[fontdrasil] Fix many-to-one axis map handling#1995
Merged
anthrotype merged 3 commits intomainfrom May 1, 2026
Merged
Conversation
When the map is reversed (e.g. design-to-user), a many-to-one forward map produces duplicate keys. binary_search may return any matching index for duplicates, so use partition_point to always find the first occurrence. googlefonts/ufo2ft#978
Instead of round-tripping design coords through design_to_user (which is lossy for many-to-one axis maps), read the user-space values directly from the mapping entries. This matches glyphsLib's approach. googlefonts/ufo2ft#978
ab4e47e to
e76d106
Compare
Member
Author
|
https://github.com/googlefonts/fontc/actions/runs/25220991765/job/73952882058?pr=1995#step:4:195 |
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.
This is the companion to fonttools/fonttools#4085.
Fixes the remaining
ttx_diffdiscrepancy on SUSE-Italic at 7159afb255 reported in googlefonts/ufo2ft#978"output is identical" in ttx-diff after updated fonttools is installed in the fontc
.venv.PiecewiseLinearMap::map()usesbinary_search, which returns an arbitrary/unspecified index when there are multiple matches:https://doc.rust-lang.org/std/primitive.slice.html#method.binary_search
When a many-to-one forward map (e.g. user=900 -> design=1000 and user=1000 -> design=1000) is reversed, the value returned from binary_search can differ from fontmake's (which takes the first match).
I changed it to use
partition_pointto always find the first occurrence.After fixing this I found a second related issue:
to_ir_axisderived fvar axis min/default/max by round-tripping design coords throughdesign_to_user, which is lossy for many-to-one maps.Changed it to take min/max directly from the user-space values in the mapping, matching glyphsLib's approach.
(I will release a patched fonttools soon and bump fontc requirements after)