Expand description
Glyph source: outlines extracted on first use, never up front.
A face keeps its file bytes and rebuilds the ttf_parser::Face on
demand — parsing one is table-offset arithmetic, so the cost lands in
the noise next to the outline work it guards. Each glyph’s outline is
turned into a [tiny_skia::Path] the first time it is asked for and
cached for the process lifetime; rasterising then fills that path
into an 8-bit coverage [Mask].
The eager alternative — building every glyph in the cmap when the
face is constructed — costs 330 MB and 1.7 s of CPU for a 44 810
glyph CJK collection, to draw the hundred or so glyphs a screen
actually shows. A single arrow or bullet resolving through the
fallback chain was enough to pay it in full.
Metrics, OutlineBounds and LineMetrics keep the layout
conventions the renderers and widgets already lay text out with:
sizes scale by px / units_per_em, bounds is the outline box in
subpixels, ymin grows upwards from the baseline, and the bitmap
runs row-major from its top-left corner.
Structs§
- A glyph drawn as a colour image rather than an outline. The box is in ems, from the pen on the baseline, y up: scale it by the text size in pixels.
- A font face that materialises glyphs on demand.
- Vertical metrics of a face at a given size.
- Placement and size of one rasterised glyph.
- Bounding box of a glyph’s outline, in subpixels,
yminupwards from the baseline.