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Β§

codepoint_ids πŸ”’
err πŸ”’
font πŸ”’
font_arc πŸ”’
glyph πŸ”’
outlined πŸ”’
scale πŸ”’
ttfp πŸ”’
ttf-parser crate specific code. ttf-parser types should not be leaked publicly.
v2
variable πŸ”’

StructsΒ§

CodepointIdIter
FontArc
Font implementor that wraps another concrete Font + 'static type storing in an Arc.
FontRef
Font data handle stored as a &[u8] + parsed data. See Font for more methods.
FontVec
Font data handle stored in a Vec<u8> + parsed data. See Font for more methods.
Glyph
A glyph with pixel scale & position.
GlyphId
Glyph id.
GlyphImageDeprecated
Old version of v2::GlyphImage.
GlyphSvg
InvalidFont
Invalid font data error.
Outline
A β€œraw” collection of outline curves for a glyph, unscaled & unpositioned.
OutlinedGlyph
A glyph that has been outlined at a scale & position.
Point
An (x, y) coordinate.
PxScale
Pixel scale.
PxScaleFactor
2D scale factors for use with unscaled metrics.
PxScaleFont
A Font and an associated pixel scale.
Rect
A rectangle, with top-left corner at min, and bottom-right corner at max.
VariationAxis

EnumsΒ§

GlyphImageFormat
Valid formats for a GlyphImage.
OutlineCurve
Glyph outline primitives.

TraitsΒ§

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

FunctionsΒ§

point
Point constructor.