I could copy the SmartComponentPoleMapping setting from layer to layer on the same file, however could not copy as a new glyph of an other file. The settings are not applied on the Glyph’s ‘Show Smart Glyph Settings’ dialog. How can I do that?
sourceFont = Glyphs.fonts[ indexOfSourceFont ]
sourceGlyph = sourceFont.glyphs[ thisGlyphName ]
sourcelayer = sourceGlyph.layers[ indexOfSourceMaster ]
targetFont = Glyphs.fonts[ indexOfTargetFont ]
newGlyph = GSGlyph(thisGlyphName)
for theaxis in sourceGlyph.smartComponentAxes :
cpaxis = GSSmartComponentAxis()
cpaxis.setName_(theaxis.name)
cpaxis.topValue = theaxis.topValue
cpaxis.bottomValue = theaxis.bottomValue
newGlyph.smartComponentAxes.append(cpaxis)
targetFont.glyphs.append(newGlyph)
for slayer in sourceGlyph.layers :
newLayer = GSLayer(slayer.name)
### Loop copy for paths and anchors
mapping_str = str(slayer.smartComponentPoleMapping)
mapping = dict([(i.split("=")[0], int(i.split("=")[1])) for i in re.sub(r'[\{\}\s\"\n]+', "", mapping_str).split(";") if "=" in i])
for a in mapping.keys():
newLayer.smartComponentPoleMapping[a] = slayer.smartComponentPoleMapping[a]
targetGlyph.layers.append(newLayer)