If a module is run as script, as in `python module.py` or when using
`runpy.run_module()`, then __name__ == "__main__".
So when we instantiate modules' loggers with `logging.getLogger(__name__)`,
those loggers' name may become "__main__" when run as scripts, and hence
fall outside of the "fontTools" logging namespace.
fontTools.configureLogger() by default only configures the "fontTools"
library loggers, anything outside of it (e.g. logger called "__main__")
is not attached a handler.
So here I name loggers explicitly instead of relying on __name__, but
only for modules which can be run as "__main__".
Fixes#801
API Change:
This will change XML output for GSUB/GPOS/GDEF/MATH/BASE/JSTF/...
Scripts that set the Version for those to 1.0 or other float values
also need fixing. A warning is emitted when code or XML needs fix.
Fixed encoding error in subset tool in Windows which system default codepage isn't 65001.
For Example:
When windows default codepage is 936, the command like 'pyftsubset myfont.ttf --text-file=mytextfile.txt' will throw an exception.
'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.
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
As needed in my Monotype OpenType format parser. I'm not using the object
directly from subset module, but pushing back my changes here, in the hope
that we move this object to ttLib proper soon.
Add support for subsetting COLR table.
The CPAL table does not need subsetting, but unused palettes should be
pruned, this is not implemented however as it depends on COLR table,
which in turn will not be updated after pruning CPAL.