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

Fix header compressed size check by checking against an aligned size #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Kanabenki
Copy link

Closes #4.

It seems the size check would often fail on some fonts as the size of the compressed section provided by the header might not take into account the 4-byte alignment of the section. The comparison is now done between the actual consumed input size after processing the compressed section (the input buffer is consumed until after the potential padding bytes), and the size reported by the header aligned to the next multiple of 4.

The spec seems to indicate that the compressed section should always be padded to 4 byte alignment if followed by an extended metadata block or a private data block, but I'm not totally sure if it enforces this alignment when the compressed block is the last one. However on the font files I checked, the compressed block was always padded even if nothing followed.

This PR also add some derives on the public error type that might be useful to the crate consumers.

I tested with a few fonts (notably those listed in #4) and this seems to be working properly.

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.

Converting Bootstrap woff2 to ttf leads to error
1 participant