Can't skew with Glyphs.drawingTools

from GlyphsApp.drawingTools import skew
skew(0.1)

Traceback (most recent call last):
File "Macro 2.py", line 3
skew(0.1)
~~~~^^^^^
File "/GlyphsApp/drawingTools.py", line 242, in skew
Transform.shearXBy_yBy_(a, b)
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NSAffineTransform' object has no attribute 'shearXBy_yBy_'. Did you mean: 'scaleXBy_yBy_'?

Maybe a bug. I try that with success on : Glyphs 4.1.1 (4108)


from AppKit import NSAffineTransform

def skew(a, b=None):
    if b is None:
        b = a
    transform = NSAffineTransform.alloc().init()
    transform.setTransformStruct_((1, b, a, 1, 0, 0))
    transform.concat()

I have used the Glyphs MCP server in coding mode to find it.
I hope that helps.

Thanks. There also is

NSAffineTransform.shearXBy_yBy_atCenter_()

… which is not listed in Apple’s documentation, but does what I need. It may be deprecated?

NSAffineTransform.shearXBy_yBy_atCenter_ is added by Glyphs to the NSAffineTransform API.

1 Like