How do you get acces to the glyph.lib?

Anybody knows how I can get to the data inside the glyph.lib?

from robofab.world import *
f = CurrentFont()

for glyph in f:
    print glyph.lib

Have you read those?
http://robofab.com/objects/lib.html
http://robofab.com/howto/usethelib.html

Yes I did, but that didn’t work; I get the following error:

Error in File ~/Library/Application Support/Glyphs/Scripts/objectsGS.py

line 676, in get_lib
return self.object.userData.objectForKey(“org.robofab.ufoLib”)
AttributeError: ‘objc.native_selector’ object has no attribute 'objectForKey
’

The implementation of the RoboFab wrapper and the saving and loading .ufos was not complete. I fixed both.

For now, you can use the Glyphs Python API:

Font = Glyphs.currentDocument.font
Glyph = Font.glyphs["B"]
if Glyph.userData() == None:
	Glyph.setUserData_({})
Glyph.userData()["Test"] = "!!!!!!"
print Glyph.userData()["Test"]
1 Like

Hi Georg,

Thanks for your reply, did you test the script above? It does not save anything to glyph.lib or anywhere in the font as it is only valid in session.

I was not clear about what I wanted but I need to read existing data from Glyph.lib