Skip to main content
A font that shapes and draws text. Fonts come from the file’s assets with context:font(name), from a view model Property<Font>, or from bytes with Font.decode. Metrics are for a 1 point font and grow negative upwards, so multiply by the size and expect ascent below zero.

Fields

ascent

Distance from the baseline to the top of the em box for a 1 point font, negative.

descent

Distance from the baseline to the bottom of the em box for a 1 point font.

capHeight

Distance from the baseline to the top of capital letters, negative.

xHeight

Distance from the baseline to the top of lowercase letters, negative.

weight

Weight from 1 to 1000, 400 being regular.

isItalic

axes

Variable axes the font offers.

features

Four letter OpenType feature tags the font offers, such as ‘liga’.

Static Functions

decode

Decodes a TrueType or OpenType font from bytes a script obtained itself, such as a downloaded file. Font files in a project are font assets, reached with context:font, not blobs. Returns nil when the bytes are not a font.

Methods

lineHeight

Height of one line of text at the given size.

hasGlyph

Whether the font has a glyph for the unicode codepoint.

axisValue

Current value of a variable axis, by tag.

withOptions

A new font at the given axis values and feature settings.

glyphPath

Outline of one glyph in 1 point units with the baseline at y 0, wound for a clockwise fill. Scale by the font size to draw it.