registerFont()
Register fonts for @napi-rs/canvas to use (EXTENSION OF GlobalFonts.register())
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| pathOrURL | string | β | The path or URL to the font file. | |
| name | string | β | The name of the font. | |
| timeout | number | β | 1500 | Request timeout in milliseconds (IF FONT IS A URL). |
Returnsβ
- Promise<
void>
Throwsβ
XpFatal- If invalid parameters are provided.
[JS] Exampleβ
const {registerFont} = require('simply-xp');
const {Path} = require('path');
await registerFont("https://cdn.jsdelivr.net/fontsource/fonts/mochiy-pop-one@latest/japanese-400-normal.woff2", "MochiyPopOne");
// OR
await registerFont(Path.join(__dirname, "fonts", "MochiyPopOne.ttf"), "MochiyPopOne");