Automattic / Automattic/node-canvas

Pango failure when using a local font that isn't system installed

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

Description

I have 4 fonts that aren't installed on my system. They are just placed in a fonts folder in my assets folder. I load them using registerFont like said in the docs. They load fine but when I try to use them to fill some text the pango error shows up. If I install the fonts, it works fine. If I uninstall them, it stops working again. I'm on windows
```ts
for (const font of fs.readdirSync("./assets/fonts")) {
const name = font.split(".")[0];
console.log("Loading font:", name);
registerFont(`./assets/fonts/${font}`, {
family: name
})
}
```
```
(process:39704): Pango-WARNING **: 04:41:52.851: couldn't load font "FN Heading Now Bold Not-Rotated 150px", falling back to "Sans Bold Not-Rotated 150px", expect ugly output.
(process:39704): Pango-WARNING **: 04:41:52.880: couldn't load font "FN Heading Now Bold Not-Rotated 60px", falling back to "Sans Bold Not-Rotated 60px", expect ugly output.
(process:39704): Pango-WARNING **: 04:41:52.885: couldn't load font "FN Heading Now Bold 60px", falling back to "Sans Bold 60px", expect ugly output.
(process:39704): Pango-WARNING **: 04:41:52.892: couldn't load font "Heading Now Bold Italic Not-Rotated 60px", falling back to "Sans Bold Italic Not-Rotated 60px", expect ugly output.
(process:39704): Pango-WARNING **: 04:41:52.962: couldn't load font "FN Heading Now Medium Not-Rotated 20px", falling back to "Sans Medium Not-Rotated 20px", expect ugly output.
```
**canvas@3.1.2**

![Image](https://github.com/user-attachments/assets/d85bdc5a-4aea-4827-a610-189076c161f3)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.