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

build MVAR table from variable GlobalMetrics #648

Merged
merged 5 commits into from
Dec 19, 2023
Merged

build MVAR table from variable GlobalMetrics #648

merged 5 commits into from
Dec 19, 2023

Conversation

anthrotype
Copy link
Member

Fixes #531

This matches fontmake's and fonttools' MVAR tables for a bunch of fonts I tested locally, will add more thorough unit tests soon.

Note how in ufo2fontir and glyphs2fontir we make sure that non-default global metrics masters are not sparse (the default metrics all populated based on basic metrics like UPEM or italic angle), that's because when varLib merges them into MVAR, it starts with whole OS/2 or post etc. tables, so it is never the case that, e.g., only the ascender or the descender provides masters.

Our fontir GlobalMetrics allow for sparse-ness but we currently want to match the output of fontmake in this regard, until maybe some new source format is designed for sparse variable-first use cases.

@anthrotype anthrotype marked this pull request as draft December 13, 2023 17:03
@anthrotype anthrotype force-pushed the mvar branch 5 times, most recently from 55731da to 80a35f4 Compare December 18, 2023 10:44
@anthrotype anthrotype changed the base branch from main to mvar-test-files December 18, 2023 15:05
@anthrotype anthrotype marked this pull request as ready for review December 18, 2023 16:28
Base automatically changed from mvar-test-files to main December 18, 2023 18:15
fontbe/src/mvar.rs Outdated Show resolved Hide resolved
Comment on lines +236 to +242
assert_eq!(mvar.version(), MajorMinor::VERSION_1_0);
assert_eq!(mvar.value_records().len(), 1);

let rec = &mvar.value_records()[0];
assert_eq!(rec.value_tag(), Tag::new(b"xhgt"));
assert_eq!(rec.delta_set_outer_index(), 0);
assert_eq!(rec.delta_set_inner_index(), 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional, I continue to greatly prefer the test output of this sort of thing done as one assert, e.g.

assert_eq!(vec![(Tag::new(b"xhgt"), 0, 0),], mvar.value_records().iter().map(...)]

I've always found it much easier to troubleshoot and harder to forget to assert the length

glyphs-reader/src/font.rs Outdated Show resolved Hide resolved
@anthrotype anthrotype added this pull request to the merge queue Dec 19, 2023
Merged via the queue into main with commit 777f5db Dec 19, 2023
1 check passed
@anthrotype anthrotype deleted the mvar branch December 19, 2023 11:15
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.

Emit MVAR
2 participants