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

[CFF2] Lift uint16 VariationStore.length limitation #290

Open
behdad opened this issue Oct 25, 2024 · 9 comments · May be fixed by #291
Open

[CFF2] Lift uint16 VariationStore.length limitation #290

behdad opened this issue Oct 25, 2024 · 9 comments · May be fixed by #291

Comments

@behdad
Copy link
Collaborator

behdad commented Oct 25, 2024

See this for details:
harfbuzz/boring-expansion-spec#159

I suggest we implement that already. That is, if the VariationStore struct's length field is 65,535, then allow the embedded ItemVariationStore to reach out to the rest of the font file.

@justvanrossum has been building a font that hit that limit.

We are going to also implement this change in FontTools. HarfBuzz already renders such fonts fine, and I will test FreeType and report.

behdad added a commit to behdad/ots that referenced this issue Oct 25, 2024
@behdad behdad linked a pull request Oct 25, 2024 that will close this issue
@khaledhosny
Copy link
Owner

What does Microsoft and Apple rasterizer do with such fonts? We wouldn’t usually allow fonts they can’t handle, and specially if they don’t fail gracefully. cc @jfkthame

@jfkthame
Copy link
Collaborator

What does Microsoft and Apple rasterizer do with such fonts? We wouldn’t usually allow fonts they can’t handle, and specially if they don’t fail gracefully. cc @jfkthame

Yeah, that's the same question I was going to ask. We don't want OTS accepting fonts that will then cause issues in either DirectWrite or Core Text.

Are there some examples of such fonts that folks could test with the various rasterizers?

@behdad
Copy link
Collaborator Author

behdad commented Oct 26, 2024

What does Microsoft and Apple rasterizer do with such fonts? We wouldn’t usually allow fonts they can’t handle, and specially if they don’t fail gracefully. cc @jfkthame

Yeah, that's the same question I was going to ask. We don't want OTS accepting fonts that will then cause issues in either DirectWrite or Core Text.

I can install the font in on the Mac just fine, and renders fine. I cannot test on Windows.

Are there some examples of such fonts that folks could test with the various rasterizers?

I have a test font from @justvanrossum that is proprietary. I can get it sorted to share with you or @khaledhosny if you can test on Windows.

@jfkthame
Copy link
Collaborator

Windows 10 refuses to install the font; it tells me it's "not a valid font file".

I was able to load it as a webfont resource in Firefox after hacking the OTS code to skip validation of the CFF2 table, and then it does seem to render the glyphs as expected (including weight variations), though I don't know how to test whether it would be able to use the whole of the VariationStore, or only whatever's in the first 64K.

(Just patching ParseVariationStore wasn't sufficient to get through OTS, as the CFF2 table was also rejected for invalid CharStrings; I had to make it skip CFF2 validation altogether.)

@behdad
Copy link
Collaborator Author

behdad commented Oct 27, 2024

(Just patching ParseVariationStore wasn't sufficient to get through OTS, as the CFF2 table was also rejected for invalid CharStrings; I had to make it skip CFF2 validation altogether.)

Yes, there seems to be an stack overflow with the test font. I'm investigating that. If I succeed we can test again to see if it installs.

behdad added a commit to behdad/ots that referenced this issue Oct 27, 2024
behdad added a commit to behdad/ots that referenced this issue Oct 27, 2024
@behdad
Copy link
Collaborator Author

behdad commented Nov 4, 2024

Windows 10 refuses to install the font; it tells me it's "not a valid font file".

I was able to load it as a webfont resource in Firefox after hacking the OTS code to skip validation of the CFF2 table, and then it does seem to render the glyphs as expected (including weight variations), though I don't know how to test whether it would be able to use the whole of the VariationStore, or only whatever's in the first 64K.

I sent you a version of the font that doesn't have the stack overflow. Can you test if that one installs?

So, based on your testing on Windows, do you think we can land this change?

@jfkthame
Copy link
Collaborator

Windows still refuses to install the font, insisting that it is "not a valid font file".

So while we'd be able to use such a file as a webfont (with the OTS change), the fact that it can't be installed in Windows still makes me hesitant to move forward. If OTS accepts a font without reporting any errors, users should be able to expect that font to work in all major current environments, and that surely includes Windows.

@behdad
Copy link
Collaborator Author

behdad commented Nov 16, 2024

This change is on its way to ISO OFF and then OpenType. ISTM that we need different profiles in OTS soon.

@jfkthame
Copy link
Collaborator

Yes, I wondered if something like that might be the answer. So in browsers that can handle the font, we could configure it to allow this, but a standalone OTS validation tool could... reject it? Issue a warning? Provide an option so the user can choose the level of support?

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 a pull request may close this issue.

3 participants