#font #truetype #opentype #ttf #otf

fonterator

Load fonts as vector graphics in pure Rust

5 unstable releases

✓ Uses Rust 2018 edition

0.3.0 Dec 9, 2018
0.2.1 Dec 8, 2018
0.2.0 Dec 2, 2018
0.2.0-pre0 Nov 25, 2018
0.1.0 May 25, 2018

#19 in Rendering

Download history 8/week @ 2018-12-14 17/week @ 2018-12-21 3/week @ 2018-12-28 11/week @ 2019-01-04 8/week @ 2019-01-11 7/week @ 2019-01-18 2/week @ 2019-01-25 3/week @ 2019-02-01 1/week @ 2019-02-15 6/week @ 2019-02-22 15/week @ 2019-03-01 8/week @ 2019-03-08 5/week @ 2019-03-15 42/week @ 2019-03-22

56 downloads per month
Used in 3 crates (1 directly)

MIT / BSL-1.0

3MB
1K SLoC

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.3.0"

In main.rs,

extern crate fonterator;
extern crate footile;

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

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

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

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

Features

  • Load TTF fonts and font collections.
  • Load some OTF fonts and font collections.
  • Automatic kerning and font layout.
  • Horizontal and vertical text layout.
  • Left-to-right and right-to-left text layout.
  • Use fallback fonts if a character is not available from one font.
  • Optional multilingual monospace (CJK is rendered exactly twice the width of Latin).

TODO

  • Support OpenType fonts that aren't TrueType (Supporting cubic bezier curves).
  • Support ligatures (‽,æ etc.).
  • Support other TrueType variants.

Links


Plop Grizzly

Dependencies