465 Commits

Author SHA1 Message Date
Cosimo Lupo
a0e74f7e69
move ttx.makeOutputFileName to new misc.cliTools module
so it can be reused for other console scripts
2017-01-13 11:16:01 +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
Sascha Brawer
155ec67ae6 [cvar] Implement cvar table 2017-01-10 17:57:04 +01:00
Sascha Brawer
b61b92a96a Fix inconsistent tab/space usage, for Python 3 2017-01-03 16:35:37 +01:00
Behdad Esfahbod
3820a3006f XMLReader: Allow parsing XML without <ttFont> root element 2017-01-02 23:23:44 -05:00
Behdad Esfahbod
6c140cbba1 [testTools] Move MockFont from mtiLib to testTools
This is useful for testing beyond just mtiLib.
2016-12-26 14:34:29 -05:00
Cosimo Lupo
dd5e9a8a28
testTools: fix failing tests on Python 3.4
Apparently b"string %s" % (b"interpolation") works on Python 3.5 but not on 3.4.

We whall maybe start thinking about dropping support for 3.4, now that 3.6 is out next week...
2016-12-21 14:12:43 +00:00
Cosimo Lupo
dff319f14e
testTools_test: add test for getXML; test bytes, unicode and list input for parseXML 2016-12-21 13:57:39 +00:00
Cosimo Lupo
540f0c32b4
testTools: getXML returns a list of strings; parseXML also accepts both a string or list of strings
When writing unit tests for XML data, it is more convenient to compare
list of lines, instead of a single string without newlines.

This helps identifying which lines in the diff printed on the console
don't match the expected result.

So, getXML now returns a list of lines,

To allow passing the same list of lines to the complementary parseXML
function in the roundtrip tests, parseXML now also accepts a list of
strings, as well as a single string.

We also use unicode_literals, and ensure that if the test modules passes
unicode str, we first encode to UTF-8 before passing on to expat XML
parser. This is because on Python 2, expat only accepts bytes strings.
2016-12-21 13:57:33 +00:00
Cosimo Lupo
1a9389653c
py23: minor typo in docstring 2016-12-14 10:03:49 +00:00
Cosimo Lupo
f59c3c59ed Merge pull request #757 from anthrotype/fix-round3-None
[py23] fix inconsistency of built-in round on Python 3.5 if second argument is None
2016-12-04 10:56:08 +00:00
Sascha Brawer
59368c424a WIP: Implement STAT table 2016-12-02 13:37:42 -08:00
Cosimo Lupo
c02ac33e35
py23_test: add test for second None argument 2016-12-02 12:15:47 +00:00
Cosimo Lupo
e7867529ad
py23: update round3 docstring to indicate that None is an allowable argument 2016-12-02 12:15:47 +00:00
Cosimo Lupo
f38cde159b
py23: in Python3 < 3.6, round3 wraps built-in round() to workaround inconsistent behaviour between floats/ints and ndigits=None 2016-12-02 12:15:47 +00:00
Cosimo Lupo
eb8654dc4e
py23: move import decimal to top-level scope 2016-12-01 17:43:35 +00:00
Cosimo Lupo
7abd4d281c
py23_test: minor whitespace 2016-12-01 17:24:01 +00:00
Cosimo Lupo
2fbf371232
py23_test: add unit tests for isclose() backport 2016-12-01 17:13:09 +00:00
Cosimo Lupo
b09501fd8b
py23: only use the slow round3 implementation for half-way, even cases; add backport of py35 math.isclose() 2016-12-01 17:12:20 +00:00
Cosimo Lupo
63621b347d
py23_test: in round2/round3, drop support for ndigit with __index__ attribute; add test for when a number is already an integer 2016-11-30 13:01:20 +00:00
Cosimo Lupo
f742ea07e8
py23: in round3, avoid rounding if number is already int; return the same type when called with two args
We only define 'round3' for PY2 and 'round2' for PY3, and also make sure 'round3' is always an alias of
the built-in 'round' on Python 3; and similarly 'round2' is an alias of built-in 'round' on Python 2.

Thus, for clarity, one can do:

    from fontTools.misc.py23 import round3 as round

or

    from fontTools.misc.py23 import round2 as round

and be certain that the fast built-in implementation will be used on the
respective python major version.
2016-11-30 12:58:58 +00:00
Cosimo Lupo
2552d224a3 [testTools] use 'newlinestr' for makeXMLWriter() helper function 2016-10-20 16:57:49 +01:00
Cosimo Lupo
543be9cfbf [xmlWriter_test] test custom 'newlinestr' values in XMLWriter constructor 2016-10-20 16:56:41 +01:00
Cosimo Lupo
d874782ee4 [xmlWriter] add 'newlinestr' argument for overriding os-specific line endings
By default (newlinestr=None), the XMLWriter will still use the `os.linesep` as the
newline string.
Otherwise, it will use the specified `newlinestr`.

