-
Notifications
You must be signed in to change notification settings - Fork 475
Float yMin value: required argument is not an integer #1604
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
Comments
The question is where rounding should be applied. If I look at the code in fonttools itself that usually provides these values, I see that rounding is done by the caller. In your case, which code was responsible for calculating the font bounding box? |
Good question! In our case the data is read from a font file I believe. It goes something like: from fontTools.ttLib import TTFont
font = TTFont(path)
# Here some naming table data is adjusted, nothing to do with bounding box...
font.save(path) This works on most of our files. Only a few have the To answer your question:
I believe it's |
Hm, since the code that I looked at does do proper rounding, it's a bit of a mystery. Can you provide exact steps to reproduce? |
Yes, luckily I have a test version of the failing font (with a testing licence and limited character set) that reproduces the issue. To reproduce with the above linked file:
|
Thanks, can reproduce. The issue is that the CFF FontBBox contains float values:
And those values are used to populate the head table upon compile. I don't think it is illegal for FontBBox to contain floats, so we indeed need to do some rounding. Probably here:
|
Thanks for confirming. And yes, I was looking at that very line you linked—seems like an appropriate place. |
One question, which I don't have the knowledge to answer, is whether numbers should be rounded here; or otherwise further carried through as floats all the way downstream. |
We need to round because head table can only contain integers for the font bounding box values, unlike the CFF FontBBox. |
Sure! On it. |
If a font file has a float value in
yMin
—and I assume equally inxMin
,xMax
oryMax
—it will fail to save with the errorrequired argument is not an integer
(fontTools/misc/sstruct.py in pack at line 75
, fonttools v3.40.0).Trace:
Variables at point of error:
As you can see the value
-170.009
would trigger the error. If integers are expected then rounding should probably be applied.The text was updated successfully, but these errors were encountered: