FontGlyphs

Load a font and extract glyph vertices for morphing.

Constructor

FontGlyphs(font_path: str)

Load a font file.

Parameters

font_path
Path to TTF or OTF font file

Methods

close

close()

Close the font file.

get_advance_width

get_advance_width(char: str) -> float

Get the advance width for a character in font units.

get_state

get_state(
    char: str,
    num_vertices: Optional[int] = None,
    height: Optional[float] = None,
    scale: Optional[float] = None,
    pos: Optional[Point2D] = None,
    fill_color: Optional[Color] = None,
    stroke_color: Optional[Color] = None,
    stroke_width: float = 0.0,
    _center: bool = True,
    _cursor_x: float = 0.0
) -> StateCollectionState

Get a StateCollectionState for a single character.

Parameters

char
Single character to extract
num_vertices
Vertex count per contour
height
Desired height in scene units (preferred over scale)
scale
Direct scale factor (use height instead for intuitive sizing)
pos
Position offset (default: origin) - applied during rendering
fill_color
Fill color (default: white)
stroke_color
Stroke color (default: none)
stroke_width
Stroke width (default: 0)
_center
Internal - if True center at origin, if False for text layout
_cursor_x
Internal - cursor X position for text layout

Returns

StateCollectionState containing one GlyphState per disconnected component

get_word

get_word(
    text: str,
    num_vertices: Optional[int] = None,
    height: Optional[float] = None,
    scale: Optional[float] = None,
    letter_spacing: float = 1.0,
    pos: Optional[Point2D] = None,
    fill_color: Optional[Color] = None,
    stroke_color: Optional[Color] = None,
    stroke_width: float = 0.0
) -> StateCollectionState

Get a StateCollectionState for a word.

Parameters

text
String to convert
num_vertices
Vertex count per contour
height
Desired letter height in scene units (preferred over scale)
scale
Direct scale factor (use height instead for intuitive sizing)
letter_spacing
Multiplier for space between letters (1.0 = normal, 0.5 = tight)
pos
Center position (default: origin)
fill_color
Fill color
stroke_color
Stroke color
stroke_width
Stroke width

Returns

StateCollectionState containing all glyph states