Repository navigation
Fix inconsistent MathKerning ordering - #333
Open
fbirds5230 wants to merge 1 commit into
Open
fbirds5230 wants to merge 1 commit into
fbirds5230 wants to merge 1 commit into
Conversation
Member
|
Could you show a brief example of where this is a problem, please? A short script showing just the kerning pairs will probably be enough. That will help me evaluate the patch. |
Author
|
Sure — two kerning pairs are enough, with no groups involved: from fontMath.mathKerning import MathKerning
a = MathKerning({('A', 'V'): -80, ('T', 'o'): -40})
b = MathKerning({('A', 'V'): -70, ('T', 'o'): -50})
print('a < b:', a < b)
print('b < a:', b < a)
print('sorted([a, b]):', [dict(k.items()) for k in sorted([a, b])])
print('sorted([b, a]):', [dict(k.items()) for k in sorted([b, a])])On current master this prints: The first pair establishes I ran the same script against the PR head: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MathKerningcan report botha < bandb < aas true when successive kerning values differ in opposite directions. Sorting the same two objects can then produce a different order depending on their input order._isLessishalready stops at a smaller value, but continues past a larger one. Add the matchingFalsereturn so the first differing value determines the comparison. This also fixes comparisons of kerning group members and keeps group data from overriding a kerning-value difference.The regression tests cover both comparison directions, sorting from either input order, both group sides, and the priority of kerning values over groups. They fail on the original implementation.
tox -e py-covpasses on Python 3.12.14 with the pinned fonttools 4.60.2: 134 tests and 2 subtests, including doctests. Coverage combination and XML generation also pass. Other Python versions and operating systems were not run locally.