neplextech / canvacord

Easily generate images using react-like components in nodejs. Canvacord is suitable for creating dynamic images such as social media posts, greetings cards, memes, etc. It is also possible to create your own templates and builders to generate images. You are only limited by your imagination.
https://canvacord.neplex.dev
GNU General Public License v3.0
254 stars 72 forks source link

Error: No fonts are loaded. #198

Closed beepboopdai closed 7 months ago

beepboopdai commented 8 months ago

const rank = new canvacord.RankCardBuilder() .setAvatar(targetUserObj.user.avatarURL({ size: 256 })) .setRank(currentRank) .setLevel(fetchedLevel.level) .setCurrentXP(fetchedLevel.xp) .setRequiredXP(calculateLevelXp(fetchedLevel.level)) .setStatus(targetUserObj.presence.status) .setUsername(targetUserObj.user.username) .setFonts("Arial")

i was trying to run this code but everytime i run the command i just get "Error: No fonts are loaded."

TomasSlekys commented 7 months ago

I'm facing the same issue

twlite commented 7 months ago

@TomasSlekys @beepboopdai You need to manually register at least one font in v6. Place the following at the top of your file and make sure it only runs once to prevent memory leaks.

// loads the bundled "Geist" font
require('canvacord').Font.loadDefault()
TomasSlekys commented 7 months ago

@TomasSlekys @beepboopdai You need to manually register at least one font in v6. Place the following at the top of your file and make sure it only runs once to prevent memory leaks.

// loads the bundled "Geist" font
require('canvacord').Font.loadDefault()

thanks! It works now :)