Opening font via a script raises traceback

So I want to perform some operations on a font, then revert the entire font and reopen. I have a short script that seems to do what I want…

font = Glyphs.font
myPath = font.filepath
font = Glyphs.font
#Do more stuff…

However, even though the font opens correctly in the viewer, I am getting a traceback…

Traceback (most recent call last):
File “”, line 34, in
File “/Users/georg/Programmierung/Glyphs/Glyphs/Glyphs/Scripts/”, line 291, in OpenFont
AttributeError: ‘tuple’ object has no attribute ‘font’

and the “more stuff” doesn’t happen, apparently because the font object can’t be read or manipulated further after that traceback.

Fixed it. For now, use plain Cocoa:

URL = NSURL.fileURLWithPath_(Path)
Doc = NSDocumentController.sharedDocumentController().openDocumentWithContentsOfURL_display_error_(URL, showInterface, None)[0]
if Doc is not None:
	print Doc.font

Hmm. The Cocoa method produces a different traceback… Forgive the single quotes below. I couldn’t figure out how to get the < and > to show up without adding them.

Traceback (most recent call last):
File “<‘string’>”, line 8, in <‘module’>
NameError: name ‘showInterface’ is not defined

This is a argument variable. Add showInterface = YES before the second line.

Success! Thanks Georg. Have a great weekend.

I just uploaded a new version that fixes the problem.

1 Like