Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

userData not cloned when node is cloned #1006

Open
simoncozens opened this issue May 20, 2024 · 5 comments
Open

userData not cloned when node is cloned #1006

simoncozens opened this issue May 20, 2024 · 5 comments

Comments

@simoncozens
Copy link
Collaborator

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})
@anthrotype
Copy link
Member

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

@simoncozens
Copy link
Collaborator Author

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

@simoncozens
Copy link
Collaborator Author

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...

@simoncozens
Copy link
Collaborator Author

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...

@simoncozens
Copy link
Collaborator Author

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]: ()

@simoncozens simoncozens changed the title Dictionary collapsed when reading node userData userData not cloned when node is cloned May 20, 2024
schriftgestalt added a commit that referenced this issue May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants