简体   繁体   中英

Not able to load font node-canvas

I am trying to use Fira font but for some reason I am not able to do it.

registerFont('./fira.ttf', { family: 'Fira', weight: 700 });
ctx.font = '50px "Fira"';

This gives:

(process:14880): Pango-WARNING **: 20:25:33.039: couldn't load font "Fira Code Light Not-Rotated 50px", falling back to "Sans Light Not-Rotated 50px", 
expect ugly output.

(process:14880): Pango-WARNING **: 20:25:33.043: couldn't load font "Fira Code Light 50px", falling back to "Sans Light 50px", expect ugly output.

and with:

registerFont('./fira.ttf', { family: 'Fira', weight: 700 });
ctx.font = '50px';

I think it gives the right font but it's too small

The font rendering, which is done with Pango, does not find the font you registered.

You should try to change the family name, probably to Fira Code . Please check out this issue for some details: https://github.com/Automattic/node-canvas/issues/1608

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM