i put this in the beggining of my code « registerFont(__dirname + “/onepiece.ttf”, { family: “onepiece” }); »
and applies on my text « ctx.font = “48px onepiece”;
ctx.fillStyle = “#000”;
ctx.textAlign = “center”;
ctx.fillText(username.toUpperCase(), 350, 600); »
but it dont work but the font he is detecte by the code but it dont applies on the text why?
A few things; foremost, don’t load .ttf files in modern browsers, you want the WOFF2 version instead (ttf and otf are system font formats and contain a lot of data that isn’t used in web context, while also not being compressed, so they’re huge compared to their WOFF2 equivalent).
That said: you’ll have to explain which library you’re using. If you want to use web fonts on the canvas you almost never need to use the library’s own loader, you just need to load the font with a short bit of normal @font-face CSS.