Skip to main content

Module sdf_generator

Module sdf_generator 

Source
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:

  1. Rasterize each glyph at high resolution (256px) via ab_glyph
  2. Compute SDF at output resolution (typically 64px) using dead reckoning
  3. Pack glyphs into an atlas using a shelf packing algorithm
  4. Optionally cache the atlas to disk as a PNG for fast reload

Structs§

MsdfGlyphData
Multi-channel SDF result: R, G, B channels each contain distance to a different edge segment class, producing sharper corners when median-filtered.
SdfAtlasData
Complete result of SDF atlas generation.
SdfConfig
Configuration for SDF generation.
SdfGlyphData
SDF data for a single glyph, before atlas packing.
SdfGlyphMetric
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.