-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
registerFont() not working and getting couldn't load font , falling back to "Sans", on any canvas version #2285
Comments
@hassannaftabb plz use this exact version |
@konyan tried, still same error, i am using windows, there could be a problem with my OS? the same is quite working in MAC, but not on my hosted server at AWS ECS, having hard time resolving that. |
@konyan I faced the same issue on latest version but v2.10.2 working perfectly fine for me! |
2.10.2 works fine on Win10x64 |
2.10.2 works |
2.10.2 used to work until I upgraded to the latest LTS version of Node. Then it couldn't find a binary for that version and I had to upgrade to the latest version, which supports Node 20.11.0 but has this font bug. |
This seems to be fixed if I compile 2.10.2 myself, but it would save me (and other future users) a lot of hassle if this was either fixed in 2.11.2 or precompiled binaries were available for 2.10.2 |
I solved this by installing the fonts into my system. It didn't worked in any other case. For my cloud server, i used docker image to manually copy the files and install the fonts. They can be easily installed in cloud servers also. I would recommend this approach. Downgrading the package versions creates a lot of hassles, most likely dependencies incompatibility issues, as you need to vary your Node version also. Using 2.10.2 and latest LTS Node caused me a lot of dependencies issues. |
@hassannaftabb How do you install the fonts into your system? Do you just drop them into the |
For my docker image, yes I copied the fonts file to the root system font configuration which could be /usr/shared/fonts ( may vary for systems ). After copying you need to cache the fonts into the system, you can get these commands easily from ChatGPT. For my Local windows, I installed the fonts by selecting all the files, right clicking and clicking install, after that only I was able to solve the loading issue. But keep in mind, wherever you setup the project, the fonts should be installed in that system, requiring from path didn't worked for me. |
The 2.10.2 is working fine. |
Could be related to the cairo and pango versions? Using canvas 2.10.2 that works fine: Using canvas 2.11.2, that has issues: |
…-rs/canvas`) Fixes font not rendering on backend due to a bug in node-canvas v2.11.2. See: Automattic/node-canvas#2285 Couldn't downgrade to v2.10.2 due to build issues on Windows. See: Automattic/node-canvas#1773 (comment) R v3.0.0 of node-canvas will remove node-pre-gyp which should make it a bit easier to install? See: https://github.com/Automattic/node-canvas/releases/tag/v3.0.0-rc2
Im pretty noob
@konalt can you update the compiled ? |
As of 2.11.2, this still seems to be broken. Any updates on this? |
Can anyone help on this? |
I'm encountering an issue where the registerFont() function is not behaving as expected.
However, I continue to receive Pango-related errors. Furthermore, I've attempted to resolve this by installing the fonts on my Windows system and rebooting, but the Pango library still cannot locate the fonts. |
Guys simply install font in windows, it is working. Use the font name showing in windows. |
@devr77 Simply doesn't work like that |
@zbjornson @chearon at least an answer would be great.. |
I have been trying to register custom fonts in the node-canvas, I have been trying it to do with
registerFont()
function, I am using [email protected] , tried with [email protected] also, my implementation for registering fonts is like this:I have this type of structure:
so always i am validating the import's path also, and it's fine.
This is my implementation for using the font in ctx.font , tried all of these:
When i go inside the font file, the name is only "Sora" i tried adding that, and also tried to change the name in the family key in registerFont to Sora Bold, but nothing works, I am getting this error at any implementation:
I tried all of these solutions:
I am using NestJS, and tried on node 18, 20 also.
I need to register multiple fonts but it's not even working for one.
Please help me on this as I am stuck, you can download the font from Google Fonts, name's "Sora".
Would appreciate any help.
Thanks.
The text was updated successfully, but these errors were encountered: