simvx.core.text.msdf

True MSDF atlas generation from vector contours.

Generates multi-channel signed distance fields from FreeType glyph outlines. Each RGB channel encodes distance to a different set of edges, enabling sharp corner reconstruction in the fragment shader via median filtering.

Module Contents

Classes

GlyphRegion

Atlas region for a packed glyph.

MSDFAtlas

MSDF font atlas with incremental shelf-based bin packing.

BitmapAtlas

Font atlas using FreeType hinted bitmap rendering (no SDF).

API

class simvx.core.text.msdf.GlyphRegion

Atlas region for a packed glyph.

char: str

None

x: int

None

y: int

None

w: int

None

h: int

None

metrics: simvx.core.text.font.GlyphMetrics

None

u0: float

0.0

v0: float

0.0

u1: float

0.0

v1: float

0.0

class simvx.core.text.msdf.MSDFAtlas(font: simvx.core.text.font.Font, atlas_size: int = 1024, glyph_padding: int = 4, sdf_range: float = 4.0, charset: str | None = None)

MSDF font atlas with incremental shelf-based bin packing.

Glyphs are rendered on demand and appended to the atlas. ASCII is pre-seeded at init time so Latin text works without re-uploads.

Initialization

ensure_glyphs(text: str) bool

Ensure all glyphs in text are in the atlas.

Returns True if the atlas was modified (caller should re-upload).

get_uv(char: str) tuple[float, float, float, float]
class simvx.core.text.msdf.BitmapAtlas(font_path: str, target_size: int, atlas_size: int = 512, charset: str | None = None)

Font atlas using FreeType hinted bitmap rendering (no SDF).

Produces pixel-perfect glyphs at a fixed target size. The atlas format is RGBA with R=G=B=coverage so the MSDF shader’s median(r,g,b) acts as a simple alpha blend passthrough.

Initialization

ensure_glyphs(text: str) bool
get_uv(char: str) tuple[float, float, float, float]