Skip to content

(Even) better merger errors - #2226

Merged
simoncozens merged 20 commits into
fonttools:mainfrom
simoncozens:fix-merger-errors
Mar 19, 2021
Merged

simoncozens merged 20 commits into
fonttools:mainfrom
simoncozens:fix-merger-errors

Conversation

@simoncozens

Copy link
Copy Markdown
Collaborator

Fixes #2224 (as well as some other silent errors) and adds a test.

Comment thread Lib/fontTools/varLib/errors.py Resolved
Comment thread Lib/fontTools/varLib/merger.py Resolved
Comment thread Lib/fontTools/varLib/errors.py Resolved
Comment thread Tests/varLib/varLib_test.py Resolved
@simoncozens

Copy link
Copy Markdown
Collaborator Author

Thanks, good catches!

@anthrotype
anthrotype requested a review from madig March 17, 2021 12:10
Comment thread Lib/fontTools/varLib/errors.py Resolved
Comment thread Lib/fontTools/varLib/errors.py Resolved
@madig

madig commented Mar 17, 2021 •

Copy link
Copy Markdown
Collaborator

I realize it's probably too late for a debate on principles, but is there a special reason why there's an enum and error classes instead of subclassing the base VarLibMergeError for each subcategory of VarLibMergeFailure? Would make instantiation and printing a bit more straightforward I suppose...

@simoncozens

Copy link
Copy Markdown
Collaborator Author

Maybe. I’ll take a look at doing it that way.

@simoncozens

Copy link
Copy Markdown
Collaborator Author

Done, but now the code is sufficiently different, you're going to have to review it again. :-)

Comment thread Lib/fontTools/varLib/errors.py Resolved
Comment thread Lib/fontTools/varLib/errors.py Resolved
@madig

madig commented Mar 19, 2021

Copy link
Copy Markdown
Collaborator

Hm, this scuppers CFF merge errors, they follow their own logic. Maybe the merge errors with a cause should be subclasses of a class VarLibDetailedMergeError(VarLibMergeError) for now. Or someone needs to adapt the CFF code... Also, could the __init__s use kwargs so one can do

UnsupportedFormat(self, subtable="pair positioning lookup")
# UnsupportedFormat(self, ({"subtable": "pair positioning lookup"},))

InconsistentGlyphOrder(self)
# InconsistentGlyphOrder(self, ({},))

@anthrotype

Copy link
Copy Markdown
Member

@madig good catch about CFF-related VarLibMergeErrors (I'd expected the tests to fail?)

also 👍 on using **kwargs

@madig

madig commented Mar 19, 2021

Copy link
Copy Markdown
Collaborator

The tests don't fail, but the str makes little sense.

@simoncozens

Copy link
Copy Markdown
Collaborator Author

Yes, moving to kwargs was a good move; it allowed me to split up the reason from the traceback, which makes everything a lot tidier.

@madig

madig commented Mar 19, 2021

Copy link
Copy Markdown
Collaborator

Small nit: if your class has a docstring, you don't need a pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Output message for GPOS error

3 participants