OTS parsing error: glyf: Failed to parse table

I got a font, that I cannot get to work in any browser.

It fails in Font Gauntlet, mekkablue’s Variable Font Test HTML (generated from his scripts), FontDrop, as well as my one barebone @font-face html. Those always show Times.
Chrome logs OTS parsing error: glyf: Failed to parse table to the console.

It displays in FontGoggles, but loads quite long.

  1. How can I fix this? Is there something, that needs to be in the font, that might not be there? I got the CharSets for Mac Roman and Windows 1252 complete (as not having those was a cause for trouble, at least a few years ago)
  2. How can one properly debug such things? I am doing wild step dances in the dark here.

Does dumping the font with ttx give any traceback that might give you a clue where the problem might be?

Ohoooo, very good idea! Didn’t think about ttx, stupid me.

It does:

Dumping 'GlyphOrder' table...
Dumping 'head' table...
Dumping 'hhea' table...
Dumping 'maxp' table...
Dumping 'OS/2' table...
Dumping 'hmtx' table...
Dumping 'cmap' table...
Dumping 'loca' table...
Dumping 'glyf' table...
ERROR: Unhandled exception has occurred
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/ttx.py", line 401, in main
    process(jobs, options)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/ttx.py", line 374, in process
    action(input, output, options)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/misc/loggingTools.py", line 373, in wrapper
    return func(*args, **kwds)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/ttx.py", line 264, in ttDump
    ttf.saveXML(output,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/ttLib/ttFont.py", line 227, in saveXML
    self._saveXML(writer, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/ttLib/ttFont.py", line 282, in _saveXML
    self._tableToXML(tableWriter, tag, splitGlyphs=splitGlyphs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/ttLib/ttFont.py", line 311, in _tableToXML
    table.toXML(writer, self, splitGlyphs=splitGlyphs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/ttLib/tables/_g_l_y_f.py", line 151, in toXML
    glyph = self[glyphName]
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/ttLib/tables/_g_l_y_f.py", line 241, in __getitem__
    glyph.expand(self)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/ttLib/tables/_g_l_y_f.py", line 548, in expand
    self.decompileComponents(data, glyfTable)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/ttLib/tables/_g_l_y_f.py", line 678, in decompileComponents
    more, haveInstr, data = component.decompile(data, glyfTable)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fontTools/ttLib/tables/_g_l_y_f.py", line 1285, in decompile
    flags, glyphID = struct.unpack(">HH", data[:4])
struct.error: unpack requires a buffer of 4 bytes

Seems like some python stuff, which might be ignorable here, but it also sheds more light on the glyf table :thinking:

The source makes use of a lot of cap-/corner- and segment-components, and I had a very hard time getting it to export in the first place, as Glyphs complained a lot about it’s inability to convert to truetype curves. For the time beeing, I removed all those components to get it exporting at least.

Can you send me that file?

1 Like

I think I saw something like this recently as well. In my case, the culprit was an exporting glyph that contained a component of an empty non-exporting glyph.

Actually, it’s very easy to reproduce the error:
glyf.zip (4.5 KB)

1 Like

sent :slight_smile: Thanks a lot

Thanks Jens. I fixed that problem.

And my problem, too? I could not find any exporting glyph that contained a component of an empty non-exporting glyph in my file, I assume there was another cause/problem?

The fix for Jens’ example fixes your font, too.

1 Like

Awesome, thank you a ton!