Skip to main content

Function: registerFont()

registerFont(family, source): boolean

Defined in: src/mobjects/text/registerFont.ts:39

Register a custom font so text mobjects can use it by family name.

Parameters​

family​

string

The font-family name to register the source under.

source​

FontSource

A CSS source string, a URL/path, or font binary data.

Returns​

boolean

true when the font was registered, false when the CSS Font Loading API is unavailable (for example in Node or a test worker).

Example​

registerFont('Inter', 'https://example.com/Inter.woff2');
registerFont('Inter', 'url("/fonts/Inter.woff2")'); // explicit CSS source