Custom Fonts in Discord Bot

Hi, I’m using canvas module in code of my Discord bot. How can I get custom fonts, because the Docs of Canvas say that the font must be installed, so how can I install it?

Canvas has registerFont(). If you upload the font locally using wget then you can register the font like Canvas.registerFont('path/to/font/fontName.ttf', {family: 'fontFamily'});

fc-list shows you a list of installed fonts.

And how can we install more fonts?

you can just import these fonts to your Glitch project. Or by adding the fonts via git

git clone https://<user-token>@api.glitch.com/git/<project-name>
git checkout -b local

then you can copy the fonts into one fo the directory.

After that you’ll have to upload them to Glitch:

git add .
git commit -m "Added fonts"
git push -u origin local

Then you’ll go into the Glitch Console for your project to merge the local branch with the master branch.

git merge local
refresh

The refresh command is to refresh the connection between the editor and your project.

1 Like

Um but can i not use it from the assets?

You should be able to!

it says no:
Error: ENOENT: no such file or directory, lstat '/app/https:'

Well I guess then you should load the fonts into your project. Do you want me to show you how?

i have no clue how to do it so yessir

is it not supposed to be like:

Canvas.registerFont(’’, { family: ‘font name’ })

Open the console and run this (replace url with the link to the raw font file):

wget url && refresh

Once you run this, the file should be in your project. Rename it to what you want.

yayy that worked doggo sensei rules!

2 Likes

Hi,
I got the same problem as hhhunterwolf but I don’t really understand because I still have an error :

Error: ENOENT: no such file or directory, lstat ‘/1075e213-e003-451f-8b10-e48f6dcb4785%2FLondrinaSolid-Regular[1].ttf?v=1598974942961’

and even more, I can’t rename my file with .ttf extension because if I do this, the file just disappear of my project !

So can you help me :wink:

Run wget cdnlinkhere -O font.ttf

Haha! @RiversideRocks should make his slogan and change his bio to ‘The doggo sensei’! :joy:

1 Like

Thanks for this answer, I found the solution after 2 hours of research and just before you replied me !
So I didn’t run your command but it’s probably working

1 Like

CDN files can be a bit tricky because the v parameter throws some languages off.

I’ll figure something out! Keep your eyes peeled.

it could be possible that .ttf files are hidden like .log files. I think we need a complete list of files glitch hides somewhere or it could be just all files git automatically ignores

How to address the assets folder?