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
Cosimo Lupo
020acf168b
[classifyTools] fixup tests after reverting commit 34d43aa
2016-04-08 21:59:05 +01:00
Cosimo Lupo
20320494de
Revert "[classifyTools] 'sorted' keyword argument should be boolean"
...
This reverts commit 34d43aa797c8b9e4ff42782bfdd7abde7711835d.
See 34d43aa797 (commitcomment-17012817)
2016-04-08 21:54:56 +01:00
Cosimo Lupo
1aa92de366
[classifyTools] must sub-class from 'object' to use new-style classes on py2
2016-04-07 12:09:28 +01:00
Cosimo Lupo
c9db89a851
[classifyTools] fix doctest failing on pypy
...
It seems like sets are hashed differently in CPython and PyPy.
Because of this, the returned list of class sets may have a different sort
order (within each class size) between the two implementations.
For now, I make the test pass on both CPython and PyPy by casting the returned
list of sets into a set of (frozen) sets, and asserting that its *content* is
correct, without considering the *order* of the sets in the list.
2016-04-07 11:54:53 +01:00
Cosimo Lupo
d2aab877bb
[classifyTools] fix CI doctest failures on python 3
...
set objects have different __repr__ on python 2 and 3
Python 3:
>>> {1, 2, 3}
{1, 2, 3}
Python 2
>>> {1, 2, 3}
set([1, 2, 3])
(one among the several reasons I don't particularly like doctest...)
2016-04-07 10:00:49 +01:00
Cosimo Lupo
69bee48a8f
[classifyTools] semicolon
2016-04-07 09:33:02 +01:00
Cosimo Lupo
34d43aa797
[classifyTools] 'sorted' keyword argument should be boolean
...
or at least that's what the signature and the docstring imply.
2016-04-07 09:31:12 +01:00
Cosimo Lupo
da04ab2909
[py23] define __all__ variable
...
specifying the list of names that are imported when `from py23 import *` is used
2016-04-07 09:21:05 +01:00
Behdad Esfahbod
f70d264ef0
Add __bool__ to fontTools.misc.transform.Transform
2016-04-06 18:15:43 -07:00
Behdad Esfahbod
552b5d97fc
Add fontTools.misc.classifyTools, helpers to classify things into classes
...
To be extended with more features / API. API might change.
2016-04-06 18:15:43 -07:00
Behdad Esfahbod
2a0359af4d
Always import * from py23
...
Since py23 modifies some essential builtins, it's safe to import
everything all the time. At least, that's how it was designed.
It's a bug if importing * breaks some code.
2016-04-06 18:15:43 -07:00
Cosimo Lupo
16f29ffd6d
[loggingTools] use ellipsis for doctests when printing time
...
appveyor can be *very* slow
https://ci.appveyor.com/project/anthrotype/fonttools/build/job/pdrl7o5ggan7qlej
2016-02-07 01:19:45 +00:00
Cosimo Lupo
7c6744e639
[py23_test] pass os.environ copy instead of empty dict to avoid issue on Windows
...
Otherwise I get this:
Fatal Python error: Failed to initialize Windows random API (CryptoGen)
https://ci.appveyor.com/project/anthrotype/fonttools/build/job/qhf8d89or4d5hiyd
see: http://bugs.python.org/issue20614
2016-02-07 01:19:45 +00:00
Cosimo Lupo
4a783326b8
[py23_test] need to use os.pathsep as Windows uses ";", not ":"
2016-02-07 01:19:45 +00:00
Cosimo Lupo
4874264dd9
[py23_test] pass the sys.path as PYTHONPATH to python subprocess
...
Apparently I need to do that, or the child python process does not see fontTools in the path.
Another workaround woud be to ensure that fontTools is installed, at least in editable or develop mode (via `pip install -e .`). But the way we temporarily extend the PYTHONPATH in run-test.sh is less intrusive.
2016-02-07 01:19:45 +00:00
Cosimo Lupo
c4d2ebca66
remove deprecated use of 'quiet' option in test modules
2016-02-01 13:39:39 +00:00
Cosimo Lupo
f65a6ec346
[loggingTools] remove _StderrHandler and Logger classes (moved to py23)
2016-02-01 13:18:06 +00:00
Cosimo Lupo
52620787d8
[py23] set the lastResort handler and custom logger class only for python 2
...
move _StderrHandler and _Logger classes here (previously defined in loggingTools)
2016-02-01 13:17:15 +00:00
Cosimo Lupo
bfe330e0a6
[psCharStrings] use fixedToFloat to use the shortest decimal reprentation
...
Fixes https://github.com/behdad/fonttools/issues/492
2016-02-01 10:52:33 +00:00
Cosimo Lupo
f3116ad4d0
[loggingTools] add Logger class with support for 'lastResort' stderr handler
...
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).
2016-01-29 18:36:21 +00:00