Ask coding questions

← Back to all posts
Fontconfig error: Cannot load default config file
Trunks8257

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

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
enigmaxx1
abdulnaufalpv
hapishanipuddin
Trunks8257
Comments
hotnewtop
Coder100

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

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.

  1. Using the font

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

Trunks8257

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

Coder100

no problem! @Trunks8257

Trunks8257

@Coder100
it worked, thank you!!!

Coder100

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

Trunks8257

@Coder100
Semi Bold Open Sans

Coder100

nice! That's a good font! @Trunks8257

Trunks8257

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

OctagonalT

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

Coder100

Hmm send repl @OctagonalT

OctagonalT

@Coder100 Link?

Coder100
OctagonalT
Coder100
Coder100

Is the error fatal? @OctagonalT

OctagonalT

@Coder100 no, the program continues

Coder100

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

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

Coder100
OctagonalT

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

Coder100

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

OctagonalT
Coder100
OctagonalT

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

Coder100

your text is white lol @OctagonalT

OctagonalT

@Coder100 oh- shi-

Coder100

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

OctagonalT

Thanks dude @Coder100

Coder100
marcos10pc

Thanks c:

TarunB1

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

TarunB1

could u send ur rep
@Coder100

CrazyBotBoy

Nice! This is what I've been looking for.

Abdullah2222

thx Coder100

Abdullah2222

thank u so mush

FishyFlick

could u help me @Coder100
(node:340) UnhandledPromiseRejectionWarning: ReferenceError: registerFont is not defined

Coder100

hello, i think it has been fixed on discord? @FishyFlick

FishyFlick

ye ty <3 @Coder100

JabalanProducti

@Coder100 i got same problem to -_-

JabalanProducti

can you help me? @Coder100