Expand description
SDF (Signed Distance Field) generation from rasterized glyph bitmaps.
Uses a dead-reckoning (8SSEDT) algorithm for O(n) per-pixel SDF computation, with optional multi-channel SDF (MSDF) for sharper corners.
The pipeline:
- Rasterize each glyph at high resolution (256px) via
ab_glyph - Compute SDF at output resolution (typically 64px) using dead reckoning
- Pack glyphs into an atlas using a shelf packing algorithm
- Optionally cache the atlas to disk as a PNG for fast reload
Structs§
- Msdf
Glyph Data - Multi-channel SDF result: R, G, B channels each contain distance to a different edge segment class, producing sharper corners when median-filtered.
- SdfAtlas
Data - Complete result of SDF atlas generation.
- SdfConfig
- Configuration for SDF generation.
- SdfGlyph
Data - SDF data for a single glyph, before atlas packing.
- SdfGlyph
Metric - UV rectangle for one glyph in the SDF atlas.
Functions§
- generate_
glyph_ msdf - Generate MSDF data for a single glyph using Chlumsky’s approach.
- generate_
glyph_ sdf - Generate SDF data for a single glyph.
- generate_
sdf_ atlas - Generate the complete SDF atlas for all
ATLAS_CHARS.