All layers must also include all Brace and Bracket layers. Here is one that just puts one in all layers it can find.
thisFont = Glyphs.font
# iterate through all layers of all selected glyphs:
for thisGlyph in [l.parent for l in thisFont.selectedLayers]:
for thisLayer in thisGlyph.layers:
# check if bottom anchor is missing:
if not thisLayer.anchorForName_("bottom"):
# add anchor:
bottomAnchor = GSAnchor.alloc().init()
bottomAnchor.name = "bottom"
thisLayer.addAnchor_(bottomAnchor)
# set its position:
halfWidth = thisLayer.width * 0.5
halfWidthOnTheBaseline = NSPoint( halfWidth, 0.0 )
bottomAnchor.setPosition_( halfWidthOnTheBaseline )
It doesn’t do anything if the bottom anchor already exists on that layer.
There is a workshop coming up in Frankfurt, probably early next year.
And there is a three-part introductory tutorial in the Tutorials section. That one is pretty easy and known to have gotten a bunch of type designers started in Python. Just to whet your appetite.
@mekkablue If it’s not too complicated, would you be able to give an example of how to set an anchor at a particular position in a particular master? E.g. x, y coordinates in the regular master?
Thanks, Georg. I should get to the layer first, right, before trying to add an anchor?
What I’m hoping to do is to select a bunch of marks of a particular type and add identical anchors to all of them, at set coordinates in each master. I’ll see how this goes.