85 Commits

Author SHA1 Message Date
Just van Rossum
5fc65d7168
Misc py23 cleanups (#2243)
* 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
2021-03-29 11:45:58 +02:00
Simon Cozens
1d366fa345 Address feedback 2020-09-03 14:12:49 +01:00
Simon Cozens
f72983b09d Document mtiLib library 2020-07-22 14:31:17 +01:00
Simon Cozens
089f24da6b
Ensure all fonttools CLI tools have help documentation (#1948)
Note UI change : `fonttools varLib.models` now takes prefixed options `-d` or `-l` instead of guessing the intended feature from the number of arguments.

We have a number of command line tools which are somewhat opaque. (varLib.models in particular was very confusing.) This ensures that they all use argparse to have a consistent interface, and all have --help documentation which at least details their parameters, and hopefully therefore gives more of a clue about what they do. Those which use logging have had a command-line logging parameter added.
2020-05-12 15:11:30 +01:00
Simon Cozens
2cef07af80
[doc] Add help options to fonttools CLI (#1920)
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.
2020-05-12 06:31:13 +01:00
Cosimo Lupo
d91724d76c
Revert "[doc] Add help options to fonttools CLI" 2020-05-04 17:37:24 +01:00
Simon Cozens
02f23a214c [doc] Add help options to fonttools CLI 2020-05-03 22:59:54 +01:00
Cosimo Lupo
39b02fd224
fix a coiple of SyntaxWarning on python 3.8 2020-01-30 10:47:57 +00:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Mickaël Schoentgen
698aa676e8 Fix ResourceWarning: unclosed file in mtiLib 2018-09-25 23:17:34 +02:00
Cosimo Lupo
a4861a16cc
use logging.warning() instead of deprecated logging.warn()
functionality is identical, the latter is deprecated:
https://docs.python.org/3/library/logging.html#logging.Logger.warning
2017-05-24 09:49:37 +01:00
Khaled Hosny
61670fc652 Use logging module for these warnings
Not sure if warnings module was used intentionally here, but the
messages looked odd compared to other FontTools messages.
2017-05-24 10:00:55 +02:00
Behdad Esfahbod
4e9806a443 [mtiLib] Be more lenient in script block parsing
Fixes https://github.com/googlei18n/fontmake/issues/258
2017-03-08 15:33:17 -08:00
Cosimo Lupo
78ad48eaf3
Move all *_test.py modules and test data to external Tests/ folder 2017-01-16 09:14:12 +00:00
Cosimo Lupo
49bcbb916b
consistently do sys.exit(unittest.main()) in all test modules
So that when run as scrips they report test failures with exit code

Follow up on b7bb391033ef3255c90134da3d7aef50d2d5326d
2017-01-11 13:05:35 +00:00
Cosimo Lupo
e5dbc85463
[mtiLib] add __main__.py to allow running package as module
This now works:

$ fonttools mtiLib

or which is the same:

$ python -m fontTools.mtiLib
2017-01-11 12:15:33 +00:00
Cosimo Lupo
b7bb391033
don't use sys.exit(...) inside main(), but only under if __name__ == "__main__"
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.
2017-01-11 12:10:58 +00:00
Cosimo Lupo
ae05b2a583
[logging] for runnable modules, spell out module name instead of using __name__
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
2017-01-11 11:58:17 +00:00
Behdad Esfahbod
6250b60ec3 [mtiLib] Test roundtripping XML->Python->XML as well
Most tests fail right now since when reading XML we don't set *Count
members for empty arrays; we don't set propagated counts either.
Fixes coming.
2017-01-02 23:23:44 -05:00
Behdad Esfahbod
3eacc23868 Update tests for previous commit
The following sed command can be used to update TTX sources for the LookupType
change:

$ sed -i'~' 's/<!-- LookupType=\(.\) -->/<LookupType value="\1"\/>/g' *.ttx
2016-12-28 20:29:43 -05:00
Behdad Esfahbod
8dada08d4d [mtiLib] Enable cmap test now that it passes
Was failing before 312203b6610f513509063dfc7e823bbf9ea55e29
2016-12-27 18:42:09 -05:00
Behdad Esfahbod
7236533eb2 [mtiLib] Prepare for enabling cmap test 2016-12-27 18:16:09 -05:00
Behdad Esfahbod
8528dc9d7c [mtiLib] Add commnent re emitting empty lookups 2016-12-27 15:22:23 -05:00
Behdad Esfahbod
4b38a20cee [mtiLib] Set lookup type even if lookup is empty
For real this time.
2016-12-27 15:19:22 -05:00
Behdad Esfahbod
6380b7041c [mtiLib] Set LookupType even for empty lookup 2016-12-27 15:17:04 -05:00
Behdad Esfahbod
7af5f9a343 [mtiLib] Port remaining types to new internal API 2016-12-27 15:15:48 -05:00
Behdad Esfahbod
86717f390b [mtiLib] Minor 2016-12-27 15:06:03 -05:00
Behdad Esfahbod
621a0613bc [mtiLib] Parse lookup-flags earlier
Such that we set them even if lookup block is empty.
2016-12-27 13:59:12 -05:00
Behdad Esfahbod
cf09589729 [mtiLib] Format 2016-12-27 13:42:17 -05:00
Behdad Esfahbod
a6178fd4fb [mtiLib] Fix and enable chained-glyph test 2016-12-27 13:40:27 -05:00
Behdad Esfahbod
1896353af0 [mtiLib] Enable testing same source against multiple tableTags 2016-12-27 13:38:51 -05:00
Behdad Esfahbod
2f800c9384 [mtiLib] Allow empty lookup 2016-12-27 13:37:11 -05:00
Behdad Esfahbod
edd46bb14a [mtiLib] Remove use of MockFont in tests
Tests pass on both Python 2 and 3 now. Yay!

MockFont is handy for mtiLib.__init__:main().  Not sure how useful it is
otherwise, and what to replace it with.
2016-12-27 13:28:06 -05:00
Behdad Esfahbod
f6294ba7bd [mtiLib] More deterministic output with MockFont 2016-12-27 13:09:39 -05:00
Behdad Esfahbod
8358a7248f [mtiLib] Make output more deterministic with MockFont
I'll first make Python 2 and 3 both generate same output for tests with
MockFont, then will probably hardcode glyphorder and remove MockFont
completely and remove hacks I added to make tests work with MockFont.
2016-12-27 13:03:37 -05:00
Behdad Esfahbod
2034cef52f Write test diffs to stderr, not stdout 2016-12-26 20:30:00 -05:00
Behdad Esfahbod
0661b0805b [mtiLib] Fix warnings in tests with Python3 2016-12-26 20:15:53 -05:00
Behdad Esfahbod
31b6aab8e1 [mtiLib] One more try to make bots happy 2016-12-26 18:06:44 -05:00
Behdad Esfahbod
ab01846a8d [mtiLib] Add some more tests 2016-12-26 17:35:21 -05:00
Behdad Esfahbod
2d3610bb6b Ignore class=0 when reading & writing ClassDef objects
class=0 items might be added as an optimization.  They have no semantic value.
Ignore them.

Fixes the last of mtiLib tests.
2016-12-26 17:26:14 -05:00
Behdad Esfahbod
101303ab50 [mtiLib] Fix two more tests 2016-12-26 17:14:39 -05:00
Behdad Esfahbod
fc25b26ca2 [mtiLib] Fix expected output of two remaining tests 2016-12-26 16:58:19 -05:00
Behdad Esfahbod
795e66747c Print XML output from compil-roundtripped object, not the built one
This is almost always the correct thing to print.  If the two differ, that's
bad, but print the better one.
2016-12-26 16:50:00 -05:00
Behdad Esfahbod
8c571d1b73 [mtiLib] Fix order of diffing test outputs 2016-12-26 16:49:48 -05:00
Behdad Esfahbod
3689f0ffdc [mtiLib] Whitespace 2016-12-26 16:39:50 -05:00
Behdad Esfahbod
aa3b94db0a [mtiLib] Fix mti/gpospairglyph test 2016-12-26 16:36:38 -05:00
Behdad Esfahbod
f4c9134957 [mtiLib] Fix gposmarktobase test 2016-12-26 16:29:20 -05:00
Behdad Esfahbod
4f6dea2d99 [mtiLib] Fix gpossingle test 2016-12-26 16:27:45 -05:00
Behdad Esfahbod
730f77a606 [mtiLib] Make test pass
mark-to-ligature was failing because we were not setting ClassCount.
2016-12-26 16:23:02 -05:00
Behdad Esfahbod
180362d30c [mtiLib] Add test data from spec, with test runner 2016-12-26 16:22:54 -05:00