Skip to content
glyph_outline

glyph_outline

Mojo module 🡭

glyph_outline

Glyph outlines and metrics: the adapter between font_discovery.mojo, which resolves a family/slant/weight to a file, and ttf.mojo, which parses that file’s binary tables. Exposes the LineMetrics/GlyphMetrics/face_line_metrics/has_glyph/ glyph_metrics/glyph_path surface render.mojo calls, each of the last two paired with a glyph_index_* form addressing a glyph directly, which is what a GSUB ligature – a glyph no single codepoint names – is laid out through.

Outlines are unhinted (ttf.mojo runs no hinting bytecode), so glyph metrics differ slightly from a hinting rasterizer’s such as FreeType’s; tests/test_glyph_outline.mojo has the exact numbers.

TrueType outline space has y increasing upward, the PDF/PostScript/font-design convention. ttf.mojo’s outline_to_path applies the y-flip into this package’s y-down raster space, so this module does not repeat it.

Structs

  • LineMetrics: This face’s line metrics at its current size, in pixels. ascender/descender are signed, descender negative per hhea’s convention; line_height is the recommended baseline-to-baseline distance for stacked lines.
  • GlyphMetrics: One glyph’s layout-relevant measurements, in pixels, at whatever size was last set.

Functions