Hi,
I noticed that User Data saved to a glyph object becomes inaccessible when the using the UFO file format.
Steps to reproduce:
- Create a new Glyphs file with one master.
- File > Save as UFO.
- Run the below Macro to add user data to the font (1) and to the “A” glyph (2).
Returns:Glyphs.font.userData["TestingFont"] = "Hello, Font" # (1) Glyphs.font.glyphs["A"].userData["TestingGlyph"] = "Hello, Glyph" # (2) print("Font User Data:", Glyphs.font.userData) print("Glyph 'A' User Data:", Glyphs.font.glyphs["A"].userData)
Font User Data: { TestingFont = "Hello, Font"; } Glyph 'A' User Data: { TestingGlyph = "Hello, Glyph"; }
- Save & close the UFO. The
lib.plist
andA_.glif
look like the belowNew Font.ufo/lib.plist ... <key>com.schriftgestaltung.font.userData</key> <dict> <key>TestingFont</key> <string>Hello, Font</string> </dict> ...
New Font.ufo/glyphs/A_.glif <?xml version="1.0" encoding="UTF-8"?> <glyph name="A" format="2"> <advance width="600"/> <unicode hex="0041"/> <outline> </outline> <lib> <dict> <key>TestingGlyph</key> <string>Hello, Glyph</string> <key>com.schriftgestaltung.Glyphs.lastChange</key> <string>2021-08-02 20:01:39 +0000</string> </dict> </lib> </glyph>
- Re-open the UFO in Glyphs.
- Run the below macro to report the User Data
Returns:print("Font User Data:", Glyphs.font.userData) print("Glyph 'A' User Data:", Glyphs.font.glyphs["A"].userData)
Font User Data: { "UFO.lib" = { TestingFont = "Hello, Font"; }; UFOFormat = 3; } Glyph 'A' User Data: None
I would expect the User Data object for Glyph A to look similar to the Font’s User Data object, but instead it returns None
.
Is there any way to read the User Data out of a UFO glyph? This seems like a bug to me.
Thanks!