Skip to main content

Module text

Module text 

Source
Expand description

Text: font loading, signed-distance-field glyph atlas and layout.

Glyph outlines are read from the TrueType glyf table with read-fonts (simple and composite glyphs), rasterized once at RASTER_PX by a small coverage rasterizer, converted to a signed distance field and packed into a single-channel atlas. The SDF stays sharp from a few pixels up to large zoom levels, so text never needs to be re-rasterized while zooming.

Layout follows the scene contract (Text::height is the cap-to-descender height; lines are 1.2 × height apart). With the default font, glyph positions come from Text::line_pens — the advance widths and pair kerning shared with dotloom-geometry — so drawn text and the engine’s text boxes (hit-testing, culling) agree exactly. Other fonts are laid out with their own advances.

Structs§

TextSystem
Font, atlas and glyph cache.

Constants§

ATLAS_SIZE
Atlas edge length (fits WebGL2’s guaranteed 2048 texture limit).
DEFAULT_FONT
The default font: a subset of Inter Regular (SIL OFL 1.1, see assets/).
RASTER_PX
Rasterization size of atlas glyphs (pixels per em).
SPREAD
SDF spread and glyph padding in raster pixels.