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

Missing fonts in chart.js in the layer for Node 20 #27

Open
SOVALINUX opened this issue Sep 27, 2024 · 4 comments
Open

Missing fonts in chart.js in the layer for Node 20 #27

SOVALINUX opened this issue Sep 27, 2024 · 4 comments
Assignees

Comments

@SOVALINUX
Copy link

SOVALINUX commented Sep 27, 2024

Hi
First of all thank you for maintaining this repo and publishing as an AWS layer!
Sorry for a bit incomplete description, but decided to raise an issue rather than keep silence :)

Context / Environment:

  • AWS Lambda Runtime x86_64
  • Node.JS 20x (both Lambda & Layer)
  • Using chartjs-node-canvas 4.1.6 and chart.js 3.9.1
  • ChartJS config doesn't contain any font settings and special characters in the config: default font & plain English

Issue:
After upgrade from Node.JS 18 to 20 using new Layer version fonts stopped to display properly (image below is shown)
What I see from the logs (no stacktrace unfortunately): Fontconfig error: Cannot load default config file
Unfortunately I don't fully understand how/where to look deeper and is it a issue of this package or some misconfiguration on my end

image

@charoitel
Copy link
Owner

Hi @SOVALINUX,

Thanks for reporting this issue. Would you mind to share sample code and let me take some time to investigate? Thank you.

@charoitel charoitel self-assigned this Oct 13, 2024
@ag-sudolabs
Copy link

I am running into the exact same issue. I am also unable to load any other font file - I am getting Could not parse font file error. You can reproduce it using the sample on your website (with and without the DejaVu font).

@SOVALINUX
Copy link
Author

Hi
Looks like we've managed to fix the issue and the reason that the underlying docker image comes w/o preinstalled fonts
So here is how we use it now:
image
image

And here is how we changed the lambda deployment:
added resources/fonts/roboto-regular.ttf to the project and updated the bundling:
image

@Jeff-Tham
Copy link

Jeff-Tham commented Jan 3, 2025

Hi Looks like we've managed to fix the issue and the reason that the underlying docker image comes w/o preinstalled fonts So here is how we use it now: image image

And here is how we changed the lambda deployment: added resources/fonts/roboto-regular.ttf to the project and updated the bundling: image

Thanks, this workaround is working.
if you are using createCanvas, register font is not through canvas object.
please refer to https://www.npmjs.com/package/canvas#registerfont and add commandHooks config to the lambda bundling, same as @SOVALINUX pointed out.

FYI, it is just a workaround. Cloudwatch still log this error.
Fontconfig error: Cannot load default config file

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

No branches or pull requests

4 participants