Transform Script

I had this function to only skew anchors and paths, but I’d like to use it now just for simply x, y transformation (I use this when I am applying a font wide spacing change, and then instead of manually adjusting the component+path glyphs, I’d like to reverse shift the path and anchors):

	def slantLayers(self, selectedLayers, skewAngle):

		xHeight = selectedLayers[0].associatedFontMaster().xHeight
		transform = NSAffineTransform.new()
		slant = math.tan(skewAngle * math.pi / 180.0)
		transform.shearXBy_atCenter_(slant, -xHeight / 2.0)

		Font.disableUpdateInterface()		
		for layer in selectedLayers:
			for path in layer.paths:
				for node in path.nodes:
					node.position = transform.transformPoint_(node.position)
			for anchor in layer.anchors:
				anchor.position = transform.transformPoint_(anchor.position)
		Font.enableUpdateInterface()

What’s the transform function that would let me simply transform x, y?

OK it seems I got the answer in an old post already haha


its Transform.translateXBy_yBy_(200, 0)

Are you using TextMate or SublimeText? What you may like is the Python for Glyphs repository. There is a snippet called transform which gives you a transform(shiftX, shiftY, rotate, skew, scale) method.