Skip to content
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

Open
roberto-arista opened this issue Nov 13, 2024 · 4 comments

Comments

@roberto-arista
Copy link

Consider the following code

import pprint

from fontTools.pens.recordingPen import RecordingPen
from glyphsLib import GSFont

if __name__ == "__main__":
    gs_font = GSFont("example.glyphs")
    layer = gs_font.glyphs["bitcoin"].layers[0]
    recording_pen = RecordingPen()
    layer.draw(recording_pen)
    pprint.pp(recording_pen.value)

When running the code from the main branch, the output is:

[('moveTo', ((249, 650),)),
 ('lineTo', ((297, 650),)),
 ('lineTo', ((324, 800),)),
 ('lineTo', ((276, 800),)),
 ('closePath', ()),
 ('moveTo', ((364, 650),)),
 ('lineTo', ((412, 650),)),
 ('lineTo', ((439, 800),)),
 ('lineTo', ((391, 800),)),
 ('closePath', ()),
 ('moveTo', ((115, -110),)),
 ('lineTo', ((163, -110),)),
 ('lineTo', ((191, 50),)),
 ('lineTo', ((143, 50),)),
 ('closePath', ()),
 ('moveTo', ((230, -110),)),
 ('lineTo', ((278, -110),)),
 ('lineTo', ((307, 50),)),
 ('lineTo', ((259, 50),)),
 ('closePath', ()),
 ('addComponent', ('B', <affine transformation 1 0 0.0 0.94 5 21>))]

Instead, when running the code from Glyphs3-merge, the output is:

[('moveTo', ((249, 650),)),
 ('lineTo', ((297, 650),)),
 ('lineTo', ((324, 800),)),
 ('lineTo', ((276, 800),)),
 ('closePath', ()),
 ('moveTo', ((364, 650),)),
 ('lineTo', ((412, 650),)),
 ('lineTo', ((439, 800),)),
 ('lineTo', ((391, 800),)),
 ('closePath', ()),
 ('moveTo', ((115, -110),)),
 ('lineTo', ((163, -110),)),
 ('lineTo', ((191, 50),)),
 ('lineTo', ((143, 50),)),
 ('closePath', ()),
 ('moveTo', ((230, -110),)),
 ('lineTo', ((278, -110),)),
 ('lineTo', ((307, 50),)),
 ('lineTo', ((259, 50),)),
 ('closePath', ()),
 ('addComponent',
  ('B', <affine transformation 1.0 0.0 -0.8422883804630793 0.94 5.0 21.0>))]

Attached you can find the .glyphs file.

example.glyphs.zip

cc @schriftgestalt

@schriftgestalt
Copy link
Collaborator

As fare as I can see, both transforms are not correct. In the .glyphs source is this:

{
pos = (5,21);
ref = B;
scale = (1,0.94);
slant = (-0.7,0);
}

transfrom from main:

1 0 0.0 0.94 5 21

and from Glyphs3 branch:

1 0 -0.8422883804630793 0.94 5 21

and from Glyphs 3.app

1 0 -0.011484837902484654 0.94 5 21

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.

@roberto-arista
Copy link
Author

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.

@schriftgestalt
Copy link
Collaborator

the type cast is still relevant. Remove the change with the active property.

@roberto-arista
Copy link
Author

done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants