List of all kerning pairs in the font?

How can a Python macro determine a list of all kerning pairs defined in the font?

I tried this…

all_existing_pairs = [ ( first, second ) for first, pairs in kerning.iteritems() for second, value in pairs.iteritems() ]

… but for exceptions, instead of the glyph name, the dict/list contains the master ID so it is impossible to determine the glyph (maybe a bug?).

Is there a more elegant way than brute-force testing kerningForPair() for all possible combinations (including glyph name and classes)?

For exceptions you get the glyph id. Call font.glyphForId_(ID) to get the glyph. (written in Safari)

Thanks, Georg.

FWIW, this is what I came up with to determine all flat kerning pairs in the font:

flat_kerning = [ ( font.glyphForId_( first ).name, font.glyphForId_( second ).name, value ) for first, pairs in font.kerning[master_id].iteritems() for second, value in pairs.iteritems() if not first.startswith(’@’) and not second.startswith(’@’) ]

A year late to this but here’s a script that will print every kerning pair in a new tab, including group kerning and exceptions in case anyone is looking for it.