SOLVED GlyphConstruction as script: x = a&\b gives traceback if no kerning pair is present

  • Im using the utterly convenient glyphConstruction in a python script (ParseGlyphConstructionListFromString, GlyphConstructionBuilder). When I construct a Glyph (x = a&\b) using a pair of glyphs that has not been kerned I get a traceback.

    I'm simply wondering, is this to be expected should it just work, even if a and b are not kerned?

    Also, print(font.kerning[("a", "b")]) triggers a traceback. Should it not be a simple None if a and b is not an existing kerning pair?

    (I use if ("a", "b") in font.kerning: first, then see if I should use the \ or not to trigger kerning in my constructions)

    Traceback (most recent call last):
      File "countrycodes and glyph names", line 63, in <module>
      File "/Users/martin/Library/Application Support/RoboFontPy3/plugins/GlyphConstruction.roboFontExt/lib/", line 1185, in GlyphConstructionBuilder
      File "/Users/martin/Library/Application Support/RoboFontPy3/plugins/GlyphConstruction.roboFontExt/lib/", line 974, in kernValueForGlyphPair
      File "/Applications/", line 255, in __contains__
      File "/Applications/", line 319, in __contains__
      File "/Applications/", line 129, in normalizeKerningKey
    TypeError: Kerning key items must be strings, not NoneType.

    When I type x = a&\b via the Glyph Builder UI all goes well.

  • admin

    should be fixed here:

    Getting kerning is advised to use font.kerning.get(pair) where it does not fail. This is similar to a normal dict.

    Or you can also check first if pair in font.kerning: ...