Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use custom fonts "Fontconfig error: Cannot load default config file: No such file: (null)" #4075

Open
MarianoFacundoArch opened this issue Apr 19, 2024 · 1 comment
Labels

Comments

@MarianoFacundoArch
Copy link

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");
@lovell
Copy link
Owner

lovell commented Apr 19, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants