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

Canvas renders font registered previously #1537

Closed
CodysseusX opened this issue Mar 18, 2020 · 1 comment
Closed

Canvas renders font registered previously #1537

CodysseusX opened this issue Mar 18, 2020 · 1 comment

Comments

@CodysseusX
Copy link

CodysseusX commented Mar 18, 2020

I am using node canvas on AWS Lambda to produce images of text (different fonts, sizes, colours etc.) I use the registerFont() method of the API to register my font. The first time I call my function, I get the expected output. However, if I call again with a different font and font file this time, the canvas renders some previously registered font. My lambda is still warm, therefore the data is still there. I am using unique font names, files and families. Therefore, it makes no sense to me, why the canvas is rendering text using previously registered fonts. I went through several related github issues, but couldn't find a solution. Any ideas would be greatly appreciated.

Issue or Feature

Getting error: 'Fontconfig error: Cannot load default config file'

Steps to Reproduce

Register different fonts and render text. Does it render them as expected?

Your Environment

  • Version of node-canvas (output of npm list canvas or yarn list canvas):
  • Environment (e.g. node 4.2.0 on Mac OS X 10.8):
    Node 10 on AWS Lambda (Layers)
@CodysseusX
Copy link
Author

CodysseusX commented Mar 24, 2020

I resolved this by doing the following:

  1. Uploaded my fonts as a Lambda layer.
  2. Got the fontFamily metadata of each font file using Font Forge or https://opentype.js.org/font-inspector.html
  3. Registered the font with the registerFont() method by using the exact font family description I got from the metadata.

It worked perfectly.

P.S. It will only work for unique font families. For some reason, registering three different font files (.e.g Regular, Bold and Light) with the same font family description and a different weight, didn''t work.

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

No branches or pull requests

2 participants