* Replaced all from ...py23 import * with explicit name imports, or removed completely when possible.
* Replaced tounicode() with tostr()
* Changed all BytesIO ans StringIO imports to from io import ..., replaced all UnicodeIO with StringIO.
* Replaced all unichr() with chr()
* Misc minor tweaks and fixes
Also, implement merging version 5 (by taking the min/max of the optical
point sizes), and rename `usMaxContex` to the correct name `usMaxContext`.
The typo was fixed in the OS/2 table some time ago, but we forgot to
also update the merge module.
Fixes#1865
This adds a `help` verb (and `--help` option) to the `fonttools` command line tool. Submodules will be listed in the help text if they have an importable `main` function with a docstring, and `main`'s docstring will be used as the one-line description for the help text.
Instead of appending font index to all glyph names and still potentially
have duplicates, use similar code like we use and “post” and “CFF”
tables to handle duplicate glyph names.
Right now only merges DefaultLangSys. Also, does not remove unused Feature's after merge.
Moreover, does not merge kind Lookups of the same Feature.
But it works!
I added the id() trick because normal objects are not hashable in Python3.
Remove that hack and use a custom dict subclass that allows us to use
objects as keys as long as they don't change.
The custom dict has a different, desirable, property as well: upon seeing
keys it does not know, it just adds them to the end of the list. Will use
this feature in next commits to merge ScriptList properly.
The convention is that sys.exit(...) is called only if a module is run as a script,
and that main() entry points use return statements to report exit codes: 0 (or None)
for successful execution, or any non-zero integer for errors.
E.g. see the console scripts generated when installing with pip.
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
Fixes https://github.com/fonttools/fonttools/issues/739
for now, though proper fix is more complicated.
This was hit now because the subsetter was changed a while back
to retain script systems even if empty... I don't like that.
Changed the merge algorithm to properly handle cmap subtables
of type 4 and 12 with platform id and encoding ids of 3/1 and 3/10
respectively. All other subtables are not merged and ignored.
The resulting merged cmap table includes a subtable of format 4/3/1
and a format 12 subtable iff there are mappings outside of the BMP.
If one font has two codepoints that point to the same glyph,
and another font has the same code points pointing to two other glyphs,
keep the behavior where the first replacement glyph is stored in 'locl'
and output the third glpyh (or more) to let the user know that they were
dropped, instead of failing to merge the font.
Fixes#444Fixes#322