Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.14k stars 1.17k forks source link

Font isn't loaded on v2.11.0 #2191

Open ErnestoRB opened 1 year ago

ErnestoRB commented 1 year ago

Issue

On v2.10.2 the follwing snippet was printing the text as expected and no warning was shown. On v2.11.0 warning is printed and the text isn't draw with the declared font. Seems like the problem only happens with fonts that aren't installed on the system.

Steps to Reproduce

registerFont("./BLADRMF.ttf", { family: "Blade" });
const canvas = createCanvas(200, 200);
const ctx = canvas.getContext("2d");
ctx.font = "20px 'Blade'";
ctx.fillText("Testing", 0, 0);
// etc.

Desired beheavior: No warning and text drawn with the set font.

Actual behavior:

(process:13200): Pango-WARNING **: 22:36:14.818: couldn't load font "Blade Runner Movie Font Not-Rotated 20px", falling back to "Sans Not-Rotated 20px", expect ugly output.

And text drawn with fallback font.

Your Environment

zbjornson commented 1 year ago

I'm not positive if this is the same issue, but there's some issue with fonts in 2.11.0 prebuilds on Windows that seems to be due to a difference in one of node-canvas's dependencies between 2.10.2 and 2.11.0. It'll take a while to figure out which of the ~35 dependencies is causing it unfortunately. Until then, can you use v2.10.2?

flohall commented 1 year ago

Is this only an issue with the prebuilds or does it also occur if you build canvas from source npm i --build-from-source after cleaning node_modules @ErnestoRB?

DARK-ECNELIS commented 1 year ago

Is this only an issue with the prebuilds or does it also occur if you build canvas from source npm i --build-from-source after cleaning node_modules @ErnestoRB?

I can say that using npm i --build-from-source does not fix the problem (win/Linux)

hassannaftabb commented 1 year ago

Is this only an issue with the prebuilds or does it also occur if you build canvas from source npm i --build-from-source after cleaning node_modules @ErnestoRB?

I can say that using npm i --build-from-source does not fix the problem (win/Linux)

Hi, can you look into this issue? https://github.com/Automattic/node-canvas/issues/2285 , i have been trying to resolve this thing but couldn't, would appreciate, thanks