Closed NightFurySL2001 closed 1 year ago
Are you sure that the fontBuilder font has a valid Panose entry?
I think so? At least saving the font with fontBuilder directly (fb.save("test.otf")
) does not raise any errors.
https://github.com/fonttools/fonttools/blob/3235454fcd720f270e18ddf00b058df83da63547/Lib/fontTools/fontBuilder.py#L266
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.
@anthrotype thank you! Closing this.
fontTools provide a method to build a whole font from scratch using fontBuilder: https://github.com/fonttools/fonttools/blob/main/Lib/fontTools/fontBuilder.py . It is quite helpful in making a new font from scratch.
However, running the minimal reproduce code below raises an error:
Error: