Automattic / Automattic/node-canvas
Issue with loading custom fonts using registerFont()
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
## Issue with loading custom fonts using registerFont()
**Note**: I have tried multiple fonts so problem is not in font files... Keep getting this error below and output in fallback font...
(process:22832): Pango-WARNING **: 12:52:05.268: couldn't load font "Zen Dots Not-Rotated 40px", falling back to "Sans Not-Rotated 40px", expect ugly output.
## Steps to Reproduce
```js
registerFont("./ZenDots-Regular.ttf", {
family: "Zen Dots",
});
const canvasInit = canvas.createCanvas(1000, 500);
const ctx = canvasInit.getContext("2d");
ctx.font = '40px "Zen Dots"';
const color = "#ffffff";
ctx.fillStyle = color;
ctx.fillText(
"Whereas disregard and contempt for human rights have resulted",
10,
100
);
// etc.
```
## Your Environment
* Version of node-canvas (output of `npm list canvas` or `yarn list canvas`): 2.11.2
* Environment (e.g. node 4.2.0 on Mac OS X 10.8): node 18.16.0
* OS: Windows 11
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.