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

OTS fails on font with no glyf #52

Open
rsheeter opened this issue Mar 13, 2015 · 17 comments
Open

OTS fails on font with no glyf #52

rsheeter opened this issue Mar 13, 2015 · 17 comments
Labels

Comments

@rsheeter
Copy link
Contributor

Using pyftsubset, I cut a font down to just a space character. OTS rejects the font saying:

ot-sanitise /tmp/font.ttf
ERROR: glyf: zero-length table
Failed to sanitise file!

As far as I can tell I can't attach a file to an issue so I put the TTX version of the offending font file in https://gist.github.com/rsheeter/5b692cf56eb5d8d54bfe.

@khaledhosny
Copy link
Owner

That is by design, all zero length tables are rejected (though I can not really tell what issue this check is protecting against). We probably need to relax it a bit, e.g. allow an empty glyf table if there is no glyphs with outlines, i.e. loca[maxp->numGlyphs + 1] == 0.

@behdad what do you think?

@behdad
Copy link
Contributor

behdad commented Mar 13, 2015

I hit that before:

https://groups.google.com/forum/#!topic/fonttools/JR1yvwyHj-I

I whitelisted empty tables in fonttools:

fonttools/fonttools#106

I think we need to test how well this actually works. Worst case, I can change fonttools to write 4 zero bytes if glyf table is empty.

@khaledhosny
Copy link
Owner

@rsheeter did you have chance to test if such fonts really work?

@rsheeter
Copy link
Contributor Author

No. Hm; usually our team defines font works as works in browser. Since OTS
is going to kick it out that isn't tremendously helpful. As such I'm not
sure what test to perform to determine if it works. If I can pass such a
font through something like hb-shape OK would we consider that proof it
works?

On Sat, Mar 21, 2015 at 6:52 AM, Khaled Hosny notifications@github.com
wrote:

@rsheeter https://github.com/rsheeter did you have chance to test if
such fonts really work?


Reply to this email directly or view it on GitHub
#52 (comment).

@behdad
Copy link
Contributor

behdad commented Mar 24, 2015

@rsheeter See if it works in IE.

@behdad
Copy link
Contributor

behdad commented Mar 24, 2015

You want to do that by constructing a webfont that maps, say, 'a' to an empty glyph, and see if IE uses the webfont or skips it.

@khaledhosny
Copy link
Owner

I tested the font from #52 (comment) (but adding an entry in the cmap table for a to the space glyph, and making the width of the glyph 2em so it is clear we are not seeing something else) on Windows 10. Windows considers the file invalid and the font viewer refuses to open it, Internet Explorer does not like it either and a fallabck font us used, however Edge is happy to use it and shows whitespace for a.

So I think fonts with zero-length glyf table can be considered invalid, at least as long as people still want to support Internet Explorer.

Closing now, we can probably reconsider this after a couple more years or so when Internet Explorer is no longer relevant (hopefully).

@behdad
Copy link
Contributor

behdad commented Mar 22, 2017

What if glyf table has 1, or 4, zero bytes? Would that work? If yes, we should make fonttools do that.

@behdad
Copy link
Contributor

behdad commented Mar 22, 2017

Because right now an innocuous subset operation can generate fonts that will be rejected.

@khaledhosny
Copy link
Owner

I need to find how to build such a font.

@behdad
Copy link
Contributor

behdad commented Mar 23, 2017 via email

@khaledhosny
Copy link
Owner

Zero-length glyf table does not work, but 1 zero byte works (2 or 4 zero bytes also work). OTS fails with the zero bytes table (it does not reject it but fails to serialize the font). I guess we want to fix this.

@anthrotype
Copy link
Contributor

Do we want to also have fontTools add that 1 zero byte when compiling empty glyf tables?

@khaledhosny
Copy link
Owner

I guess so, since fonts zero-length glyf table won’t even install on Windows.

@behdad
Copy link
Contributor

behdad commented Apr 5, 2017

Do we want to also have fontTools add that 1 zero byte when compiling empty glyf tables?

Yes please.

@yisibl
Copy link

yisibl commented Apr 23, 2023

I found that if I compressed it to woff2, OTS would re-report the error.

ttx gistfile1.txt
woff2_compress gistfile1.ttf

So, shouldn't we give better error alerts to the user before subsetting? This would avoid generating such fonts.

woff2_info gistfile1.woff2


TableDirectory starts at +48
Entry offset flags tag  origLength txLength
    0     48  0x1a GDEF         30
    1     50  0x1b GPOS         30
    2     52  0x1c GSUB         40
    3     54  0x06 OS/2         96
    4     56  0x00 cmap         52
    5     58  0x0a glyf          0       44
    6     61  0x0b loca          6        0
    7     64  0x01 head         54
    8     66  0x02 hhea         36
    9     68  0x03 hmtx          8
   10     70  0x04 maxp         32
   11     72  0x05 name        430
   12     75  0x07 post         32

@khaledhosny
Copy link
Owner

It works for the TTF because the glyf table is 1 byte length, while the woff2 it is 0. I guess this issue was never really fixed since ttx never generated a really empty glyf table.

@khaledhosny khaledhosny reopened this Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants