Rainer kept joking “im not much of a coder”… and often I feel like that atleast when it comes to unfamiliar territory of python scripting. However I continued working on a font and soon ran into a repetitive workflow that i figured I could solve with a macro. I gave it a shot and have a result pretty much as I wanted, expect for a small but important detail.
What I am missing is another subtractor within the variable “offsetExit”.
That would be the vertical stem weight that would be defined in the corresponding master.
As the exit must compensate by that amount.
I couldnt figure out how to access that.
Can anyone point me in the right direction?
Heres my macro
font = Glyphs.font
# get active layer
layer = font.selectedLayers[0]
# get glyph of this layer
glyph = layer.parent
print "Inserting entry and exit anchors in:"
# access all layers of this glyph
for layer in glyph.layers:
name = layer.name
print name
thisLayer = font.selectedLayers[0]
thisGlyph = thisLayer.parent
thisGlyph.beginUndo()
#define coordinates
offsetEntry = layer.LSB
offsetExit = layer.width - layer.RSB
# add entry anchor
layer.anchors['#entry'] = GSAnchor()
layer.anchors['#entry'].position = NSPoint(offsetEntry, 0)
# add exit anchor
layer.anchors['#exit'] = GSAnchor()
layer.anchors['#exit'].position = NSPoint(offsetExit, 0)
thisGlyph.endUndo()
yea i understand where the values are stored,
what i dont understand is the chain from the for loop of layer to get to the corresponding masters stem.
first master isnt helping in this case because the macro will iterate through all master layers.
how do u determing which master is the corresponding one?
i tried using masterID for this somehow but to no avail