-
Notifications
You must be signed in to change notification settings - Fork 475
Add varLib.hvar
module
#3780
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
Add varLib.hvar
module
#3780
Conversation
Lib/fontTools/varLib/hvar.py
Outdated
storeBuilder.setSupports(supports) | ||
advMapping[glyphName] = storeBuilder.storeDeltas(deltas, round=noRound) | ||
|
||
singleModel = all(advMapping[g] >> 16 == 0 for g in glyphOrder) |
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.
shouldn't this check that all the supports are the same (like we do in the varLib _get_advance_metrics)?
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.
That's one way. My reasoning here was that if the OnlineVarStoreBuilder put them all in the same group (ie. all major's match), then we can do this. I'll try to revert to other logic.
Lib/fontTools/varLib/hvar.py
Outdated
phantoms[1] = phantoms[1][phantomIndex] if phantoms[1] is not None else 0 | ||
deltas.append(phantoms[1] - phantoms[0]) | ||
|
||
allDeltas[glyphName] = deltas[1:] |
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 skip the first one? an inline comment might help the reader
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.
First "delta" is the actual advance itself.
Lib/fontTools/varLib/hvar.py
Outdated
directStore = None | ||
if singleModel: | ||
# Build direct mapping | ||
supports = supports[1:] |
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.
same as above (probably related) why skip the first?
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.
Ah. I think I messed up both of these. I'll fix. I used to have {} as first item, but I think I removed it.
I wish we could reuse more of the code that's already in |
Me too. I'll work on it. |
I addressed reviews. One thing occurs to me that in a post-64k world, we should be more careful building the direct mapping since not all will fit in a VarData. I'll see about more code sharing. And needs some kinds of tests. |
I haven't found a font yet that this fully roundtrips to the same XML... |
We changed the sort algorithm a bit. Maybe it's that. |
Oh it's probably because we don't go through the VariationModel, just directly to deltas. Anyway, I've convinced myself that the code is correct. Now onto refactoring. |
Refactoring done. PTAL. |
VORG is not done in this module. VVAR is done but untested. |
maybe because we end up ordering the VarRegions differently in the VarRegionList?
yes, ideally |
I built a fresh NotoSansArabic, and HVAR roundtrips perfectly. |
577b8e4
to
65a8974
Compare
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.
LGTM!
Fixes #3778
Mildly tested. In particular, on RobotoFlex VF, it produces smaller HVAR table. I have not investigated. The code is heavily lifted from
varLib.__init__
.