Trying to add kerning to this script https://github.com/mekkablue/Glyphs-Scripts/blob/master/Components/Align%20All%20Components.py and I need to be able to enumerate and get the next component but I can’t do that? Any ideas?
def process( thisGlyph ):
numberOfLayers = len( thisGlyph.layers )
for i in range( numberOfLayers )[::-1]:
thisLayer = thisGlyph.layers[i]
thisFontMasterID = thisLayer.associatedFontMaster().id
if thisLayer.layerId == thisFontMasterID:
advance = 0.0
allComponents = thisLayer.components
for i, thisComponent in enumerate(allComponents):
thisKerningPair = 0
if i>0:
previousComponent = thisLayer.components[i-1]
thisKerningPair = Font.kerningForPair(thisFontMasterID, previousComponent, thisComponent)
thisComponent.position = NSPoint( advance, 0.0 )
advance += thisComponent.component.layers[thisFontMasterID].width + thisKerningPair
thisLayer.width = advance