I’m getting this error on 10.9.5, Glyphs (653) for the following script that I don’t understand?
Start
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.
End
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 -*-
3 __doc__="""
4 Delete all kerning pairs smaller than #
5 """
6
7
8 import GlyphsApp
9
10 def nameForID( Font, ID ):
11 (tab)try:
12 (tab)(tab)if ID[0] == "@": # 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
18
19 Font = Glyphs.font
20 Master = Font.selectedFontMaster
21 MasterID = Master.id
22 MasterKernDict = Font.kerning[ MasterID ]
23
24 maxKerningSize = 100
25
26 Font.disableUpdateInterface()
27
28 for leftGlyphID in MasterKernDict.keys():
29 (tab)leftName = nameForID( Font, leftGlyphID )
30
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 )
36
37 Font.enableUpdateInterface()
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 )
Typemart
(Mart Anderson)
May 4, 2019, 11:42am
4
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.
Typemart
(Mart Anderson)
May 4, 2019, 12:11pm
5
Still for deleting all positive pairs, can I use Adjust kerning script where can multiple all positive pairs with zero.
mekkablue
(Rainer Erich Scheichelbauer)
May 4, 2019, 2:32pm
7
Thanks for the bug report, I’ll upload an update in a minute.
Edit: should work now
Typemart
(Mart Anderson)
May 4, 2019, 3:09pm
8
Thanks, looks working now!