How to tell whether glyph has kerning exception

Hello, I am trying to find the following in the API doc:

I want to set the kerning for a pair with group exceptions. I can tell Glyphs to kern by glyph name or by kerning key – but I cannot automatically recognise whether a glyph is set to kerning exception or not. Glyphs will still kern with the kerning key, not with the glyph, although it is set to exception.

Any ideas? Thank you!

Having an exception means that the glyphs has glyph and class kerning. There is a method in the GSLayer that can help: GSLayer Class Reference

Hello. I can’t figure out how this works in Python.


This returns AttributeError: 'NSKVONotifying_GSLayer' object has no attribute 'previousKerningExeptionForLayer'

Is this at least somewhat correct, or am I completely on the wrong path?

The method is called previousKerningExeptionForLayer:direction:. In Python, the colons need to be replaced by an underscore:

o = Font.glyphs["o"].layers[0]
d = Font.glyphs["d"].layers[0]
kern = o.previousKerningExeptionForLayer_direction_(d, LTR)
1 Like

Thank you very very much!

Just a side note, the method has a typo. It needs to be Exception, not Exeption.

Typos are generally kept for backwards compatibility with existing scripts and plugins. We might add a version without the typo and keep the current method but hide it from the docs.