217 Commits

Author SHA1 Message Date
Nikolaus Waxweiler
d53583932a Order exceptions hierarchically 2020-02-07 11:39:37 +00:00
Cosimo Lupo
855166c518
cu2qu/ufo: must use PointToSegmentPen with outputImpliedClosingLine=True
When collecting a glyph's segments, we can't simply call the glyphs' draw
method with the GetSegmentsPen, but we must initialize the
PointToSegmentPen explicitly with outputImpliedClosingLine=True.

By default PointToSegmentPen does not outputImpliedClosingLine -- unless
last and first point on closed contour are duplicated.

Because we are converting multiple glyphs at the same time, we want to
make sure the _get_segments function returns the same number of segments,
whether or not the last and first point overlap.

Fixes https://github.com/googlefonts/fontmake/issues/572

Also see: https://github.com/fonttools/fonttools/pull/1720
2019-09-13 13:14:03 +02:00
Cosimo Lupo
3543e4f24e
change imports from ufoLib to fontTools.ufoLib 2018-11-01 16:41:08 +00:00
Cosimo Lupo
201b4926c1 pens: skip the 'None' point for special quadratic contours without oncurves
Fixes https://github.com/trufont/trufont/issues/595
2018-10-11 22:26:10 +01:00
Cosimo Lupo
f77981327e
cli: must create output directory if it doesn't exist already 2018-10-11 18:38:21 +01:00
Cosimo Lupo
e755f58515
pens: add workaround for BasePointToSegmentPen bug
Fixes https://github.com/trufont/trufont/issues/595

We shall remove this workaround once ufoLib is fixed upstream
2018-10-11 18:37:54 +01:00
Behdad Esfahbod
a340ea1fb3 Revert cdivision
Bot not happy.  Not happy bot not good.

This reverts commit 7e130ea438875b3a32564fe02adfd60286b3eed0.
This reverts commit 3486a3635f35044fe94d722cee788ba5d3a5698a.
2018-10-09 09:57:15 -04:00
Behdad Esfahbod
7e130ea438 [cython] Revert one of the cdivisions
Seeing if makes bot happy.
2018-10-09 09:46:30 -04:00
Behdad Esfahbod
3486a3635f [cython] Sprinkle some cdivision
https://github.com/googlei18n/cu2qu/issues/155#issuecomment-427986961

The primary purpose is to disable div-by-zero check since we know it
can't happen in those functions.
2018-10-09 09:40:35 -04:00
Cosimo Lupo
4247b30dde
revert to using division instead of multiplication, fixes 1-unit diffs after v1.6
Fixes #155
2018-10-09 11:32:53 +01:00
Behdad Esfahbod
6be1737965 [cython] Minor add inline 2018-10-06 21:07:13 +02:00
Cosimo Lupo
0f80ff7b2c
cu2qu: add a COMPILED flag to check if cu2qu is running in compiled/interpreted mode 2018-09-26 19:02:02 +01:00
Cosimo Lupo
73d3ce4bc1
cu2qu: add language_level=3 and define_macros to enable coverage 2018-09-26 19:02:02 +01:00
Cosimo Lupo
c13ce2faee
cu2qu: return float('NaN') instead of None so return val matches signature
Otherwise I get 'TypeError: must be real number, not NoneType' when running tests with
the compiled cu2qu extension module
2018-09-26 19:02:02 +01:00
Cosimo Lupo
337c302488
cli: add missing __future__ import absolute_import 2018-09-26 19:00:59 +01:00
Cosimo Lupo
672b446c89
move cu2qu/__init__py to cu2qu/cu2qu.py so we can make an optional Extension module 2018-09-26 19:00:59 +01:00
Cosimo Lupo
d37bbef646
use setuptools_scm for getting package version from git tags 2018-09-26 18:59:03 +01:00
Cosimo Lupo
1d2b159911
Add copy of Cython.Shadow as cu2qu.cython 2018-09-26 18:59:03 +01:00
Behdad Esfahbod
f85240f005 [cython] Remove a couple intermediates 2018-09-26 11:08:25 -04:00
Behdad Esfahbod
36d1b69d7e [cython] More 2018-09-25 18:04:27 -04:00
Behdad Esfahbod
0c361f5cc4 [cython] Some more 2018-09-25 18:01:48 -04:00
Behdad Esfahbod
3efd0839a1 [cython] Add a few @cython.cfunc 2018-09-25 17:52:16 -04:00
Behdad Esfahbod
1f9c4a9e6b [cython] Some more annotations 2018-09-25 17:29:08 -04:00
Behdad Esfahbod
ffdeb86420 Add cython shim 2018-09-25 17:21:54 -04:00
Behdad Esfahbod
f07bf0c266 [cython] Add some cython annotations
Compare:

Python:
behdad:cu2qu 0$ python __init__.py
curve_to_quadratic:	 62.7us
curves_to_quadratic:	163.2us

Cython:
behdad:cu2qu 0$ cython --embed -a __init__.py && gcc __init__.c `python-config --cflags --libs` -O3 && ./a.out
curve_to_quadratic:	 30.4us
curves_to_quadratic:	 77.8us

