FontRegistry.registerCustomFont()
Adds a font from TTF/OTF bytes.
methodRegisteringsince 1.0.0
Signature
registerCustomFont(font: CustomFont & { ttfBytes: Uint8Array }): void
Parameters
| Parameter | Type | Description |
|---|---|---|
| font | CustomFont & { ttfBytes: Uint8Array } | { id, displayName, ttfBytes, category?, cssFallback? } — the same bag as a fonts.customFonts entry. category defaults to 'sans-serif'; cssFallback to the display name, then sans-serif. |
Returns
void
Example
TypeScript
const ttfBytes = new Uint8Array(await (await fetch('/fonts/brand.ttf')).arrayBuffer()); fonts.registerCustomFont({ id: 'brand', displayName: 'Brand Sans', ttfBytes, category: 'sans-serif' });