Class Font
How text looks, as a plain table given to DrawableText and Text.measure. Fields left out take their defaults, so {} is 14 px sans-serif at weight 400.
Errors for a font with both family and file, a field that isn't one of the four, and a size or weight outside its limits.
lua
local title_font = { family = "sans-serif", size = 13, weight = 600 }
local clock_font = { family = "monospace", size = 16 }
local metrics = Text.measure("12:00", clock_font)Properties
font.family: string?family
A family name such as "Inter" or "JetBrains Mono", or one of "sans-serif", "serif" and "monospace" for the system's default of that style.
- Default:
"sans-serif". - Characters the family doesn't have come from other installed fonts.
font.file: string?file
The path of a font file, used instead of a family.
- A text drawable with a path that isn't a font draws nothing.
Errors in Text.measure when the path isn't a font.
font.size: number?size
In logical pixels, so text keeps its size on a scaled output.
- Default: 14.
- Above 0 and at most 1024.
font.weight: integer?weight
400 is regular and 700 is bold. A family without that weight uses its nearest one.
- Default: 400.
- 1 to 1000.