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

[fontbe] Fix incorrect feature deltas w/ sparse glyph sources #779

Merged
merged 4 commits into from
May 20, 2024

Conversation

anthrotype
Copy link
Member

@anthrotype anthrotype commented Apr 18, 2024

This fixes 'incorrect feature deltas when sparse' #407

The global StaticMetadata.variation_model now only includes 'full' masters (i.e. defining kerning) for both UFOs+DS and .glyphs input (previously this was the case only for the latter).

When we call resolve_variable_metric we make new sub-model when locations != global_model.locations(), or just reuse the global model when locations are equal -- which is currently basically always true for the common source formats (DS and glyphs) in the case of kerning, as the latter is meant to be "dense" and can only be specified for the "full" or globally-defined masters. However, we don't preclude the possibility that in the future other (or newer) source formats may define sparse kerning data, and our fontbe is ready for that.

I added a test file in #776, and verified locally that this patch fixes the issue #407, but I haven't find the time to make an actual unit test yet. If I don't make it in time, you should be able connect the dots...

EDIT: I have added a test case #817

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, a few little notes inline!

fontbe/src/features.rs Outdated Show resolved Hide resolved
)
.unwrap();
&local_model
};
Copy link
Member

Choose a reason for hiding this comment

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

agree it's annoying that we have two versions of this impl, let's open an issue to try and fix this.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah. If we do consolidate these two implementations of resolve_variable_metric, maybe we could use a struct and let the method take &mut self so we can store a cache of prebuilt variation models to reuse when we see the same set of locations, instead of making new ones each time

Copy link
Member Author

Choose a reason for hiding this comment

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

fontbe/src/hvar.rs Show resolved Hide resolved
…ocations only

excluding the locations for intermediate or sparse layers which only contribute glyph sources, not metrics nor kerning
….locations()

or else reuse the global StaticMetadata.variation_model, which will now only includes 'full' masters (i.e. defining kerning) for both UFOs+DS and .glyphs input.

This fixes 'incorrect feature deltas when sparse' #407
@anthrotype anthrotype force-pushed the fix-incorrect-feature-deltas-when-sparse branch from 326a91c to a55c7b2 Compare May 20, 2024 11:44
anthrotype added a commit that referenced this pull request May 20, 2024
@anthrotype
Copy link
Member Author

the same test that failed in #817 passed with this PR branch

@anthrotype
Copy link
Member Author

given that Colin already LGTM'ed this PR before I had added the test, I'll just go on and merge it.

@anthrotype anthrotype added this pull request to the merge queue May 20, 2024
Merged via the queue into main with commit 3b5bcec May 20, 2024
10 checks passed
@anthrotype anthrotype deleted the fix-incorrect-feature-deltas-when-sparse branch May 20, 2024 12:50
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.

2 participants