Drawing.loadfont
Loads a font file and returns an id for Drawing.Font.
Syntax
Drawing.loadfont(path: string, size?: number, smooth?: boolean) -> number
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Full path to a .ttf or .otf file. |
size | number | Pixel size, clamped to 6-96. Defaults to 14. |
smooth | boolean | Optional. When true the font is baked without hinting; omitted or false uses light hinting. |
Returns
| Type | Description |
|---|---|
number | Font id to assign to drawing.Font. |
Description
The request is queued from the script thread and loaded on the render thread, so the id is returned before the font is baked.
Custom ids start at 100. Text objects with an unknown id fall back to the normal UI font.
Example
local id = Drawing.loadfont("C:\\Windows\\Fonts\\arialbd.ttf", 18, true)
local text = Drawing.new("Text")
text.Text = "Custom font"
text.Font = id
text.Visible = true
Notes
- Only Drawing Text objects use the font id.
- A missing or unreadable file does not invalidate the returned id; it simply falls back.
- Prefer absolute paths.