Shortcut for symmetries

Shortcuts for vertical and horizontal symmetries (from the transformation panel) would be very handy!

You can make that yourself with this script.

#MenuTitle: Align Center
# -*- coding: utf-8 -*-
__doc__="""
Align Center.
"""

GSLeft = 0
GSVCenter = 1
GSRight = 2
GSTop = 3
GSHCenter = 4
GSBottom = 5

align = GSVCenter

transform = NSClassFromString("GlyphsPaletteTransform").new()
transform.setWindowController_(Font.parent.windowController())
transform.alignSelection_(align)

Put that in a script in the Script folder and give it a shortcut. You need to change the line align = GSVCenter and the title in the first line to whatever you like the script to do.

Thank you Georg, but I don’t understand what I should change it with so it would perform mirroring functions instead of aligning functions.
I cannot find it in the doc neither: https://docu.glyphsapp.com/genindex.html

This is not documented.

One trick is to run

transform = NSClassFromString("GlyphsPaletteTransform").new()
print "\n".join(dir(transform))

It prints a lot stuff, but it contains everything that this object can do. And sometimes, you can find the needle in all that hay. But in this case, you would be out of luck.

Here is the code:

from AppKit import NSButton
transform = NSClassFromString("GlyphsPaletteTransform").new()
transform.setWindowController_(Font.parent.windowController())
dummy = NSButton.new()
dummy.setTitle_("flipVertical")
#dummy.setTitle_("flipHorizontal")
transform.transform_(dummy)
1 Like

Any idea why the flip is not centered even though the center is selected as origin?
Pressing the button from the panel does what expected, but the script gives a different result: the flip happens on the bottom or left part of the glyph.

I see.

replace this two lines

transform = NSClassFromString("GlyphsPaletteTransform").new()
transform.setWindowController_(Font.parent.windowController())

with those:

palettes = Font.parent.windowController().valueForKey_("paletteInstances")
for palette in palettes:
	if palette.__class__.__name__ == "GlyphsPaletteTransform":
		transform = palette
3 Likes

Nice, thank you!

1 Like