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
Var store quantize #3126
Var store quantize #3126
Conversation
Not sure if we want to set quantization higher than one by default in any fontmake-related codepath. |
Lib/fontTools/varLib/varStore.py
Outdated
for regionIdx, v in zip(regionIndices, item): | ||
row[regionIdx] += ( | ||
round(v / quantization) * quantization | ||
) # TODO: round towards 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why "round towards 0"?
you can use decimal.Decimal
's quantize
method with a ROUND_DOWN
rounding method:
https://docs.python.org/3/library/decimal.html#decimal.ROUND_DOWN
though it might be quicker to simply do floor(v) if v > 0 else ceil(v)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove the comment. round is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant was a round that rounds .5 to 0, such that eg. with quantization 2, value 1 will become 0, not 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i think as a size saving optimization this quantization should make the deltas smaller, would be strange if it made them bigger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(though the sharing comes from reuse, not the delta magnitude itself)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I don't know, maybe an option in the public varLib.build/build_many methods that ufo2ft uses. But I'm not sure if one wants to use the same quantization (if at all) for all the VarStores (HVAR, MVAR, COLR, etc.). |
I think it's fine to have this option available in the |
No. I was just inspecting some varstores in GDEFs and saw many similar values. Ie. this is the entirety of the varstore from NotoSansCJK:
|
Sounds good. Thanks. |
No description provided.