font.kerning.get() allows for a default return value in case the pair is not present.
However, this afternoon I discovered that fontParts puts an unnecessary restriction on what types it allows for the default value.
Where in former days of RoboFab the code below would happily work:
f = CurrentFont()
print(f.kerning.get(('A', 'Y'), 'no value found'))
Now I was suddenly confronted with this cryptic traceback:
File "/Applications/RoboFont-4.2.app/Contents/Resources/lib/python3.7/fontParts/base/kerning.py", line 350, in get
File "/Applications/RoboFont-4.2.app/Contents/Resources/lib/python3.7/fontParts/base/base.py", line 361, in get
File "/Applications/RoboFont-4.2.app/Contents/Resources/lib/python3.7/fontParts/base/normalizers.py", line 152, in normalizeKerningValue
TypeError: Kerning value must be a int or a float, not str.
To me this seems an overly strict application of normalisation.
Just like in standard Python dictionaries, default return values should be passed along as they are.
font.kerning.get()allows for a default return value in case the pair is not present.However, this afternoon I discovered that fontParts puts an unnecessary restriction on what types it allows for the default value.
Where in former days of RoboFab the code below would happily work:
Now I was suddenly confronted with this cryptic traceback:
To me this seems an overly strict application of normalisation.
Just like in standard Python dictionaries, default return values should be passed along as they are.