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

[maxp] Attempt to improve fixup of bad 'maxp' version numbers. #267

Merged
merged 1 commit into from
Nov 12, 2023

Conversation

jfkthame
Copy link
Collaborator

If the version number is less than 0x00010000 (e.g. an example reported at mozilla/pdf.js#16839 apparently has 0x0100), it will be treated as version 0.5 and only the num_glyphs field is kept.

However, this can prevent the font working on Windows, which apparently requires the full version 1.0 maxp table for truetype fonts.

So if the version number was bad, but there is in fact enough data to parse as version 1.0, let's try correcting it to 1.0 rather than 0.5.

(Test not included because the example in the issue appears to be a derivative of a proprietary font.)

@jfkthame jfkthame force-pushed the maxp-version branch 3 times, most recently from b3cc775 to 9353793 Compare November 10, 2023 16:29
src/maxp.cc Outdated Show resolved Hide resolved
src/ots.cc Show resolved Hide resolved
If the version number is not explicitly v0.5 (0x00005000), try to read
it as v1.0. (The version field will be corrected to one of the valid
versions during serialization.)

This handles cases where the table was intended to be v1.0 (for a font
with TrueType data), but the version field was set incorrectly (e.g. to
0x00000100, as seen in mozilla/pdf.js#16839).

Also make the max_zones fixup more general, as the example font from the
above issue has max_zones=512(!). Correcting it to 2 should be harmless.
@khaledhosny khaledhosny merged commit be94458 into khaledhosny:main Nov 12, 2023
5 checks passed
@jfkthame jfkthame deleted the maxp-version branch November 12, 2023 19: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.

2 participants