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
[VARC] Variable Composites table #3395
base: main
Are you sure you want to change the base?
Conversation
fb660e6
to
ca824db
Compare
This is mostly steady now. I'll go ahead and write a spec for it. What is left to do is:
|
I should also somehow figure out how to do the |
TODO:
|
I can use some directions here. The It will be more pronounced when adding subsetting to |
I managed to share some code by monkey-patching for now. |
87dc659
to
c8a8b47
Compare
This is ready for review. Thanks in advance @anthrotype @justvanrossum |
It's terse but here's something of a spec for this: |
I probably should move some of the new code from |
8e75d94
to
2e057ba
Compare
No functional change.
Since we modify comp.transform.
From the spec: "Offsets in the offset array are relative to the byte that precedes the object data."
Now can render fonts generated with this fonttools branch. |
45e579e
to
b7e8ac6
Compare
This is ready. Has tests too. |
@@ -22,6 +22,8 @@ | |||
|
|||
DELTAS_ARE_ZERO = 0x80 | |||
DELTAS_ARE_WORDS = 0x40 | |||
DELTAS_ARE_LONGS = 0xC0 |
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.
de/compiling TupleVariation with this new DELTAS_ARE_LONGS
flag doesn't seem to be covered by tests
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.
You caught me!
I'll see if I can make one.
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.
You caught me!
codecov did! :)
Suggest to apply this patch to make a var composite referencing its own GID work correctly with the pen protocol: diff --git a/Lib/fontTools/ttLib/ttGlyphSet.py b/Lib/fontTools/ttLib/ttGlyphSet.py
index 8b276aa37..5d373cfb9 100644
--- a/Lib/fontTools/ttLib/ttGlyphSet.py
+++ b/Lib/fontTools/ttLib/ttGlyphSet.py
@@ -344,11 +344,17 @@ class _TTGlyphVARC(_TTGlyph):
reset = comp.flags & VarComponentFlags.RESET_UNSPECIFIED_AXES
with self.glyphSet.glyphSet.pushLocation(location, reset):
with self.glyphSet.pushLocation(location, reset):
- try:
- pen.addVarComponent(
- comp.glyphName, transform, self.glyphSet.rawLocation
- )
- except AttributeError:
+ shouldDecompose = self.name == comp.glyphName
+
+ if not shouldDecompose:
+ try:
+ pen.addVarComponent(
+ comp.glyphName, transform, self.glyphSet.rawLocation
+ )
+ except AttributeError:
+ shouldDecompose = True
+
+ if shouldDecompose:
t = transform.toTransform()
compGlyphSet = (
self.glyphSet Without this, it will emit a self-referencing component which (as far as I can see) can't be resolved in another way. @behdad, I can't find a reference to the prescribed behavior in the proposal doc. Others: what was new to me is that a VARC Composite may reference its own GID, which will then bypass VARC and go straight to glyf or CFF2. This is a handy way to mix outlines and (variable) components. |
@justvanrossum Thanks. Can you push that change to the branch?
Here: The component then is recursively loaded from the VARC table, if it is present in this table; otherwise, falls back to glyf/gvar, CFF2, or any other mechanism to get raw outlines. An exception to the recursive rule is that if a component refers to the glyphID of the current glyph, instead of recursing (which would result in infinite recursion), the glyph outline for the component is loaded directly instead, as if the glyphID had no VARC entry. |
With more Condition formats. harfbuzz/boring-expansion-spec@df7dcc4 harfbuzz/boring-expansion-spec#147
Will do, thanks! |
…lyph (special case)
Shift other Condition format numbers. Implements https://github.com/adobe-type-tools/opentype-spec-drafts/blob/main/condvalue_spec.md
That's what we agreed upon.
Based on harfbuzz/boring-expansion-spec#103 (comment)