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

[otlLib] buildCoverage does not remove duplicate glyphs #2433

Closed
dscorbett opened this issue Oct 24, 2021 · 4 comments · Fixed by #2440
Closed

[otlLib] buildCoverage does not remove duplicate glyphs #2433

dscorbett opened this issue Oct 24, 2021 · 4 comments · Fixed by #2440

Comments

@dscorbett
Copy link
Member

If a class in a feature file includes duplicate glyphs, buildCoverage is called on a list that includes duplicate glyphs. buildCoverage sorts the input glyphs but does not remove duplicates.

>>> import fontTools.otlLib.builder
>>> fontTools.otlLib.builder.buildCoverage(['A', 'B', 'A'], {'A': 1, 'B': 2}).glyphs
['A', 'A', 'B']

The spec says “A Coverage table defines a unique index value, the Coverage Index, for each covered glyph”, but a glyph listed multiple times won’t have a unique index.

This can cause a problem when using the OpenType Sanitizer: if a CoverageFormat1 table lists more glyphs than are declared in 'maxp', OTS reports an error.

@jenskutilek
Copy link
Collaborator

It’s at least consistent with what Adobe’s makeotf does, which also doesn’t remove guplicates.

@anthrotype
Copy link
Member

I'm actually not sure about this. Can @khaledhosny or @simoncozens take a look?

@simoncozens
Copy link
Collaborator

Related problem I've been wanting to fix for a while: feaLib allows empty classes, which it then hands to the builder, and the builder dies. Both issues should be caught earlier.

@khaledhosny
Copy link
Collaborator

I defer to @dscorbett expertise here, but it looks like the right thing to do in general.

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 a pull request may close this issue.

5 participants