Hi, all my glyphs show a layer (which has content) but whose name is entirely empty. I never created this layer and it seems to contain some older version of a previous layer. Any idea what this is? If I print(layer.name)
then I get “orphan”.
Also, I can’t find out how to bulk-delete it with a script. del(thisGlyph.layer[1])
empties the second master layer, not the actual second layer in the layers panel.
Print the list of layer to understand the structure.
Okay, I tried del(thisGlyph.layers[-1]). First, that doesn’t work (the layer stays filled), but the layer doesn’t disappear from the layer list. If I try by absolute index (2), then I get an index out of range error. The layer just doesn’t exist, somehow.
it is better to iterate the layers to find the one you like to remove and then use the layerId
to delete it.
delLayer = None
for l in g.layers:
if len(l.name) == 0:
delLayer = l
break
if delLayer is not None:
del(g.layers[delLayer.layerId])
I’m afraid that didn’t work, either (I substituted “g” by “thisGlyph”, correct?). I don’t get an error message and the empty layer is still there.
Upon further blind button mashing I have found that the empty layer doesn’t have a layerId.
No. In this case: Layer.parent.layers
thisGlyph
is not set by Glyphs so that is a from a previous script, and not the current glyph.
Thanks a lot. This worked:
for g in Font.glyphs:
delLayer = None
for l in g.layers:
if l.name == None:
delLayer = l
break
if delLayer:
del(g.layers[delLayer.layerId])
Still no idea how this happened, would be very curious to find out. Thanks a lot for your help!
I suspect the layers are produced by some script or plugin.