This allows to call `TTFont.saveXML` with an already open file/stream (e.g. sys.stdout or a StringIO) without it being abruptly closed at the end.
We do the same elsewhere when we reiceive file handles instead of path names, so we might do it here too.
Previously, when TTX was run in verbose mode, the messages printed to the console would also show the time
each one was logged -- e.g. "blah blah (15:23:24)" -- using the 'debugmsg' function which is defined here.
Even though the logging package would allow to do the same thing (via 'datefmt' and "%(asctime)s"), I decided
drop this, as I think it's not very interesting...
I'll replace it with the overall elapsed time in seconds, in a follow-up commit.
When a font supplies no glyph names in its 'post' table, fontTools
builds synthetic glyph names by reversing the 'cmap' table.
After this change, the library looks at all 'cmap' subtables for
Unicode, irrespective of format or platform. For example, glyph #4
in NotoSansOldItalic-Regular.ttf gets now named "u10300" instead of
"glyph00004".
Moved the code for building a reversed 'cmap' table into the cmap class,
for easier testing.
Reorder to OT spec recommended order if reorederTables == True (default).
Don't reorder if reorderTables == None.
Keep the input font original table order if reorderTables == False (and
the font has a reader object from which to get the original order).
when _getGlyphNamesFromCmap gets called by the cmap parser itself, the
partially loaded subtable is removed and then restored later.
However, when a TTFont instance is imported from XML rather than from
binary file, its 'reader' attribute is None, and so the line:
tempcmap = self['cmap'].getcmap(3, 1)
will make TTFont.__getitem__ raise KeyError. It's better to fail nicely,
and return a dummy glyphOrder based on maxp numGlyphs.
Needed to avoid surprises when we add new table implementations.
Recently we added VDMX table, and that broke build of projects using
VDMX with DefaultTable, eg:
https://github.com/behdad/fonttools/issues/151
When I added the font.lazy setting, I made glyf table non-lazy
by default. This is helpful to users who typically access glyphs
like:
glyf_table.glyphs[glyfname]
instead of the correct way:
glyf_table[glyfname]
and also forget to call expand() on the glyph. However, this
significantly slows down most scripts that load the font without
lazy=True... As such, add a third mode to laziness. By default
lazy=None and does NOT expand glyphs. If lazy=False is passed
in, all glyphs are loaded.
I hope this is an acceptable middle ground and not too confusing.
Lazy loading has implications on how people use objects.
So, by default, don't load lazily. This only affects
GSUB/GDEF/GPOS/etc and is closer to what fonttools used
to do traditionally.
Turn lazy loading on in subset and inspect.
There was an inconsistency: when allowVID was False, we were allowing
gid->glyphXXX, but not the reverse. This was allowing some fonts to
be loaded, but then not to be written back. Fix that.