I’m getting this error on 10.9.5, Glyphs (653) for the following script that I don’t understand?
Traceback (most recent call last):
File "Delete Kerning Pairs Smaller Than.py", line 31, in
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/ob jc/_convenience.py", line 582, in enumeratorGenerator
yield container_unwrap(anEnumerator.nextObject(), StopIteration)
objc.error: NSGenericException - *** Collection <__NSArrayM: 0x60800084e820> was mutated while being enumerated.
I have adapted the Adjust Kerning in Master script to detect when a kerning pair is smaller than 'x' and delete it. Any help would be appreciated. I can do setKerningForPair as 0, but not remove:
1 #MenuTitle: Delete Kerning Pairs Smaller Than #
2 # -*- coding: utf-8 -*-
4 Delete all kerning pairs smaller than #
8 import GlyphsApp
10 def nameForID( Font, ID ):
12 (tab)(tab)if ID == "@": # is a group
13 (tab)(tab)(tab)return ID
14 (tab)(tab)else: # is a glyph
15 (tab)(tab)(tab)return Font.glyphForId_( ID ).name
16 (tab)except Exception as e:
17 (tab)(tab)raise e
19 Font = Glyphs.font
20 Master = Font.selectedFontMaster
21 MasterID = Master.id
22 MasterKernDict = Font.kerning[ MasterID ]
24 maxKerningSize = 100
28 for leftGlyphID in MasterKernDict.keys():
29 (tab)leftName = nameForID( Font, leftGlyphID )
31 (tab)for rightGlyphID in MasterKernDict[ leftGlyphID ].keys():
32 (tab)(tab)originalKerning = MasterKernDict[ leftGlyphID ][ rightGlyphID ]
33 (tab)(tab)if abs(originalKerning) <= maxKerningSize:
34 (tab)(tab)(tab)rightName = nameForID( Font, rightGlyphID )
35 (tab)(tab)(tab)Font.removeKerningForPair( MasterID, leftName, rightName )
Otherwise a feature to sort the kerning pairs by size would be useful?
you need to replace line 28–35 with this:
LeftKeys = MasterKernDict.keys()[:]
for leftGlyphID in LeftKeys:
(tab)leftName = nameForID( Font, leftGlyphID )
(tab)RightKeys = MasterKernDict[ leftGlyphID ].keys()[:]
(tab)for rightGlyphID in RightKeys:
(tab)(tab)originalKerning = MasterKernDict[ leftGlyphID ][ rightGlyphID ]
(tab)(tab)if abs(originalKerning) <= maxKerningSize:
(tab)(tab)(tab)rightName = nameForID( Font, rightGlyphID )
(tab)(tab)(tab)Font.removeKerningForPair( MasterID, leftName, rightName )
Sure, this is an old topic, but I’ll not create a new conversation about it.
This script gives me currently an unexpected result, as if I’m trying to delete (all) pairs with positive values, it will delete also pairs with negative values while negative-pairs-box is unchecked. Checkboxes have no effect, are they selected or not, just all pairs under current value will be removed.
Still for deleting all positive pairs, can I use Adjust kerning script where can multiple all positive pairs with zero.
Thanks for the bug report, I’ll upload an update in a minute.
Edit: should work now
Thanks, looks working now!