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 noticed (with @punchcutter) that kerning.scale() followed by kerning.round() may write floats into the kerning data.
These floats are all .0, so there’s no data problem – still, wondering about the “why”.
In the attached project, all kerning values are integers. After doing this, all values are converted to floats:
fromfontParts.worldimportRFontimportsysf=RFont(sys.argv[-1])
original_kerning=f.kerning.copy()
forkey, valueinf.kerning.items():
ifisinstance(value, float):
# in the attached project, all kerning pairs are intprint('hey, float!', key, value)
f.kerning.scaleBy(2)
f.kerning.round()
forkeyinoriginal_kerning.keys():
value_original=original_kerning[key]
value_scaled=f.kerning[key]
ifisinstance(value_scaled, float):
print(key)
print(value_original, value_scaled)
print()
Would it be reasonable to check for the type of the value there?
Or, perhaps kerning.round() should just completely replace the whole kerning object instead of re-writing pairs one-by-one?
I have noticed (with @punchcutter) that
kerning.scale()
followed bykerning.round()
may write floats into the kerning data.These floats are all
.0
, so there’s no data problem – still, wondering about the “why”.In the attached project, all kerning values are integers. After doing this, all values are converted to floats:
output is
When changing the scale factor to 2.2, only a few pairs (the ones ending up as .0) become floats, the remaining pairs are rounded to int:
I have double-checked https://github.com/robotools/fontParts/blob/master/Lib/fontParts/base/kerning.py#L93-L115, as well as https://github.com/robotools/fontParts/blob/master/Lib/fontParts/base/normalizers.py#L1094-L1108 – it’s impossible for these to return a float.
normalizers.normalizeKerningValue
should just pass the value through – I wonder if there’s some comparison happening while setting the values (which would return True for10.0 == 10
)?kerning_example.ufo.zip
The text was updated successfully, but these errors were encountered: