Fontconfig error: Cannot load default config file
Trunks8257 (2)

Hi, I recently started with repl.it and I'm getting this error while using canvas in node.js. Is there a solution? In the image, all the characters are squares
Thanks in advance

You are viewing a single comment. View All
Coder100 (18917)

Hello, that is because there is no default font with repl.it. I have experienced this with my code on canvas too, and I have created a solution.

  1. Import the registerFont
const { registerFont } = require('canvas');

Append this line and don't replace it with previous imports.

  1. Install a font.
    Go to like google fonts and then choose a font and install it. Then, unzip the folder and then drag the fonts in question to your repl.

  2. Register the font.

registerFont('path/to/font.ttf', { family: 'InsertFontNameHere' });
  1. Using the font
ctx.font = '30px InsertFontNameHere';

Hopes this helps! Be sure to accept it as the correct answer if it worked for you!

Trunks8257 (2)

@Coder100
Thanks! I will add it and see if it works

Trunks8257 (2)

@Coder100
it worked, thank you!!!

Coder100 (18917)

yay!!! no problem!!! What font did you use? @Trunks8257

Coder100 (18917)

nice! That's a good font! @Trunks8257

Trunks8257 (2)

@Coder100
yes, and I can use it thanks to you

OctagonalT (9)

@Coder100 I'm still getting an error: Fontconfig error: Cannot load default config file

OctagonalT (9)

@Coder100 no, the program continues

Coder100 (18917)

hmm, I am going to jump the conclusion that if that error only prints text, and your canvas works fine, you can safely ignore it @OctagonalT

OctagonalT (9)

@Coder100 There's no text on the canvas (dont judge the image pls)

OctagonalT (9)

@Coder100 It should have the text "hi" somewhere (its for testing) but there isn't

Coder100 (18917)

hmm, can I make a quick repl and see if it works? @OctagonalT

OctagonalT (9)

@Coder100 Can you tell me what needs to be changed for my repl?
(also sorry for not responding i had to go)

Coder100 (18917)

lol bad eyes go brr @OctagonalT
i definitely could see the text

TarunB1 (0)

@Coder100
i got the same issue could u explain wha file
t i have to add in my fonts