Cython without this commit:
behdad:cu2qu 0$ cython --embed -a __init__.py && gcc __init__.c `python-config --cflags --libs` -O3 && ./a.out
curve_to_quadratic:	 43.9us
curves_to_quadratic:	113.3us

So, 2x speedup compared to Python. 1.5x speedup compared to Cython without annotations.

More to be done.
2018-09-25 17:18:15 -04:00
Behdad Esfahbod
ed9da8db80 Add benchmarking to __init__
I haven't removed tools/benchmark.py.  Probably should.
Also, improved the timeit parameters over benchmark.py.
2018-09-25 16:05:40 -04:00
Cosimo Lupo
81878eef6b
Bump version: 1.5.0 → 1.5.1.dev0 2018-04-11 12:01:33 +01:00
Cosimo Lupo
7e9043a61e
Release 1.5.0 2018-04-10 21:48:46 +01:00
Cosimo Lupo
5b59be68fb
Bump version: 1.4.1.dev0 → 1.5.0.dev0 2018-04-10 21:25:19 +01:00
Cosimo Lupo
ccdf7ad140
cli: add -e/--conversion-error and --keep-direction options 2018-04-10 21:24:15 +01:00
Cosimo Lupo
06c4d5973b
cli: minor 2018-04-10 21:04:05 +01:00
Cosimo Lupo
4a8b44356d
Add __main__.py to call cli.main() as 'python -m cu2qu' 2018-04-10 19:04:21 +01:00
Cosimo Lupo
ac8fdf7dc9
add cu2qu.cli module exporting a main() function for console script
requires defcon
2018-04-10 19:04:21 +01:00
Cosimo Lupo
0a2593b2c5
[cu2qu.ufo] remember the curve type in lib to skip converting twice 2018-04-10 18:22:32 +01:00
Cosimo Lupo
7064562174
Bump version: 1.4.0 → 1.4.1.dev0 2018-01-18 17:07:01 +00:00
Cosimo Lupo
dba25f6059
Release 1.4.0 2018-01-18 17:05:31 +00:00
Cosimo Lupo
ed9080df79
Bump version: 1.3.1.dev0 → 1.4.0.dev0 2018-01-18 16:55:50 +00:00
Cosimo Lupo
e07d582755
minor: prettify indentation of incompatible segments message 2018-01-18 16:53:47 +00:00
Cosimo Lupo
0b41ba3521
_set_segments must now handle 'curveTo' segments as well
since we let them pass now, and we only stop at the end
2018-01-18 14:33:49 +00:00
Cosimo Lupo
b627a778bf
Don't stop at first incompatibilty, log errors, raise at the end
Based on Miguel Sousa's original PR and the following discussion:
https://github.com/googlei18n/cu2qu/pull/114

Instead of raising an error at the first incompatible glyph, we
let it continue (keeping the original contours unmodified when
that happens), and use logging to print error messages.

A new `IncompatibleFontsError` exception is raised at the end of
`fonts_to_quadratic` if any glyph has incompatible number or types
of segments. The exception instance has a `glyph_errors` attribute
(dict) which collects all the individual IncompatibleGlyphsError
keyed by glyph name.
2018-01-18 13:21:08 +00:00
Cosimo Lupo
fbb41aeb1b Bump version: 1.3.0 → 1.3.1.dev0 2017-10-31 19:57:57 +00:00
Cosimo Lupo
932d030d6f Release 1.3.0 2017-10-31 19:57:00 +00:00
Cosimo Lupo
824a9d22bc Bump version: 1.2.1.dev0 → 1.3.0.dev0 2017-10-31 19:43:56 +00:00
Cosimo Lupo
718228cb32 ufo: minor
No need to be verbose here. Message is never read anyway.
2017-10-31 19:10:35 +00:00
Cosimo Lupo
e648ef3f89 ufo: must scale max_err_em list by UPEM
When the 'max_err_em' argument is a float, we multiply it
by the font.info.unitsPerEm. However we were not doing it when
the argument is a list of floats...
2017-10-31 18:23:21 +00:00
Cosimo Lupo
fabada54b1 ufo: minor
_segments_to_quadratic is private, and always gets not-None 'stats' argument.
This if-branch is always true. Removed.
2017-10-31 18:22:56 +00:00
Cosimo Lupo
09c5856428 ufo: don't drop single points in GetSegmentsPen
We dropped robofab support. There is no reason to arbitrarily
drop any contour points. Anchors are handled as anchors in
latest ufoLib+defcon, also for UFO2. No more need to special-case.
2017-10-31 18:21:20 +00:00
Cosimo Lupo
6c22995a5f pens: deprecate 'ignore_single_points' argument
This was needed for when we were supporting the old robofab.ufoLib
where anchors were represented as single-point-with-a-name contours.
With latest ufoLib, even when glif format is 1, anchors are
stored separately and are not drawn with pens (only proper contours
and components are passed on in the draw method).
So there is no longer need to special-case single points.
It's not the job of the cu2qu pens to filter those out.
2017-10-31 17:57:53 +00:00
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