158 Commits

Author SHA1 Message Date
Cosimo Lupo
9be3901795 move Lib/cu2qu/test to tests/ folder
There is no need to install the test suite with the package.
Let's put it outside like it's recommended by pytest.
2017-10-31 12:58:09 +00:00
Cosimo Lupo
af0a06081a remove robofab imports
fonts_to_quadratic may still work with Robofab fonts, it's just
that the point pens will be imported from standalone ufoLib
2017-10-31 12:35:26 +00:00
Cosimo Lupo
4d07b533fc Move benchmark.py and ufo_benchmark.py to tools/
These modules are only useful for development, should not be installed
with the library
2017-10-31 12:35:26 +00:00
Cosimo Lupo
df10cdea05 Use fonttools' ReverseContourPen
Fixes #51
2017-10-30 18:56:02 +00:00
Cosimo Lupo
c21ee24eec [pens_test] fix test_stats test
This test would have failed with the incorrect count.
2017-10-25 19:05:40 +01:00
Cosimo Lupo
13abea3ca5 [pens] fix number of segments reported in stats
It appears we were reporting the 'stats' differently in the pens and
in the main ufo module.

https://github.com/googlei18n/cu2qu/blob/7a2f638/Lib/cu2qu/ufo.py#L148

You can git blame me, sorry.
Funny how it's been broken for almost two years :)
2017-10-25 18:49:19 +01:00
Behdad Esfahbod
7a2f6383e4 Simplify log message 2017-07-28 16:41:52 +01:00
Cosimo Lupo
a9f5d463ae
Bump version: 1.2.0 → 1.2.1.dev0 2017-05-24 19:16:46 +01:00
Cosimo Lupo
611512bd60
Release 1.2.0 2017-05-24 19:16:16 +01:00
Cosimo Lupo
815afa1a5a
Bump version: 1.1.2.dev0 → 1.2.0.dev0 2017-05-24 19:14:23 +01:00
Cosimo Lupo
153404077d
[pens] remove ReverseContourPointPen copy; import it from ufoLib (v2.1.0)
... or from robofab (I haven't tested the latter though)
2017-05-24 19:05:14 +01:00
Denis Moyogo Jacquerye
b1626bd0e8 Change the default approximation error from 0.0025 to 0.001 2017-05-23 16:09:48 +01:00
Cosimo Lupo
ee708d097d
Bump version: 1.1.1 -> 1.1.2.dev0 (for real!)
Sorry for all this "bumping" :)
2016-12-16 23:46:25 +00:00
Cosimo Lupo
2290612c50
manually fix up version string after my release script screwed it :( 2016-12-16 23:42:43 +00:00
Cosimo Lupo
077f9efabe
Bump version: 1.1.0 -> 1.1.1.dev0 2016-12-16 23:16:18 +00:00
James Godfrey-Kittle
19854ad27b [minor] Use submodule name in logger 2016-11-30 17:53:37 -08:00
James Godfrey-Kittle
ebebcd9f0d Use logger instead of printing info 2016-11-29 16:57:42 -08:00
Cosimo Lupo
1236d2fb78 Merge pull request #58 from anthrotype/pypi-deploy
set up PyPI deployment on tags from Travis CI
2016-11-24 06:45:19 +00:00
Cosimo Lupo
6618095c36
ufo: raise custom IncompatibleGlyphsError exception with the name(s) of incompatible glyphs
Fixes https://github.com/googlei18n/cu2qu/issues/46
2016-11-04 15:30:40 +00:00
Cosimo Lupo
85bbe112ce
ufo_benchmark: move defcon and robofab imports inside respective setup functions
otherwise, pytest test collection fails to import ufo_benchmark mode, as defcon/robofab are not specified as install requirements, thus may not be present when running the test suite.
2016-11-03 18:59:00 +00:00
James Godfrey-Kittle
641a4cfc42 Merge pull request #56 from anthrotype/fix-py3-random-seed
Fix tests on py2 because of differences with py3 random module
2016-11-02 11:33:10 -07:00
Cosimo Lupo
4fb661f01a
cu2qu.test: load test package data using pkg_resources
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()`.
2016-11-02 17:51:08 +00:00
Cosimo Lupo
5e8f036edd
cu2qu_test: don't use 'random' to gen test curves for py23 compat, load from json file
`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/KwALjKjF6Y4
http://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
2016-11-02 17:51:07 +00:00
James Godfrey-Kittle
509b82204e [minor] rename variable 2016-10-20 11:25:02 -07:00
James Godfrey-Kittle
4782dd64d3 Merge pull request #50 from anthrotype/no-zip-fonts
[ufo] in fonts_to_quadratic, iterate over union of glyph names
2016-10-20 10:55:45 -07:00
Cosimo Lupo
a876671e6f [ufo] glyphs_modified = reverse_direction 2016-10-06 16:17:26 +01:00
Cosimo Lupo
c2792f858b [ufo] when reverse_direction is True, we always want to modify the input glyphs
otherwise, the direction would only flipped if the glyph contains at least one cubic curve; whereas, we want to reverse the contour direction of all the glyphs in the font, even if they are just made of straight lines.
2016-10-06 15:14:44 +01:00
Cosimo Lupo
9c229e6509 [ufo] max_errors and glyphs list must have same length
Else curves_to_quadratic raises AssertionError if len(max_errors) != len(curves)

https://github.com/googlei18n/cu2qu/blob/master/Lib/cu2qu/__init__.py#L244
2016-09-21 00:51:06 +01:00
Cosimo Lupo
a5f93a06b9 [ufo] in fonts_to_quadratic, iterate over union of glyph names and convert compatibly glyphs with same name.
Don't use zip(*fonts) as defcon fonts are dictionary-like objects and the ordering of the glyphs returned by __iter__ method is undefined.
Should fix #48
2016-09-20 23:34:32 +01:00
Cosimo Lupo
826b790147 [ufo] minor refactor 2016-09-19 13:10:57 +01:00
Cosimo Lupo
f2e962c78f [ufo] don't check glyph names in glyphs_to_quadratic 2016-08-12 16:00:20 +01:00
Cosimo Lupo
e7854e5039 [ufo] add glyph[s]_to_quadratic to convert (1+ compatible) glyphs
This was requested in https://github.com/googlei18n/cu2qu/issues/26

Plus:
- do not modify input glyphs unless they contain one cubic curve;
- make public functions return True/False to signal that the input
  was modified or not (eg. no curves, or all quadratic)
2016-08-12 15:30:51 +01:00
Behdad Esfahbod
c53ea86826 Use a generator for cubics[]
Not huge fan of it, but shows slight speedup, and is "Pythonic".
2016-08-01 18:10:16 -07:00
Behdad Esfahbod
9db52c9483 Avoid some more work
Saves another 7%.  Somehow I failed to push this to the last batch.
2016-08-01 14:34:41 -07:00
James Godfrey-Kittle
fc5f5d194d Fix tests 2016-08-01 14:15:26 -07:00
Behdad Esfahbod
33478a9e49 Merge pull request #40 from googlei18n/never-say-never
Never say never
2016-08-01 14:11:46 -07:00
James Godfrey-Kittle
daaa1bd06f Report number of segments in result, not points (#41)
For some reason, I was subtracting 1 from the spline lengths in the
test report. Not sure why that is, so I've assumed it was wrong (and
now we subtract 2 to get the length in number of segments).
2016-08-01 14:08:26 -07:00
Behdad Esfahbod
17b034c904 In curves_to_quadratic(), avoid some more work
When a curve fails to convert at a certain n, keep increasing n for
this curve until a fit found.  Saves another 7% in the benchmark.
2016-07-29 20:31:38 -07:00
Behdad Esfahbod
06eb980a0c Split off case of n=1 into its own function
Looks like changes like this don't have measurable performance
penalty, but they do help with analyzing profile output to see
which branch (n=1 or n!=1) takes more time.
2016-07-29 20:31:38 -07:00
Behdad Esfahbod
96eb3baa15 Add specialization of split_cubic_into_n() for n=6
...by calling split_cubic_into_three() twice.  Gives another 5..9%
speedup.  The thing is, while higher n values are lower-frequency,
the savings are also bigger.  So the two offset out.
2016-07-29 20:31:38 -07:00
Behdad Esfahbod
6d811003ed Add specialization of split_cubic_into_n() for n=4
...by calling split_cubic_into_two() twice.  Gives another 5% speedup.
2016-07-29 20:31:38 -07:00
Behdad Esfahbod
44235274cd Remove variable that was used once. 2016-07-29 20:31:38 -07:00
Behdad Esfahbod
f899c8ccf8 Combine two more loops
Another 10% speedup.
2016-07-28 17:37:18 -07:00
Behdad Esfahbod
c5a17bb055 Shuffle code in cubic_approx_spline() a bit 2016-07-28 17:10:49 -07:00
Behdad Esfahbod
b305ef49be Another micro-optimization 2016-07-28 16:31:30 -07:00
Behdad Esfahbod
40ebe85d9e Move special-cases of split_cubic_into_n() into it
Surprisingly this doesn't seem to slow down, but also slightly
speed up.
2016-07-28 16:25:58 -07:00
Behdad Esfahbod
ede89847a7 Apply review changes from https://github.com/googlei18n/cu2qu/pull/37 2016-07-28 16:12:00 -07:00
Behdad Esfahbod
223450e8d7 Break out of conversion loop early if a curve fails to convert
Makes the compatible-conversion about 40% faster.
2016-07-28 14:41:33 -07:00
Behdad Esfahbod
39fbd9faba [benchmark] Make output more compact
Also, are the min numbers really useful?
2016-07-28 14:41:33 -07:00
Behdad Esfahbod
54104319f9 Another theoretical optimization 2016-07-28 13:57:17 -07:00