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

Generate kern fea and pass to fea-rs #373

Merged
merged 6 commits into from
Aug 21, 2023
Merged

Generate kern fea and pass to fea-rs #373

merged 6 commits into from
Aug 21, 2023

Conversation

rsheeter
Copy link
Contributor

@rsheeter rsheeter commented Jul 19, 2023

#345 with exploration of sparseness removed. Produces fea akin to:

# fontc generated kerning

@public.kern1.bracketleft_R = [bracketleft];
@public.kern2.bracketleft_L = [bracketleft];
@public.kern1.bracketright_R = [bracketright];
@public.kern2.bracketright_L = [bracketright];


feature kern {
  pos bracketleft bracketright (wght=400:-300 wght=700:-150);
  pos exclam exclam (wght=400:-360 wght=700:-100);
  pos hyphen hyphen (wght=400:-150 wght=700:-50);
  pos @public.kern1.bracketleft_R exclam (wght=400:-165 wght=700:0);
  pos exclam @public.kern2.bracketright_L (wght=400:-160 wght=700:0);
  pos exclam hyphen (wght=400:20 wght=700:0);
} kern;

Note use of user coords as fea-rs does not support unit suffixes at time of writing.

There are a fair # of TODOs remaining, plus the variable kerning built doesn't quite work (#402). Even so, I think this moves us forward enough to be worth capturing. Update: #406 helps a lot with having variable kerning that works by not throwing away data :)

@rsheeter rsheeter force-pushed the kern2 branch 2 times, most recently from 74bb6c6 to efc748c Compare July 19, 2023 16:35
@cmyr cmyr mentioned this pull request Jul 25, 2023
@rsheeter rsheeter changed the title [WIP] Generate kern fea and pass to fea-rs Generate kern fea and pass to fea-rs Aug 15, 2023
@rsheeter rsheeter marked this pull request as ready for review August 15, 2023 17:29
.collect();

// Compute the default on the unrounded deltas
let default_value = deltas
Copy link
Member

Choose a reason for hiding this comment

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

// Compute the default

hm I'd expect the "default" to not be computed, but already defined in the input (as we discussed in #345)

otherwise we end with with default kerning values being applied twice, see #402 (comment)

When we build glyph variations we also filter the default region deltas that VariationModel::deltas returns, we must do the same for variable FEA
that's what ufo2ft kernFeatureWriter does -- fixes the aV kerning in Oswald and similar
Comment on lines +147 to +148
// WARNING: this will fail if the fea location isn't also a glyph location. In time we may wish to fix that.
let var_model = &self.static_metadata.variation_model;
Copy link
Member

@anthrotype anthrotype Aug 20, 2023

Choose a reason for hiding this comment

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

I expect this reuse of a single VariationModel for all kerning pairs to create similar issues as in the sparse glyph variations #400

The correct way to do this is to make specific VariationModels for each set of locations, fonttools does that and caches the models for the pairs referencing the same set of locations, but am not sure if the latter optimization is needed for the Rust port. I think we should prefer correctness at first and only do the memoization if the profiler confirms it's worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SG but I would like to defer this, will file an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

A couple notes inline, nothing major. :)

fontbe/src/features.rs Outdated Show resolved Hide resolved
fontbe/src/features.rs Outdated Show resolved Hide resolved
fontbe/src/features.rs Outdated Show resolved Hide resolved
@rsheeter rsheeter merged commit ba2a2ed into main Aug 21, 2023
8 checks passed
@rsheeter rsheeter deleted the kern2 branch August 21, 2023 19:17
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.

3 participants