Automattic / Automattic/node-canvas
Multiple registerFont() declarations not being honoured
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
## Issue or Feature
I have 3 custom fonts I'm trying to include in my canvas using registerFont(). The reason I'm trying to bring 3 in is that I've implemented (although removed for the purpose of this) the ability for the font to be changed via url param.
The problem I'm having is that only 1st and 3rd fonts are outputting as expected, while the 2nd (regular) is defaulting. See images below of font preview and output, and next section for code block.
**HolidayExtrasSans-Light.ttf**


**HolidayExtrasSans-Regular.ttf**


**HolidayExtrasSans-Bold.ttf**


I've tried a few different steps.
- Originally I was using .OTF, so I changed to .TTF after reading about a previous issue.
- I've tried with giving each file the same family and declaring the weight of each via the `weight: ''` declaration.
- I've tried giving them each completely separate family names.
- I've tried giving them the same family but appending a unique identifier on to the end (as is now).
I see there are other issues detailing difficulties with multiple fonts, but these seem to have been raised a number of years ago.
Thanks
## Steps to Reproduce
```js
registerFont('./fonts/HolidayExtrasSans-Light.ttf', { family: 'holiday extras light' });
registerFont('./fonts/HolidayExtrasSans-Regular.ttf', { family: 'holiday extras regular' }); // This font not outputting
registerFont('./fonts/HolidayExtrasSans-Bold.ttf', { family: 'holiday extras bold' })
context.font = "200px 'holiday extras regular'"
```
## Your Environment
Canvas version: 2.6.1
node v10.15.1 on macOS Catalina 10.15.6
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.