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

Fix duplicate glyphs3 GSMetrics; take the first and ignore 'filter' #1278

Merged
merged 2 commits into from
Feb 14, 2025

Conversation

anthrotype
Copy link
Member

GSMetric's filter attribute (that restrict a given metric to a group of glyphs, e.g. small caps) is not relevant to build OS/2 and MVAR tables. Some source contains those, normally following the same-named metric which is supposed to apply globally (and thus be stored in font wide metric tables).
glyphsLib does parse these filter attributes but doesn't even use them, when looking up a metric by name it simply returns the first one it finds. Similarly here when we collect metrics by name, we only take the first one we find and ignore any duplicate that may follow.

Fixes #1269

After the fix, the following gives "output is identical"

$ python resources/scripts/ttx_diff.py 'https://github.com/Etcetera-Type-Co/Epilogue#sources/Epilogue.glyphs' --compare gftools --config ~/.fontc_crater_cache/Etcetera-Type-Co/Epilogue/sources/config.yaml

@anthrotype
Copy link
Member Author

anthrotype commented Feb 14, 2025

the test reproducer (92b89b3) fails as expected (the last duplicate, the one with the 'filter', prevails)

---- font::tests::v3_duplicate_metrics_first_wins stdout ----
thread 'font::tests::v3_duplicate_metrics_first_wins' panicked at glyphs-reader/src/font.rs:3598:9:
assertion failed: `(left == right)`

Diff < left / right > :
 Some(
     (
         Some(
<            450.0,
>            501.0,
         ),
         None,
     ),
 )

https://github.com/googlefonts/fontc/actions/runs/13329313658/job/37229531501

@anthrotype anthrotype requested a review from cmyr February 14, 2025 12:40
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@anthrotype anthrotype added this pull request to the merge queue Feb 14, 2025
Merged via the queue into main with commit 7d57971 Feb 14, 2025
11 checks passed
@anthrotype anthrotype deleted the g3-duplicate-metrics-first-wins branch February 14, 2025 14:16
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.

[glyphs-reader] duplicate GSMetric with 'filter' attribute leading to diffs in OS/2 and MVAR
2 participants