Expand description

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

Example

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

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` */ });
}

Structs

Font implementor that wraps another concrete Font + 'static type storing in an Arc.

Font data handle stored as a &[u8] + parsed data. See Font for more methods.

Font data handle stored in a Vec<u8> + parsed data. See Font for more methods.

A glyph with pixel scale & position.

Glyph id.

A pre-rendered image of a glyph, usually used for emojis or other glyphs that can’t be represented only using an outline.

Invalid font data error.

A “raw” collection of outline curves for a glyph, unscaled & unpositioned.

A glyph that has been outlined at a scale & position.

Pixel scale.

2D scale factors for use with unscaled metrics.

A Font and an associated pixel scale.

A rectangle, with top-left corner at min, and bottom-right corner at max.

Enums

Valid formats for a GlyphImage.

Glyph outline primitives.

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.

Functions

Point constructor.

Type Definitions

An (x, y) coordinate. Point { x: f32, y: f32 }