This is useful when TTX files under version control are being written from
multiple platforms; in which case, one usually wants to always use one
specific line ending (most likely LF, which is what the XML spec itself
normalizes it to).
2016-10-20 16:53:07 +01:00
moyogo
f591e8c503 fixedTools: add ensureVersionIsLong() and versionToFixed() 2016-10-18 18:18:09 +02:00
Sascha Brawer
0588502771 Add otConverters.NameID (#708)
When writing XML, this produces a comment with the English name.
If the name ID is missing from the name table, it logs a warning.
2016-10-14 21:04:35 +02:00
Cosimo Lupo
ab395ff0e2 move CapturingLogHandler class from subset to loggingTools module 2016-10-04 14:31:30 +01:00
Cosimo Lupo
152c6d81b3 [py23_test] import round2 and round3 in py23_test module 2016-09-13 18:48:18 +02:00
Cosimo Lupo
8de2f44b31 [py23] don't export 'round2' and 'round3' in __all__, only 'round'
No need to pollute the namespace. If one needs one or the other, one can just import that explicitly.
2016-09-13 18:44:30 +02:00
Cosimo Lupo
f07c29c8bc [py23] export 'round' in __all__
(let's see if some of our tests that import * breaks now...)
2016-09-13 07:16:12 +01:00
Cosimo Lupo
b22f8c7310 [py23] in PY2 shadow built-in round with round3; in PY3 simply use built-in round 2016-09-13 07:13:32 +01:00
Cosimo Lupo
c7edcfec30 [py23_test] borrow round() test cases from cpython 2.7 test suite 2016-09-13 07:13:32 +01:00
Cosimo Lupo
ffa03f6566 [py23] add round2 and round3 function for simulating Python 2 and Python 3 built-in round
The implementation is inspired by https://github.com/PythonCharmers/python-future/blob/master/src/future/builtins/newround.py

It adds support for the old Python 2 round, and for negative 'ndigits'
2016-09-13 07:13:32 +01:00
Behdad Esfahbod
8701fedcfe More solveCubic() hardening
It really should be quite solid this time. :-)
2016-08-13 16:29:49 -07:00
Behdad Esfahbod
5bea5f4fd6 Remove unused line 2016-08-13 16:25:09 -07:00
Behdad Esfahbod
ca7f8d8808 Harden solveCubic() some more
Fixes https://github.com/behdad/fonttools/issues/617#issuecomment-239146815
2016-08-12 22:43:20 -07:00
Behdad Esfahbod
02b415c237 [bezierTools] Speed up a bit 2016-07-29 14:40:10 -07:00
Behdad Esfahbod
d96e246532 Make solveCubic() more robust
Fixes https://github.com/behdad/fonttools/issues/621#issuecomment-226671968
2016-07-19 22:50:09 -07:00
Behdad Esfahbod
10aaac53f2 Fix test 2016-07-16 21:58:41 -07:00
Behdad Esfahbod
81d84e6f85 Fix PointInsidePen
https://github.com/behdad/fonttools/issues/621
2016-07-16 21:47:37 -07:00
Behdad Esfahbod
78c29bc5a1 Some more solveCubic() work
Should be stable again now.
2016-06-08 18:56:31 -07:00
Behdad Esfahbod
b2bd15d580 Make solveCubic() more robust
Also, return duplicate roots multiple times.

Part of https://github.com/behdad/fonttools/issues/617
2016-06-08 14:54:23 -07:00
Behdad Esfahbod
e53764a16d In calcIntBounds(), round values
The glyph coordinates in glyf table are going to be rounded when
writing out, so we should use the same mode of conversion to
integers.  Otherwise the xMin of a glyph might end up being
different from its actual minimum X.
2016-06-07 15:47:02 -07:00
Behdad Esfahbod
d1424e9d5a Improve solveCubic() against rounding issues
Might fix https://github.com/behdad/fonttools/issues/617
2016-06-07 14:16:42 -07:00
Rod Sheeter
74e7400097 Minimal change to allow Google Fonts to easily capture subset timings serverside via log handler. 2016-05-11 12:59:37 -07:00
Cosimo Lupo
a796b03366 py23: raise Py23Error when using 'xrange'
see https://github.com/behdad/fonttools/pull/600#issuecomment-216935319
2016-05-04 18:31:13 +01:00
Cosimo Lupo
7efb32b2de py23: always use iterator whether one uses 'range' (py3) or 'xrange' (py2) 2016-05-04 17:16:39 +01:00
Cosimo Lupo
d2b58c4a86 textTools: add import sys
just to make my linter happy
2016-04-10 22:59:52 +01:00
Cosimo Lupo
e8c8bb75b1 xmlReader: must import sys
used at line 22 to read from stdin
2016-04-10 22:59:02 +01:00
Cosimo Lupo
09d2983fbb [classifyTools] rename 'sorted' -> 'sort' to avoid confusions with the built-in name 2016-04-08 22:08:21 +01:00