-
Notifications
You must be signed in to change notification settings - Fork 51
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
Issue with skew attribute in component transform in Glyphs3-merge
branch
#1047
Comments
As fare as I can see, both transforms are not correct. In the .glyphs source is this:
transfrom from main:
and from Glyphs3 branch:
and from Glyphs 3.app
from what I can tell, the version from Glyphs.app seem to be correct. The calculation of the transform from scale, rotation and slant was done in a different order than in Glyphs.app (and the skew needed to be converted to radians). I fixed that. Thanks for the test case. |
Hey Georg, thanks for the fix. I cannot see the code on remote, let me know when you'll push it (and on which branch) so I can test it on my end. |
the type cast is still relevant. Remove the change with the |
done! |
hey @schriftgestalt, could you push your fix online if it's ready? thanks! |
my changes are all pushed |
thanks! |
If I understand this correctly the
It's important that this order is well documented, remember that glyphsLib is not the only external implementation now, there's fontc as well. So far we have been trying to match glyphsLib's main branch. |
For reference, this commit on Glyphs3-branch changed the order in which skew is applied: before the combined transform order was: translate * rotate * scale * skew after that patch, it becomes like this: translate * skew * sotate * scale |
hm glyphsLib Is this a relatively new thing in Glyphs, or was it never implemented in glyphsLib? |
Glyphs 2 only had plain transform structs, so no special handling of slant needed. In Glyphs 3, I changed it to store the components separately as it makes it easier to show them in the UI (it very easy to get a transform from the components, but not the other way around). So I added support for rotate, scale and slant in the Glyphs3 branch.
and in Glyphs 3
(if you have code that can decompose the above transform into the same values as shown in the G3 example (or at least something meaningful), I would be very grateful) |
I'm not sure.. The code we have right now can only decompose a 2x2 transformation matrix into scale and rotation components: glyphsLib/Lib/glyphsLib/classes.py Line 265 in 74c6324
By the way, why does the Python Scripting API only mentions position, scale and rotation attributes but not any "slant" or "skew"? |
I just saw that and fixed it. I didn’t upload it, yet. |
Ah I had forgotten we so have something to decompose an affine transform into its components: Just Van Rossum added this to support the proposed VARC table @schriftgestalt does this work for your use case? |
produces this (rounded a bit to make it more readable):
Original: I think it is not even possible. A certain amount of skew is a rotation. And it gets very complicated with uneven scale. But my algorithm is not doing much better with this ;( |
the fonttools DecomposedTransform is derived from this I believe the difference with yours may be down to the order of the operations? In DecomposedTransform.toTransform() (which does the reverse and re-combines the components into the original matrix), ignoring for a moment the tCenterX and tCenterY (which we don't need here), notice how first does: skew, then scale, then rotate and finally translate (chaining operations works backwards, the last one is going to be applied first since the Transform.transform method multiplies matrices self @ other, which can be thought of mapping by other before applying self): Whereas in your case you're doing first scale, then rotate, then skew and finally translate. |
@schriftgestalt by the way, can you even insert a vertical skew (i.e. y-coordinates displaced vertically up/down proportionally to the x-coordinates) in the Glyphs.app UI? I see an icon only for the horizontal skew (the parallelogram tilted to the right): |
The vertical skew can only be added by script. We’ll add it eventually. |
Consider the following code
When running the code from the
main
branch, the output is:Instead, when running the code from
Glyphs3-merge
, the output is:Attached you can find the
.glyphs
file.example.glyphs.zip
cc @schriftgestalt
The text was updated successfully, but these errors were encountered: