Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registerFont() issue - not all fonts register #1880

Open
edmaybert opened this issue Aug 16, 2021 · 6 comments
Open

registerFont() issue - not all fonts register #1880

edmaybert opened this issue Aug 16, 2021 · 6 comments

Comments

@edmaybert
Copy link

Issue or Feature

When registering several fonts in a row, only some of them work work.

Steps to Reproduce

If I register my fonts as such:

var fontDir = <path_to_the_local_font_dir>;
var fontFamily, fontFileTTF;

//register font COPPERPLATE LIGHT
fontFamily = "copperplate_light_IBF_50e340f8-4f7f-4071-b015-5b527db4e8be";
fontFileTTF = fontDir + "/" + fontFamily + ".ttf"; 
registerFont(fontFileTTF, { family:  fontFamily  , weight: 'normal', style: 'normal'  });

 //register font COPPERPLATE REGULAR
fontFamily = "copperplate_regular_IBF_50e340f8-4f7f-4071-b015-5b527db4e8be";
fontFileTTF = fontDir + "/" + fontFamily + ".ttf"; 
registerFont(fontFileTTF, { family:  fontFamily  , weight: 'normal', style: 'normal'  });

//register font COPPERPLATE BOLD
fontFamily = "copperplate_bold_IBF_50e340f8-4f7f-4071-b015-5b527db4e8be";
fontFileTTF = fontDir + "/" + fontFamily + ".ttf"; 
registerFont(fontFileTTF, { family:  fontFamily  , weight: 'normal', style: 'normal'  });

Only 2 of the 3 fonts display correctly.

The weird thing is, if I rearrange the order of registration, a different 2 of 3 display correctly.

So basically 1 always does not display, and it's always different given the ordering.

There are no errors and the fonts do exist as evidenced by the fact they do display if I comment out 2 of the 3.
Individually, they work as well.

Your Environment

fabric@4.5.0
canvas@2.8.0
Ubuntu Release: 20.04

Any help troubleshooting would be greatly appreciated.
~ed

@david-sabata
Copy link

I think this may be similar to what's discussed in #1572

What I understood, you cannot easily register fonts with unique families, because the OS will still take the family and subfamily from the actual font file. I was hoping to use the same trick as you, but it seems that currently, the only reliable way is patching the fonts, as mentioned here

But @chearon is working on some changes that could greatly improve the situation. So fingers crossed! 🤞

@edmaybert
Copy link
Author

Thank you for that! I've been pulling my hair out trying to find out why this was happening. I'm not sure I understand what they mean by "patching fonts" though.

@david-sabata
Copy link

It's editing the otf/ttf font files using a tool like fontforge. I didn't go that far, so I cannot tell you if that actually works though

@edmaybert
Copy link
Author

Ah ok. I thought perhaps it was some programmatic work-around.
Thanks so much for all your help.

Also, chearon seems to have made a commit 17 days ago
"select fonts via postscript name on Linux"

Is this the fix for this issue? If so, how can I incorporate the fix? Would I need to build the package from source?

@david-sabata
Copy link

That's up to him to describe. I think so far it's just an isolated commit

@edmaybert
Copy link
Author

True. Well like you said, fingers crossed. :)
Thanks again for all your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants