The test suite is installed as a sub-package, so the test data must also be installed along with it.
The `__file__` attribute can be missing when importing a zipped package, so we load test files with `pkg_resources.resource_filename()`.
`random.randint`, which is used in `cu2qu.benchmark.generate_curve` function, yields
different results when run in Python 2.7 or 3, despite using the same `random.seed(1)`.
For this reason, the `test_results_unchanged` and `test_results_unchanged_multiple` tests
in `cu2qu_test` module fail when run under Python 2.
Backward compatibility was broken with Python 3.2 `random` module, as a side effect of
fixing a non-uniformity bug. For mor info see:
https://groups.google.com/forum/#!topic/comp.lang.python/KwALjKjF6Y4http://bugs.python.org/issue9025
To work around this, I dumped the result of generate_curve (running from Python 3.5.2 on
OSX) to a json file, and use that to run the tests.
I also stripped the white space to reduce the file size.
```python
import random
import json
from cu2qu.benchmark import generate_curve
random.seed(1)
curves = [generate_curve() for i in range(1000)]
with open("Lib/cu2qu/test/data/curves.json", "w") as fp:
fp.write(json.dumps(curves).replace(" ", ""))
```
fixup
Fixes https://github.com/fonttools/fonttools/issues/457
Backslash-prefixed glyph name can be used in a Feature file to distinguish them from identically-named keywords.
From section "2.f.i. Glyph name" of Adobe's Feature File Specification:
> An initial backslash serves to differentiate a glyph name from an identical keyword in the feature file language. For example, a glyph named "table" must be specified in the feature file as: \table
Thus, when we parse a glyph name that begins with a backslash, we need to ignore the first character.
Note that makeotf rejects feature files with glyph names that start with or contain backslashes, even when escaped with another backslash.
feature liga {
sub \\glyphWithBackslash by A;
} liga;
This yields:
makeotfexe [FATAL] <Backslash-Regular> invalid token (text was "\") [features 2]
ttx is now equivalent to:
$ fonttools ttx
pyftsubset can be called as:
$ fonttools subset
varLib can be called as:
$ fonttools.varLib
Also adds a executable at toplevel called fonttools, such that
with "./fonttools ..." one can run stuff without installing.
Python seems to automatically include ./Lib into its search path.
The table structure requires that all named instances have the same
record size. Slightly refactored the compilation code to make the
logic easier to understand/maintain.
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).