Skip to content

font.kerning.get() unnecessarily restricts types for default return value #723

Description

@BoldMonday

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions