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
[designspace] Add avar2 mapping support #3123
Conversation
cc @justvanrossum Opening this such that we can work on it together. |
044054a
to
522b22d
Compare
I updated this to actually build an avar2 table, and successfully built one. |
Is this based on my proposed |
Yes. Just using |
Are you dealing with supporting masters, thus only calculating duovar deltas after calculating supporting monovar deltas etc? |
It's a full VariationModel solver. |
Based on this experiment, I suggest this way forward:
I think this makes most sense. I've willing to hear alternatives. |
That sounds like an excellent refinement. Can you confirm your avar2 builder is happy crossing 0? (If specified absolutely, such a delta must be worked out in two steps.) |
It looks like it's happy to. In fact, the varLib modeler requires a region at 0. |
I am not so familiar with the implemention, and was curious about the name of this variable; I pinged Behdad to ask, what is the x in xvalue, and he kindly explained,
|
Recall that there are valid concerns from @anthrotype @justvanrossum @belluzj about the terminology in the spec, so we should not regard it as firm. In particular I’m happy to avoid use of "xvalue". See #3049. |
"xvalue" is there to record anisotropic locations. This is perhaps not very useful for variable font but it is where this specification started and it is still used during design. As long as anisotropy remains possible I'm fine with any other name. |
This makes it ugly to represent in the code. Currently how it works, is that if an axis is only specified in output, then it will work as a delta from the axis's default value. Maybe we just document it that way and go home? @Lorp |
@Lorp Can you work on a patch to the designspace spec? |
@Lorp Instead of |
What's what I'm using in the |
Sounds good. We don’t talk about regions anywhere else in designspace. I’m mostly away for the weekend, but will do it soon. |
Should the dimension element have axis name instead of tag? |
@anthrotype Thanks for the review. I think I addressed them all. |
@khaledhosny Is this something you can use in your font to build the avar2 table? |
This comment was marked as outdated.
This comment was marked as outdated.
Probably. I create a DS in code and pass it to varLib, so I can add the mapping there. |
But I don’t understand these warnings, what am I doing wrong?
|
This fixes the warnings: diff --git a/scripts/build.py b/scripts/build.py
index 8d19a4a..63d4531 100644
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -726,11 +726,11 @@ def build(font, instance, args):
ds.addSource(source)
inputs = [
- {"Justification": 0},
- {"Justification": 90},
- {"Justification": 100},
- {"Justification": -50},
- {"Justification": -100},
+ {"Justification": 0, "Spacing": 0, "Mashq": 10},
+ {"Justification": 90, "Spacing": 0, "Mashq": 10},
+ {"Justification": 100, "Spacing": 0, "Mashq": 10},
+ {"Justification": -50, "Spacing": 0, "Mashq": 10},
+ {"Justification": -100, "Spacing": 0, "Mashq": 10},
]
outputs = [ But it feels redundant. Now I need to remember to update these if I ever change the default location of any of the axes. |
Also I’m seeing this ttx diff compared to my code: <avar>
<version major="2" minor="0"/>
<segment axis="SPAC">
+ <mapping from="-1.0" to="-1.0"/>
+ <mapping from="0.0" to="0.0"/>
+ <mapping from="1.0" to="1.0"/>
</segment>
<segment axis="MSHQ">
+ <mapping from="-1.0" to="-1.0"/>
+ <mapping from="0.0" to="0.0"/>
+ <mapping from="1.0" to="1.0"/>
</segment>
<segment axis="jstf">
+ <mapping from="-1.0" to="-1.0"/>
+ <mapping from="0.0" to="0.0"/>
+ <mapping from="1.0" to="1.0"/>
</segment> Probably harmless but also redundant. |
Make the |
Yeah it's one of the issues we've been discussing. Currently we warn if a non-hidden output axis is not specified. |
But I want it the other way around, |
Interesting. Yeah I think we might want to nuke that warning then. |
Yes, let's get rid of the warning. But since leaving out the input value and putting it at the default value should behave the same way, I am also surprised at the ttx diff. |
Sorry of I didn't make this clear, the ttx diff is not related to this issue but when generating avar with varLib in general (I’m comparing with the code I was using earlier which left the segments empty). |
Removed warning. Is this good to merge then? |
@behdad what about that diff that Khaled noticed? |
That's because of this pre-existing code block: fonttools/Lib/fontTools/varLib/__init__.py Lines 149 to 156 in 84cebca
|
Are we all happy to merge this? We can start making avar2 fonts and come back fix things as needed |
@behdad hm that commit you quoted is quite old, from 2017
@khaledhosny does that mean you had not rebuilt your fonts since 2017? |
I wasn’t using DS to generate avar table. |
This just uses list of list of dictionaries. Should use proper objects.
#3049