Aller au contenu principal
Version: v2.0

registerFont()

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

Paramètres​

ParamètreTypeRequisDéfautDescription
pathOrURLstring✅Le chemin ou l'URL vers le fichier de police.
namestring✅Le nom de la police.
timeoutnumber❌1500Dé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"
);