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

[read-fonts] Basic closure of glyphs over GSUB #775

Merged
merged 2 commits into from
Feb 13, 2024
Merged

[read-fonts] Basic closure of glyphs over GSUB #775

merged 2 commits into from
Feb 13, 2024

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Feb 7, 2024

This differs from the fonttools implementation slightly, but I'm not sure if those differences are functional or just a result of how fonttools is organized.

This is a draft because I'd like to figure out tests, but I want to give cosimo a chance to look at it now and see if anything jumps out. In particular I've skipped the fancy logic at https://github.com/fonttools/fonttools/blob/534ceed9db1f5c0355d9ecd73b57db143d79a921/Lib/fontTools/subset/__init__.py#L1832-L1841 because afaict it shouldn't matter? but maybe there's some python magic going on that I'm not aware of..

@anthrotype
Copy link
Member

anthrotype commented Feb 8, 2024

In particular I've skipped the fancy logic at https://github.com/fonttools/fonttools/blob/534ceed9db1f5c0355d9ecd73b57db143d79a921/Lib/fontTools/subset/__init__.py#L1832-L1841 because afaict it shouldn't matter?

As I said in chat, it may matter if there are lookups that aren't referenced by any feature so they will never be applied, the subsetter treats these as if they aren't there for the sake of the closure. Even if this situation is arguably not very frequent, I think it makes sense to match that and also skip them in here.

@cmyr cmyr changed the base branch from main to fea-test-data February 8, 2024 20:45
Base automatically changed from fea-test-data to main February 8, 2024 22:15
This differs from the fonttools implementation slightly, but I'm not
sure if those differences are functional or just a result of how
fonttools is organized.
@cmyr
Copy link
Member Author

cmyr commented Feb 9, 2024

I've cleaned this up a bit and added tests.

I also now have a clearer sense of what fonttools is doing that we're not, and that is more carefully handling contextual lookups, so that we only apply lookups referenced by contextual lookups if we have all the glyphs to match that context.

I think it's worth doing this, but I also think it makes sense to do it as a followup.

@cmyr cmyr marked this pull request as ready for review February 9, 2024 16:04
@dfrg
Copy link
Member

dfrg commented Feb 9, 2024

I’m wondering if we can find a nice abstraction for the six contextual subtables that would simplify both closure and shaping. I’ll noodle on this a bit today.

Copy link
Member

@dfrg dfrg left a comment

Choose a reason for hiding this comment

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

The fea based tests are pretty slick! Closure logic LGTM with one question on the reverse chain stuff.

.chain(self.lookahead_coverages().iter())
{
if !coverage?.iter().any(|gid| glyphs.contains(&gid)) {
continue;
Copy link
Member

Choose a reason for hiding this comment

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

I think this should return?

Copy link
Member Author

Choose a reason for hiding this comment

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

oops, definitely. :)

I'd forgotten this behaved more like a normal lookup than a contextual
lookup.
@cmyr cmyr merged commit d76a5d6 into main Feb 13, 2024
9 checks passed
@cmyr cmyr deleted the gsub-closure branch February 13, 2024 17:41
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.

4 participants