Fonttools: error when generating gvar from TTFs with different glyph names

Created on 7 Oct 2016  路  11Comments  路  Source: fonttools/fonttools

I just got this new error which I haven't seen before. I have successfully generated many variable fonts already by first generating interpolatable ttfs and then running
python /~username/env/lib/python2.7/site-packages/FontTools/fontTools/varLib/init.py path/to/mydesignspacefile.designspace

This time I was able to generate the interpolatable ttfs. But then when I ran the command above I got this error:

Generating gvar
Traceback (most recent call last):
  File "/Users/cjdunn/env/lib/python2.7/site-packages/FontTools/fontTools/varLib/__init__.py", line 562, in <module>
    main()
  File "/Users/cjdunn/env/lib/python2.7/site-packages/FontTools/fontTools/varLib/__init__.py", line 553, in main
    _add_gvar(gx, axes, master_fonts, master_locs, base_idx)
  File "/Users/cjdunn/env/lib/python2.7/site-packages/FontTools/fontTools/varLib/__init__.py", line 445, in _add_gvar
    allCoords = [d[0] for d in allData]
TypeError: 'NoneType' object has no attribute '__getitem__'

This is the line the error refers to in init.py:

    for glyph in font.getGlyphOrder():

        allData = [_GetCoordinates(m, glyph) for m in master_ttfs]
        allCoords = [d[0] for d in allData]

looks like it's looping through all of the glyphs, but I'm not sure what the TypeError: 'NoneType' is referring to. @behdad @jamesgk Any ideas what the problem could be? Thank you.

bug

Most helpful comment

My vote would be:
鈥搕ry interpolating based on glyph name
鈥搒kip the glyphs that don't interpolate (and report them)
鈥搖se the unicodes in the 'base' master if there's ever a conflict.

This is basically what Superpolator does: if something isn't perfect in all masters you just get the base master glyph or a weird interpolation (depending what's wrong), but it doesn't stop the whole process. This is very handy for early development/testing when you only care about certain glyphs, and don't care if others fail. As long as they are reported it's fine, and you can fix them later. Alternatively, you could have options for "ignore errors" vs "stop for errors" so the first option is for development and the second option is for final production.

All 11 comments

I think it's this:
https://github.com/fonttools/fonttools/commit/99f97e13a3a95e863b53574e17e05bbc089cc431#commitcomment-19338670

It seems varLib does not currently support interpolating from master_ttfs having different glyph sets.

@anthrotype I just double checked my interpolatable ttfs and the length of the glyf table is the same for all, so that should mean there are the same number of glyphs right?

Could it be something else?

Maybe the glyph names are different?

Turns out it was the unicodes. Same glyphs in all masters, but some unicodes were set differently. Seems to be working now, thanks again for the help.

ufo2ft uses the Unicode codepoint to generate postscript names like uniXXXX, etc. So probably the different unicode value produced different glyph names in some of the master ttfs.

We could fail more gracefully here, e.g. say which glyphname is missing.

RIght. I'll leave that open then.

besides printing the missing names, there's the question whether we should support interpolating from master_ttfs having different glyph names, and how.

My vote would be:
鈥搕ry interpolating based on glyph name
鈥搒kip the glyphs that don't interpolate (and report them)
鈥搖se the unicodes in the 'base' master if there's ever a conflict.

This is basically what Superpolator does: if something isn't perfect in all masters you just get the base master glyph or a weird interpolation (depending what's wrong), but it doesn't stop the whole process. This is very handy for early development/testing when you only care about certain glyphs, and don't care if others fail. As long as they are reported it's fine, and you can fix them later. Alternatively, you could have options for "ignore errors" vs "stop for errors" so the first option is for development and the second option is for final production.

besides printing the missing names, there's the question whether we should support interpolating from master_ttfs having different glyph names, and how.

We definitely should. It's well-defined. Initially I'll require that the base master have all glyphs, but even that can be relaxed eventually.

By default, I like to err and stop if a glyph is not compatible, because I don't want to create bad fonts. But can have an option to keep it going. That's for fontmake though. The code here should probably return list of errors.

Sounds good. If fontmake had an option to ignore errors that would be great, I'll post an issue.

And perhaps varLib could have an option to ignore errors too so if you have compatible glyphs in 2 out of 3 masters then those ones would work. Again, this would only be meant for early dev/testing, not final production. Does that make sense at all?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

behdad picture behdad  路  5Comments

0xff00ff picture 0xff00ff  路  7Comments

justvanrossum picture justvanrossum  路  3Comments

typefacts picture typefacts  路  4Comments

madig picture madig  路  10Comments