Automattic / Automattic/node-canvas

Font isn't loaded on v2.11.0

Open
#2,191 4 comments 0 reactions 0 assignees View on GitHub
Bug Text & Fonts
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

## 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

```js
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
* Version of node-canvas (output of `npm list canvas` or `yarn list canvas`): v2.11.0
* Environment (e.g. node 4.2.0 on Mac OS X 10.8): node v16.13.0 on Windows 10 Pro 19045.2486

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the provided registerFont/createCanvas snippet with node-canvas v2.11.0 on the reported Windows environment and compare it with v2.10.2. Trace the registered-font lookup and the Pango warning, then verify that the declared Blade font renders without a fallback warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.