Aller au contenu principal

registerFont()

Enregistrez des polices pour que @napi-rs/canvas les utilise (EXTENSION DE GlobalFonts.register())

Paramètres

ParamètreTypeRequisDéfautDescription
pathOrURLstringLe chemin ou l'URL vers le fichier de police.
namestringLe nom de la police.
timeoutnumber1500Délai d'attente de la requête en millisecondes (SI LA POLICE EST UNE URL).

Retours

  • Promise<void>

Lancers

  • XpFatal - Si des paramètres invalides sont fournis.

[JS] Exemple

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"
);

// OU

await registerFont(
Path.join(__dirname, "fonts", "MochiyPopOne.ttf"),
"MochiyPopOne"
);