[][src]Crate fonterator

Fonterator is a pure Rust font loader. When you want to render text, fonterator gives you an iterator over footile PathOps, which you can easily pass right into footile.

Simple Example

In Cargo.toml,

[dependencies]
fonterator = "0.4.0"

In main.rs,

use fonterator::FontGroup;
use footile::{FillRule, Plotter, Raster, Rgba8};

fn main() {
    // Load the default FontGroup (font and fallbacks).
    let font = FontGroup::default();

    // Init rendering
    let mut p = Plotter::new(2048, 2048);
    let mut r = Raster::new(p.width(), p.height());

    // Render the text
    let mut path = font.render(
        "Héllö,\nWørłd!‽i", /*text*/
        (0.0, 0.0),         /*position*/
        (256.0, 256.0),     /*size*/
    );
    r.over(
        p.fill(&mut path, FillRule::NonZero),
        Rgba8::rgb(0, 0, 0), /*color*/
    );
    r.write_png("main.png").unwrap(); /*save as PNG*/
}

Re-exports

pub use footile;

Structs

FontGroup

A FontGroup is a collection of fonts that together should cover all of the unicode codepoints.

PathIterator

An iterator created by FontGroup.render() for PathOps.

Enums

Error

The type for errors returned by Fonterator.

PathOp

Path operation.

SharedBytes

SharedBytes handles the lifetime of font data used in Fonterator. The data is either a shared reference to externally owned data, or managed by reference counting. SharedBytes can be conveniently used with From and Into, and dereferences to the contained bytes.