GlyphConstruction as script: x = a&\b gives traceback if no kerning pair is present
martin last edited by gferreira
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
bare not kerned?
print(font.kerning[("a", "b")])triggers a traceback. Should it not be a simple
bis not an existing kerning pair?
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 03.py", line 63, in <module> File "/Users/martin/Library/Application Support/RoboFontPy3/plugins/GlyphConstruction.roboFontExt/lib/glyphConstruction.py", line 1185, in GlyphConstructionBuilder File "/Users/martin/Library/Application Support/RoboFontPy3/plugins/GlyphConstruction.roboFontExt/lib/glyphConstruction.py", line 974, in kernValueForGlyphPair File "/Applications/RoboFont3.4b.app/Contents/Resources/lib/python3.7/fontParts/base/kerning.py", line 255, in __contains__ File "/Applications/RoboFont3.4b.app/Contents/Resources/lib/python3.7/fontParts/base/base.py", line 319, in __contains__ File "/Applications/RoboFont3.4b.app/Contents/Resources/lib/python3.7/fontParts/base/normalizers.py", line 129, in normalizeKerningKey TypeError: Kerning key items must be strings, not NoneType.
When I type
x = a&\bvia the Glyph Builder UI all goes well.
Getting kerning is advised to use
font.kerning.get(pair)where it does not fail. This is similar to a normal
Or you can also check first
if pair in font.kerning: ...