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

Improve PairPos validation #589

Merged
merged 2 commits into from
Sep 7, 2023
Merged

Improve PairPos validation #589

merged 2 commits into from
Sep 7, 2023

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Aug 31, 2023

In write-fonts we have a 'validation' pass before compilation, which is an opportunity to go and inspect the tables we're writing and make sure that the data is sane. A bunch of these checks are generated automatically, but a lot of the validation logic we would want is case-specific; in this case we have a mechanism for naming additional methods to be called in particular places during validation.

We haven't made a ton of use of this custom validation logic, but we probably should, since it helps us be much more confident in the data that we're writing.

This adds some custom validation logic to the two PairPos subtable formats; there was something fishy happening here that was messing up my table packing.

Another thing I'm reminding of while doing this work is how tricky it is to construct these tables correctly without the assistance of a builder; there's a bunch of builders in fea-rs, and they should probably eventually migrate to write-fonts.

This ensures that the arrays are all the correct shape, and that all of
the value records report the expected format.

I believe we are getting these things wrong in fontc/fea-rs, in some
cases.
Another check to ensure that all value records report the correct
format.
@rsheeter
Copy link
Collaborator

I suggest filing issues for additional logic as we identify specific cases

+1 to enhance write-fonts w/builders

})
})
}
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't love the nesting, how might we structure this more like an iter chain where it tends to extend down more than right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. currently the vast majority of validation code is auto-generated, which makes this less painful. I think that improving the API is out of scope for this PR, but I'll open an issue to look into improving this somewhat. I'm not sure that an iter-like API is possible since it doesn't really support scoping, but we might be able to at least reduce the amount of nesting required.

@cmyr cmyr merged commit 84dbe3c into main Sep 7, 2023
9 checks passed
@cmyr cmyr deleted the validate-pairpos branch September 7, 2023 17:38
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