textmode.js / Textmodifier / loadFont
Method: loadFont()
ts
loadFont(fontSource, setActive?): Promise<TextmodeFont>;Load a font and optionally set it as the base layer's active font.
Accepts either a URL string to load a new font, or an existing TextmodeFont instance to use as a reusable source.
If setActive is true (default), the font is set as the base layer's font. If setActive is false, the font is loaded/initialized and returned without modifying the layer.
The returned font can be reused on other layers via TextmodeLayer.loadFont, which creates a layer-local fork rather than sharing a mutable instance by reference.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
fontSource | | string | TextmodeFont | undefined | Font URL or reusable TextmodeFont instance. |
setActive | boolean | true | Whether to activate the font on the base layer. Defaults to true. |
Returns
Promise<TextmodeFont>
The loaded TextmodeFont.