sharp
sharp copied to clipboard
Cannot use custom fonts "Fontconfig error: Cannot load default config file: No such file: (null)"
I am providing a valid value for fontfile and even the font name, but just doesn't work. I get Fontconfig error: Cannot load default config file: No such file: (null).
File exists, is checked, and even I am providing the font name (I tried not setting the font variable at all and it is the same)
const desiredFontFile = path.join(
__dirname,
`../../../assets/fonts/SuperFunky.ttf`
);
console.log(desiredFontFile);
if (!checkFileExists(desiredFontFile)) {
throw new Error("Error retrieving font file");
}
await sharp({
text: {
text: "TEST",
fontfile: desiredFontFile,
font: "Super Funky",
rgba: true,
dpi: 3000,
},
}).toFile("test.png");
https://sharp.pixelplumbing.com/install#fonts
If fontconfig configuration is not found, the following error will occur:
Fontconfig error: Cannot load default config file
You'll need to ensure fontconfig can be found.
The section in the issue template that asked you to provide useful information about your OS etc. was ignored/deleted.
I hope this information helped. Please feel free to re-open with more details if further assistance is required.