I recently tried duplicating a master via Python: new_master = fontObj.masters[0].copy() (edit: wrong code)
Then I noticed that the layers linked to this new master are the same layers as those linked to the original master. Any change to the copied layer affects the original.
Is there any way for the .copy() method to create independent copies of the linked layers?
At least you need to assign a new master id. At best you go though all glyphs a duplicate the layers and add them with the new id. There are helper methods to do those things. I can look is up if needed.
I tried again and I think I can only do it like this: make new GSFontMaster, copy all its properties from the one I wanted to copy, then loop through all glyphs and copy all layer properties i need from glyph.layers[layer_to_copy_id] to glyph.layers[new_font_master_id].
But I think I still would be interested in those helper methods. Are they somewhere among the methods I can get with print(dir(GSFontMaster))? I could not find one there.
Thanks, I did try deepcopy but it does not solve the problem on its own. It does copy the master but with an identical ID, and the new layers are the same objects linked to the original master.