Automattic / node-canvas

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

Text style not applied #1667

Open konnorov opened 3 years ago

konnorov commented 3 years ago

Issue or Feature

I want to use SanFrancisco. I need Black and regular styles, but for some reason the style is not applied :(

Steps to Reproduce

registerFont(__dirname + "/fonts/regular.ttf", {family: "SF"});
registerFont(__dirname + "/fonts/black.ttf", {family: "SF", weight: "bold"});

const canvas = createCanvas(512, 512);
const ctx = canvas.getContext('2d');
ctx.fillStyle = '#ffffff';
ctx.fillRect(0, 0, 512, 512);

ctx.fillStyle = '#000000';
ctx.font = '125px SF';
ctx.fillText("First text", 0, 100);

ctx.font = 'bold 85px SF';
ctx.fillText("Second text", 0, 175);

Your Environment

image

surdu commented 2 years ago

Having the same issue

slavafomin commented 1 month ago

Any solutions to this? Using latest versions on Ubuntu.