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

Add variable-aware ValueRecord and Anchor types to fea-rs #598

Merged
merged 5 commits into from
Nov 28, 2023

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Nov 23, 2023

Previously we used the ValueRecord and AnchorTable types in write-fonts. This had the complication that anytime you needed to include deltas you had to have access to a VariationStoreBuilder, which was a bottleneck for fontc.

With this change, we now just store the deltas inline in the record/anchor type, and only go and turn them into actual write-fonts types at the very end, after merging anything we've received from feature writers.

This patch makes the fewest changes outside fea-rs that were possible in order to get things working again; as follow up we can go and figure out how best to update the kerning/marks code to take advantage of this new model.

This requires googlefonts/fontations#719; this includes a commit that patches Cargo.toml to point at that for the time being.

Copy link
Member

@anthrotype anthrotype 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, with minor comments

fea-rs/src/compile/compile_ctx.rs Outdated Show resolved Hide resolved
Comment on lines 56 to 57
// the var_store is only used in GPOS, but we pass it everywhere
fn build(self, var_store: &mut VariationStoreBuilder) -> Self::Output;
Copy link
Member

Choose a reason for hiding this comment

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

it's feels a bit strange that one has to pass down a VariationStoreBuilder that is only used in some cases and not others (e.g. if only building GSUB table). Can this be avoided e.g. make it optional or add a different method to construct a lookup builder that has a VariationStoreBuilder?

Copy link
Member Author

Choose a reason for hiding this comment

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

agree this is annoying, and unfortunately Option<&mut T> is annoying to work with, because it doesn't implement Copy, which means you need to do a dance to get the inner reference anywhere you need it, so I found this to be the best compromise.

I agree that this is confusing, though, and I will expand the comment to explain what's going on.

cmyr added 3 commits November 28, 2023 12:14
These types store their deltas inline, which means that we don't need to
have access to an ItemVariationStore in orderto create them. This, in
turn, lets us move all of the concern over deltas to the end of the
compile pass, and also lets us provide a nicer feature writer API.
This also tweaks the visibility of some fields.
@cmyr cmyr force-pushed the fancy-value-record branch from 132e2b7 to b24324b Compare November 28, 2023 17:15
This does the minimum to get us compiling again; there's a larger patch
to write that skips the intermediate step and just creates these types
directly.
@cmyr cmyr force-pushed the fancy-value-record branch from b24324b to 9957f9a Compare November 28, 2023 17:17
@cmyr cmyr added this pull request to the merge queue Nov 28, 2023
Merged via the queue into main with commit e328546 Nov 28, 2023
10 checks passed
@cmyr cmyr deleted the fancy-value-record branch November 28, 2023 17:51
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.

fea-rs: consider adding variation-aware types for ValueRecord & AnchorTable
2 participants