You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
registerFont('./fonts/HolidayExtrasSans-Light.ttf',{family: 'holiday extras light'});registerFont('./fonts/HolidayExtrasSans-Regular.ttf',{family: 'holiday extras regular'});// This font not outputtingregisterFont('./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
The text was updated successfully, but these errors were encountered:
The custom font system is imperfect because font APIs on the OS don't let you pick via file path, only by weight/family/style. node-canvas does its best to pick the weight/family/style that will resolve to the exact TTF you registered, but sometimes the OS returns the wrong font.
I see there are other issues detailing difficulties with multiple fonts, but these seem to have been raised a number of years ago.
Not much has changed since those issues, unfortunately. I see that you're having the issue on macOS which is the worst platform for font selection. Does your application run on Linux? Very soon we will have #1572 fixed which will mean near-perfect font selection, but only on Linux.
The other thing you can do is manually patch the fonts in something like FontForge. Tweak the weight or give each TTF a unique family name and that should do it.
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.
weight: ''
declaration.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
Your Environment
Canvas version: 2.6.1
node v10.15.1 on macOS Catalina 10.15.6
The text was updated successfully, but these errors were encountered: