simvx.core.text.font

Font loading via freetype-py with proper glyph metrics and outline access.

Module Contents

Classes

GlyphMetrics

Metrics for a single glyph.

Font

TrueType font with freetype-py for outlines and metrics.

API

class simvx.core.text.font.GlyphMetrics

Metrics for a single glyph.

char: str

None

advance_x: float

None

bearing_x: float

None

bearing_y: float

None

width: int

None

height: int

None

contours: list[list[tuple[float, float, bool]]] | None

None

class simvx.core.text.font.Font(path: str | pathlib.Path, size: int = 64, face_index: int = 0)

TrueType font with freetype-py for outlines and metrics.

Initialization

get_glyph(char: str) simvx.core.text.font.GlyphMetrics

Get glyph metrics and outline contours.

get_kerning(left: str, right: str) float

Get kerning adjustment between two characters in pixels.

render_bitmap(char: str) tuple

Render a glyph using FreeType’s hinted bitmap rasterizer.

Returns (bitmap_hw_uint8, GlyphMetrics) where bitmap is an (H, W) uint8 array of coverage values. Uses auto-hinting for maximum crispness at small sizes.

property line_height: float

Line height in pixels.

property ascender: float

Ascender in pixels.

property descender: float

Descender in pixels (negative).