Nice names to productions names


#1

Hey guys,

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?


#2

have you set the “Use Custom Naming” in Font Info?

And why do you need to do that?


#3

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.

  • Sorry, I made a mistake before.

#4

Check first if there is a production name at all. Because if it does not have a production name, production name will be None.


#5

But do you have any ideas why the scripts are not working?


#6

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.


#7

Cool. Thanks