Automattic / node-canvas

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

Pango-WARNING on every font I've tried (Windows 11) #2077

Open TomSmedley opened 2 years ago

TomSmedley commented 2 years ago

Hey everyone,

I'm trying to use Helvetica on Windows 11 and I'm getting the following error:

(process:29384): Pango-WARNING **: 10:51:41.517: couldn't load font "Helvetica Neue Heavy Not-Rotated 120px", falling back to "Sans Heavy Not-Rotated 120px", expect ugly output.
(process:29384): Pango-WARNING **: 10:51:41.529: couldn't load font "Helvetica Neue Heavy Not-Rotated 32px", falling back to "Sans Heavy Not-Rotated 32px", expect ugly output.

I've tried 4 different version of Helvetica now and I'm getting the same error on every single one. This is my code:

registerFont('./fonts/HelveticaNeue-Heavy.otf', {
  family: 'Helvetica Neue Heavy',
})

const canvas = createCanvas(1200, 630)
const context = canvas.getContext('2d')

/* DRAW GRADIENT */
const gradient = context.createLinearGradient(0, 0, 0, 630)
gradient.addColorStop(0, '#DBECDD')
gradient.addColorStop(1, '#E2D1F9')

context.fillStyle = gradient
context.fillRect(0, 0, 1200, 630)

/* DRAW FLOWER NAME */
const name = flower.name.split(' ')
context.font = '120px "Helvetica Neue Heavy"'
context.fillText(name[0], 60, 180)
context.fillText(name[1], 60, 300)

/* DRAW FLOWER DESCRIPTION */
context.font = '32px "Helvetica Neue Heavy"'
context.fillText(flower.description, 60, 420)

I'm not entirely sure what I'm doing wrong. Any ideas?

Orangenal-name commented 1 year ago

Still getting this issue myself, it's not just helvetica I've tried either, it happened with lexend, and funnily enough it also happened with sans?

mirko-ll commented 1 year ago

Did anyone resolve this issue? I've tried adding multiple fonts, but keep getting same error...

IHZAQ commented 2 months ago

Woah, even 2 years later Still no respond from dev? wow Ye getting same problem