googlefonts/glyphsLib

userData not cloned when node is cloned

simoncozens opened this issue · 5 comments

test-userdata.zip contains a Glyphs file with a node like this:

(1310,800,c,{
co.uk.corvelsoftware.Dotter = {
forced = 1;
};
})

Except when read with glyphsLib:

font = load("test.glyphs")
print(font.glyphs["G"].layers[0].paths[0].nodes[15].userData)

I get this:

({'forced': 1})

so the outer dict with "co.uk.corvelsoftware.Dotter" key that contains the {'forced': 1} as its item is gone?

Exactly. I'll take a look as to why.

Actually it might just be a repr problem with the UserDataProxy, and something else is wrong in my code; the dictionary is correct in _userData...

Urgh, OK, it is a repr problem, the dictionary is fine and there was an issue somewhere else in my code which this did not help me to debug...

OK, so the actual issue is userData is not copied when a node is cloned:

In [5]: layer.shapes[0].nodes[15].userData
Out[5]: ({'forced': 1})

In [6]: layer.shapes[0].nodes[15].clone().userData
Out[6]: ()