Custom Fonts in Discord Bot


#1

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?


#2

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.


#3

And how can we install more fonts?


#4

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/<project-name>/git
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.