Answer the question
In order to leave comments, you need to log in
How can I include HYWenHei font in node js using Canvas?
Here is an example of my code:
const Canvas = require('canvas')
Canvas.registerFont(path.join(__dirname + `/HYWenHei-85W.ttf`), { family: 'myFont' })
const canvas = Canvas.createCanvas(1680, 800);
const context = canvas.getContext('2d');
context.fillStyle = 'white'
context.font = "100px myFont"; //HYWenHei 85W
context.fillText("LARKY", 635, 187);
(process:7752): Pango-WARNING **: 15:24:53.793: couldn't load font "HYWenHei 85W Not-Rotated 100px", falling back to "Sans Not-Rotated 100px", expect ugly output.
Answer the question
In order to leave comments, you need to log in
Have you registered the font?
https://www.npmjs.com/package/canvas#registerfont
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question