After this change, feaLib synthesizes the same lookups as makeotf v2.0.90
for `feature aalt` in the example of section 8.a of the OpenType Feature
File specification.
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.
Before this change, feaLib would group glyph-based pair positionings
by value formats. After this change, this logic happens in otlLib.
But clients can still do their own grouping if they wish, by calling
the buildPairPosGlyphsSubtable() method directly.
self.data is usually set by decompileHeader as "the data after the header"; while here
it also included `headerdata`. This produced corrupt data if the compile method was called
again, as the header data is added again to self.data.
Moreover, in none of the subtable classes' `compile` methods, the re-compiled data is
stored in self.data, so we shall not do that for format 14 either.
Fixes#389
'canonical_order' default value was set to False in the subsetter. However,
the meaning of the related 'reorderTables' argument in TTFont.save method has changed
with commit 6ba67ab699d62962690a7a523c286ebf0c8b0ae4.
When the latter is set to False, the original input font's table order is "kept": which
still means doing some sort of reordering. If one wishes to avoid any kind of reordering,
reorderTables needs to be set to None.
I think it's better to follow the current Python 3 behavior in the situation
where the user doesn't provide any explicit logging configuration.
Before Python 3.2, when no handlers were found when a logging event occurred,
either the events would be silently dropped (if logging.raiseExceptions is
set to False), or it would throw a single "No handlers could be found" warning
(this was the default behavior).
With Python 3.2 and later, the default behavior is that the events are output
using a "handler of last resort". The latter works like StreamHandler
that writes messages (without formatting) to the current value of sys.stderr
(thus respecting any redirections which may be in effect).
Both _StderrHandler and Logger.callHandlers included here are taken from Python 3.5's
logging.py source.
I only set logging.lastResort if it's not already set (i.e. for Python < 3.2).
The Subsetter class now uses a module-level 'log', and no longer uses
its own custom Logger. This has been removed, and its features replaced
by equivalents.
log.lapse() are replaced with Timer context manager/decorator (these should make clearer where the elapsed time starts/stops);
log.glyphs() is kept for convenience: it is bound dynamically to the logger instance instead of subclassing logging.Logger, as it's only
useful in here.
log.font() is replaced by `font.saveXML(sys.stdout)`.
A distinct sub-logger is configured for timing messages, to allow --timing option to be enabled independently from --verbose
Here I use logging.basicConfig to configure the root logger, and hence all the other loggers,
including fontTools'.
I could have used fontTools.configLogger as well (and get predefined formatter, etc.), but wanted
to show that one can also configure the fontTools logger using the built-in logging configuration
functions (e.g. basicConfig, config.dictConfig and config.fileConfig).
The default logger level for TTX is set to logging.INFO. Anything equal or above that level
will be logged. Anything below that will not.
If the -v option is passed, the threshold is lowered to logging.DEBUG.
If the -q option is passed, the threshold is increased to logging.WARNING.
All these debug messages were disabled, and I don't wish to re-enable them
while running TTX in verbose mode. So here I use a custom level less than
logging.DEBUGm to make sure they will be muted even when the logger's level
is equal to logging.DEBUG.