Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let PiecewiseLinearMap::new return error if input mappings contain duplicate keys #937

Open
anthrotype opened this issue Sep 5, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@anthrotype
Copy link
Member

slice::binary_search isn't well defined with multiple values #933

In #935 (comment) I commented

I now also wonder if PiecewiseLinearMap::new (and as a result CoordConverter::new) should be fallible, in case we ever construct them with duplicate from inputs which would lead to a similar ambiguous situation.

in fonttools this situation never occurs because mappings are a dict where keys are unique by definition.
When reading a designspace axis' maps, the list of (user, design) tuples is turned into a dict (with a dict comprehension, where last key wins in case of duplicates):
https://github.com/fonttools/fonttools/blob/c2119229cfb02cdb7c5a63374ef29d3d514259e8/Lib/fontTools/designspaceLib/__init__.py#L1031-L1047

not sure if fontmake warns about this ambiguity (maybe glyphsLib does when constructing the DS axes)

@rsheeter rsheeter added the bug Something isn't working label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants