8000 woff2_compress zeroes the glyf OVERLAP_SIMPLE flag · Issue #123 · google/woff2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

woff2_compress zeroes the glyf OVERLAP_SIMPLE flag #123

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

Open
Lorp opened this issue Jun 10, 2019 · 10 comments
Open

woff2_compress zeroes the glyf OVERLAP_SIMPLE flag #123

Lorp opened this issue Jun 10, 2019 · 10 comments

Comments

@Lorp
Copy link
Lorp commented Jun 10, 2019

In tests, woff2_compress zeroes the glyf OVERLAP_SIMPLE flag.

This bug refers to the Apple OVERLAP_SIMPLE flag, which is set by default by fontTools varLib.mutator since #1518.

Before woff2_compress:

<TTGlyph name="Psi" xMin="40" yMin="0" xMax="835" yMax="717">
  <contour>
    <pt x="311" y="0" on="1" overlap="1"/>
    <pt x="564" y="0" on="1"/>
    <pt x="564" y="50" on="1"/>
    …

After woff2_compress:

<TTGlyph name="Psi" xMin="40" yMin="0" xMax="835" yMax="717">
  <contour>
    <pt x="311" y="0" on="1"/>
    <pt x="564" y="0" on="1"/>
    <pt x="564" y="50" on="1"/>
    …
@anthrotype
Copy link
Member
anthrotype commented Jun 10, 2019

I believe this is a limitation of the current WOFF2 format, in that the "tripled encoding" of point coordinates in TrueType glyf table only retains whether each point is an on- or off-curve point (the most significant bit of the flagStream's bytes); the rest of the bits are used for the variable length encoding of point coordinates.
https://www.w3.org/TR/WOFF2/#triplet_decoding
Basically there is no room to store those OVERLAP_SIMPLE flags in WOFF2.
In fontTools' encoder, I think I am going to add an option so that the user can turn those bits on when generating the WOFF2 font.

@anthrotype
Copy link
Member

In fontTools' encoder, I think I am going to add an option so that the user can turn those bits on when generating the WOFF2 font.

sorry, I contradicted myself. As I said, the flags can't be stored in current WOFF2. An option could be added to the decoder to set the flags when extracting the compresed WOFF2 font, but not to the encoder itself. The spec needs to be changed if we want to allow storing these OVERLAP flags in the transformed woff2 glyf table.

Another option is to leave the glyt table untransformed. I have to check again the spec to confirm whether this is allowed.

@anthrotype
Copy link
Member
anthrotype commented Jun 10, 2019

Yes -- according to the WOFF2 spec one can pass-through the glyf and loca tables without any transformation applied by setting their version to "3" (in the bit 6-7 of TableDirectoryEntry.flags):

For 'glyf' and 'loca' tables, transformation version 3 indicates the null transform where the original table data was passed directly to the Brotli compressor without applying any pre-processing

@Lorp Lorp changed the title woff2_compress zeroes the glyf OVERLAP_COMPOUND flag woff2_compress zeroes the glyf OVERLAP_SIMPLE flag Jun 10, 2019
@Lorp
Copy link
Author
Lorp commented Jun 10, 2019

Thanks for this. Do you mean that the flag means: treat glyf data just like an arbitrary unstructured binary table? This wil be more than editing a flag in one of the woff2_compress sources, right?

@anthrotype
Copy link
Member

yes -- it means the glyf and loca (always go together) tables are stored intact, without transformations applied. The whole font data stream is then compressed with brotli.
You can't just flip a flag.

@anthrotype
Copy link
Member
anthrotype commented Jun 10, 2019

the WOFF2Params struct has an allow_transforms option that is True by default. The caller can set it to False to prevent glyf and loca to be transformed:

allow_transforms(true) {}

however, the woff2_compress command-line utility doesn't expose an option to disable that.

@christopherhb92
Copy link

Hi @anthrotype I ended up running into the same issue and set allow_transforms to false in source but that didn't seem to fix the issue. Is there more that needs to be done on top of doing that?

@anthrotype
Copy link
Member

i'm not sure actually. Maybe @rsheeter knows?

@zvuc
Copy link
zvuc commented Aug 24, 2020

I bumped onto this issue just today, when trying to use the Inter font hosted by Google Fonts.
Seeing that the original font has no issues (rsms/inter#302), I think this is somethin that needs to be addressd from Google's end... Any updates on this?

@zvuc
Copy link
zvuc commented Aug 24, 2020

Relevant filed issue in Google Fonts repo issues: google/fonts#2602

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

No branches or pull requests

4 participants
0