Crate ab_glyph

source ·
Expand description

API for loading, scaling, positioning and rasterizing OpenType font glyphs.

§Example

use ab_glyph::{point, Font, FontRef, Glyph};

let font = FontRef::try_from_slice(include_bytes!("../../dev/fonts/Exo2-Light.otf"))?;

// Get a glyph for 'q' with a scale & position.
let q_glyph: Glyph = font
    .glyph_id('q')
    .with_scale_and_position(24.0, point(100.0, 0.0));

// Draw it.
if let Some(q) = font.outline_glyph(q_glyph) {
    q.draw(|x, y, c| { /* draw pixel `(x, y)` with coverage: `c` */ });
}

Modules§

Structs§

Enums§

Traits§

  • Functionality required from font data.
  • A Font with an associated pixel scale. This can be used to provide pixel scale values for glyph advances, heights etc.
  • Logic for variable fonts.

Functions§