I made a new master by copying another, in which I (unfortunately) had already done a lot of TT hinting. Now I’d like to delete the TT hints in the new master. The new master is the fourth layer, so index 3. I’ve tried this:
for g in Glyphs.font.glyphs:
# print g
for h in g.layers[3].hints:
# print h
del(h)
print "done"
(The print statements are there so I could make sure I was actually hitting the hints.) However, the hints are still there. What am I doing wrong? (This is my first attempt at a script, so please be gentle!)
You cannot remove items from or add to a list while you are iterating over it.
You need to del directly out of the list, like: del layer.hints[i]
What I usually do is get the index numbers, then step backwards through it, to avoid confusion of index numbers after deletion:
for i in range(len(layer.hints)-1, -1, -1):
del layer.hints[i]
But if you want to delete all hints indiscriminately, you can simply set layer.hints=None. Careful though, that also deletes corner and cap components, which are technically hints.