Skip to content

font

A bitmap or TTF-based font object storing glyph data. Used for measuring/drawing text. Freed when GC sees no references.

linegap accessor

Get or set the font's additional line spacing above the built-in metrics.

value: (when setting) The new line gap.

Returns: The current line gap (when getting), or None (when setting).

height accessor

(read only)

The baseline-to-baseline height in pixels.

Returns: The font's total height in px.

ascent accessor

(read only)

How far above the baseline the font extends.

Returns: A scalar float for ascent.

descent accessor

(read only)

How far below baseline the font extends.

Returns: A scalar float for descent.

text_size(text, letterSpacing, wrap) function

Measure a piece of text's width/height when rendered with this font.

text: The string to measure.

letterSpacing: Extra spacing between characters.

wrap: If nonzero, word-wrap to this maximum width.

Returns: [width, height] as a float array.