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

[fontBuilder] Default panose value is set to a dict #3197

Closed
NightFurySL2001 opened this issue Jul 3, 2023 Discussed in #3196 · 3 comments · Fixed by #3201
Closed

[fontBuilder] Default panose value is set to a dict #3197

NightFurySL2001 opened this issue Jul 3, 2023 Discussed in #3196 · 3 comments · Fixed by #3201

Comments

@NightFurySL2001
Copy link
Contributor

NightFurySL2001 commented Jul 3, 2023

When using fontBuilder to build a font, the default panose is set as a dictionary and not a object namespace causing issues downstream.

Discussed in #3196

Originally posted by NightFurySL2001 July 2, 2023
3. extractor raises two error: AttributeError: 'dict' object has no attribute 'bFamilyType' ...
I can't catch the bug for the former. Maybe it's due to fontbuilder doesn't build panose?

Originally posted by @anthrotype in https://github.com/robotools/extractor/issues/58#issuecomment-1617773977

looks to me like a bug in the fontBuilder, because it leaves the OS/2 table's panose attribute as a dictionary (as in _panoseDefaults), whereas it should set it to a Panose object like the OS/2 table's decompile method does. The reason it works when saving from the fontBuilder is that the fonttools' sstruct.pack method accepts either an object or a dictionary and so compile works regardless.
We should fix it in fonttools. @NightFurySL2001 do you mind filing an issue or working on a PR even?
As a workaround, you could temporarily save the fontBuilder's font (to a tempfile or BytesIO stream), reload it and then try to extractor it. I believe it will work then, for the panose attribute will be an object and not a dict upon decompiling.

@NightFurySL2001
Copy link
Contributor Author

After thinking a bit more, maybe fontBuilder should provide a method to normalise the TTFont object in it? There are multiple ways that the TTFont object might be messed up during the building process, including passing in an integer value as the version number as shown in robotools/extractor/issues/59.

@anthrotype
Copy link
Member

Hm no i think that would be out of scope for fontBuilder

@anthrotype
Copy link
Member

The bugfix to set an object instead of a plain dict as panose attribute is legit and we should get it done. Would you send a PR?

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

Successfully merging a pull request may close this issue.

2 participants