Crate fonterator
source ·Expand description
Fonterator is a pure Rust font loader. When you want to render text, fonterator gives you an
iterator over footile PathOp
s, 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*/
}
Structs
A FontChain is a collection of fonts that together should cover all of the unicode codepoints.
An iterator created by
FontChain::render()
for PathOp
s.Enums
The type for errors returned by Fonterator.
PathOp from Footile.
Path operation.
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.