I am trying to write a script (based on one of Rainer’s scripts) that will change the nice names of the selected glyphs to production names.
I have tried both:
Font = Glyphs.font
selectedGlyphs = [ x.parent for x in Font.selectedLayers ]
Font.disableUpdateInterface()
for thisGlyph in selectedGlyphs:
thisGlyph.name = thisGlyph.productionName
Font.enableUpdateInterface()
And also:
Font = Glyphs.font
selectedGlyphs = [ x.parent for x in Font.selectedLayers ]
def ProductionGlyphName( thisGlyph ):
oldName = thisGlyph.name
newName = thisGlyph.productionName
if oldName != newName:
thisGlyph.name = newName
print "%s --> %s" % (oldName, newName)
else:
thisGlyph.name = oldName
print "%s: unchanged"
Font.disableUpdateInterface()
for thisGlyph in selectedGlyphs:
ProductionGlyphName( thisGlyph )
Font.enableUpdateInterface()
Both are not working. I actually need the script to work on 2.5 (1131). Any ideas?
Yes, custom naming is activated.
I found a workaround for what I wanted to do but I would still like to know why the script is not working.
If a glyph has a nice name that is different from the production name then the script works. But if the nice name and production name are the same then it deletes the name and leaves it empty and then Glyphs crashes.
You are simply taking productionName and filling it into name. But productionName can be None. So you have to check first with a line like if productionName: before you set the name.