Hi, would love a bit of advice with my first ever script, which is supposed to rescale all the graphics for selected layers and change the dimensions.
Font.disableUpdateInterface()
newWidth = 600
for thisLayer in selectedLayers:
thisMaster = thisLayer.master
layer = Glyphs.font.selectedLayers[0]
scaleFactor = newWidth/layer.width
newLSB = thisLayer.LSB * scaleFactor
newRSB = thisLayer.RSB * scaleFactor
# shift
shift = (thisLayer.LSB - thisLayer.RSB ) * -0.5
shiftMatrix = transform(shiftX=shift).transformStruct()
thisLayer.applyTransform( shiftMatrix )
# scale
scaleMatrix = transform(scale=scaleFactor).transformStruct()
thisLayer.applyTransform( scaleMatrix )
# change metrics
thisLayer.LSB = newLSB
thisLayer.RSB = newRSB
thisLayer.width = newWidth
Font.enableUpdateInterface()
It works great if you run it once, on a single glyph. But if you run it on two or more, it doesn’t do the second and subsequent ones correctly. I can’t see what it’s carrying over from the first to the next…? Thanks if you can help!