Ask coding questions

← Back to all posts
Cannot add text to Node.js canvas
tamkerl (9)

I'm trying to make a captcha system, and right now experimenting with creating a canvas with text on it.
However, when I try to do that, the image file is created, but the text is not visible, and the console shows "Fontconfig error: Cannot load default config file".

I tried searching for it, and I found an answer here:
But that answer involved editing a file that is not accessible from
Does anyone know how to fix this in any other way?

chandlerpc (0)

I have the same error, i'm working on a discord bot

chandlerpc (0)

Hey, I solved the problem, the error is because don have files .ttf, you only download a .tff and upload to proyect, on the code you need to change the direction of your file for the new typography, now the console know the typography, sorry for my bad english.

GlitchyBrick (2)

@chandlerpc Hey, I added the .ttf file to my project how do i change the direction of the file

this is my code
ctx.font = '35px sans-serif'

chandlerpc (0)

@GlitchyBrick you can use the
registerFont function,like this

registerFont('./Impact.ttf', { family: 'Impact' });

In the canvas this :
ctx.font = '28px Impact';