googlefonts / fontc

Where in we pursue oxidizing (context: https://github.com/googlefonts/oxidize) fontmake.
Apache License 2.0
85 stars 14 forks source link

fix parsing widthClass from glyphs2 instances #1005

Closed anthrotype closed 1 month ago

anthrotype commented 1 month ago

we were only testing parsing instance widthClass for glyphs3 sources, where this property already holds a number 1..9 for glyphs2 this is an enumerated string that maps to numbers from 1 to 9.

lookup_class_value is incorrectly mapping the widthClass to numbers from 50 to 200 (i.e. using the corresponding percentages instead of the enumerated integer values)

https://github.com/googlefonts/fontc/blob/4a4019c66902e9ce68c7b98403a734b94a88eaf2/glyphs-reader/src/font.rs#L1971-L1980

... but then the WidthClass::try_from fails because only numbers 1 to 9 are supported:

https://github.com/googlefonts/fontc/blob/4a4019c66902e9ce68c7b98403a734b94a88eaf2/fontdrasil/src/types.rs#L110-L134

I first push a failing test case (simply duplicating an existing test for glyphs3/WdthVar.glyphs, coverted to glyphs2 using the Glyphs.app), then will follow up with the actual fix.