Behdad Esfahbod
3d4bd76a76
[perimeterPen] Add Gauss-Lobatto implementation for quadratic Bezier as well
...
Is twice faster than the exact algorithm.
2017-02-20 10:17:07 -06:00
Behdad Esfahbod
9f1067a991
[perimeterPen] Optimize Lobatto code
2017-02-20 10:17:07 -06:00
Cosimo Lupo
a226c4772b
[perimeterPen] move source encoding declaration to the first line
...
Otherwise I get this error on python2.7:
SyntaxError: Non-ASCII character '\xc2' in file perimeterPen.py on line 87, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
2017-02-19 20:08:57 -08:00
Behdad Esfahbod
3e74798499
[perimeterPen] Add Gauss-Lobatto quadrature approximation implementation
...
Is about 30 percent faster than recursive approach for the default .005
error tolerance. To be optimized more.
2017-02-19 16:08:21 -06:00
Cosimo Lupo
78ad48eaf3
Move all *_test.py modules and test data to external Tests/ folder
2017-01-16 09:14:12 +00:00
Cosimo Lupo
29f0a99a06
[t2CharStringPen] add docstring to T2CharStringPen to explain how 'roundTolerance' works
2017-01-14 12:11:21 +00:00
Cosimo Lupo
8891f4185e
[t2CharStringPen] allow tolerance to be > 0.5
...
See https://github.com/fonttools/fonttools/pull/804#issuecomment-272559973
2017-01-13 22:32:10 +00:00
Cosimo Lupo
456e159a5a
[t2CharStringPen] raise ValueError if tolerance not in range 0 <= t <= 0.5
2017-01-13 09:34:42 +00:00
Cosimo Lupo
0a9800b109
[t2CharStringPen] use abs() instead of math.fabs()
...
abs ends up calling fabs for floats anyway, and is a bit faster if 'number' is an int
2017-01-13 09:25:49 +00:00
Cosimo Lupo
3165fa9703
[t2CharStringPen] always round the advance widths regardless of roundTolerance
...
hmtx only can have integer values, so it would be weird to have widths as float in CFF...
2017-01-12 22:38:28 +00:00
Cosimo Lupo
adac78591d
[t2CharStringPen] restore default rounding; tolerance must be between 0 and .5
2017-01-12 21:34:59 +00:00
Cosimo Lupo
20375ca41c
[t2CharStringPen_test] add tests for coordinate rounding and basic pen commands
2017-01-12 19:53:38 +00:00
Cosimo Lupo
834d0d4cca
[t2CharStringPen] disable rounding coordinates; add 'roundTolerance' argument
...
Rounding of coordinates is now disabled by default.
The pen now accepts an optional 'roundTolerance' float, with values between
0 and 1 (default is 0).
Values >= 0.5 mean round all coordinates to integers.
Values between 0 and 0.5 mean round only when the absolute difference
between the original float and the rounded integer is within the tolerance
Fixes #769
2017-01-12 19:48:55 +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
Behdad Esfahbod
25083502e4
[perimeterPen] Update check for cusps
...
If p1 coincides with p0 or p2, we still can use the lineTo()
code.
2016-11-08 16:39:38 -08:00
Behdad Esfahbod
a71faf9322
[perimeterPen] 5x speed-up cubic by using complex numbers as points
2016-10-30 14:28:38 +02:00
Behdad Esfahbod
c5538eaccf
[perimeterPen] Speed up quadratic by using complex numbers for points
2016-10-30 14:28:33 +02:00
Behdad Esfahbod
a284865851
Remove unused line
2016-10-30 14:28:07 +02:00
James Godfrey-Kittle
c732ffce8e
[areaPen] Add test for endPath
2016-10-04 17:33:16 -07:00
James Godfrey-Kittle
238e8cbc52
Typo
2016-10-04 17:32:49 -07:00
James Godfrey-Kittle
870b7ce92a
Allow single-point open contours in area pen
...
Sometimes an anchor is drawn as a moveTo followed by an endPath, for
that case it makes sense just to ignore and count the area as zero.
2016-10-04 16:27:09 -07:00
Cosimo Lupo
814e4d2d79
ttGlyphPen_test: add more test cases for removal of extra move/end points
2016-09-15 19:22:00 +02:00
Behdad Esfahbod
9b3660df9f
pointInsidePen: Disallow endPath()
...
https://github.com/behdad/fonttools/issues/621#issuecomment-234764830
2016-08-10 17:31:29 -07:00
Behdad Esfahbod
f3ff2f8881
pointInsidePen: add getWinding()
...
Resolves https://github.com/behdad/fonttools/issues/621#issuecomment-234764830
Although, leaving contours left open is out of protocol behavior
IMO.
2016-08-10 17:30:33 -07:00
Miguel Sousa
c181805e7e
Tests to increase PointInsidePen's coverage
2016-07-28 00:03:04 -07:00
Adrien Tétar
1126e6edda
qtPen: use native quads impl
2016-07-25 11:14:13 -07:00
Miguel Sousa
2240bcbd22
Example that fails latest PointInsidePen ( #638 )
2016-07-19 22:39:57 -07:00
Behdad Esfahbod
81d84e6f85
Fix PointInsidePen
...
https://github.com/behdad/fonttools/issues/621
2016-07-16 21:47:37 -07:00
Miguel Sousa
a00cacea96
Two more tests for pointInsidePen ( #622 )
2016-07-16 21:22:04 -07:00
Behdad Esfahbod
220ff2b238
[pens.areaPen] Clean up a bit
...
Based on discussion in
https://github.com/behdad/fonttools/pull/618#issuecomment-226105824
2016-06-15 14:10:44 +04:00
Behdad Esfahbod
b0b049774c
Implement analytical curve length for quadratic beziers
...
This is multiple times faster, and tolerance-independent.
I'll explain how I arrived at this later.
2016-06-13 20:08:50 -04:00
Behdad Esfahbod
56c27f45c9
Speed up perimeterPen
...
It's still too slow, but an improvement.
Also, remove duplicate copy from symfont.
2016-06-13 18:50:01 -04:00
Behdad Esfahbod
71fb49962a
Improve perimeterPen tests
...
The tolerance on the pen is set to 0.5%, so it does not make sense
to test for accuracy for anything more than integers given the
values.
2016-06-13 18:47:03 -04:00
Miguel Sousa
9efcaf05e4
Unit tests for AreaPen and PerimeterPen
2016-06-12 15:46:52 -07:00
Miguel Sousa
92e8455259
perimeterPen.py: make glyphset the first argument (like in all other pens)
2016-06-12 15:46:04 -07:00
Cosimo Lupo
c5ed6c6456
perimeterPen.py: handle implied lineTo in closePath
2016-06-12 11:49:00 +01:00
Cosimo Lupo
d51b88a234
areaPen.py: remove unused 'interpolate' function; call polygon_area directly in closePath
2016-06-12 11:37:02 +01:00
Cosimo Lupo
39f919f1f1
areaPen.py: calculate area under quadratic curve directly, using Green theorem
2016-06-12 03:14:09 +01:00
Cosimo Lupo
5f0e48e649
areaPen.py: make sure the first and last points of contour overlap
2016-06-12 03:13:32 +01:00
Cosimo Lupo
38359b054d
areaPen.py: invert sign of area (CCW is now positive)
2016-06-12 03:12:02 +01:00
Cosimo Lupo
c08e47ed47
perimeterPen.py: copy PerimeterPen from symfont.py
2016-06-11 23:07:23 +01:00
Cosimo Lupo
eb7e193773
areaPen.py: typo
2016-06-11 23:07:23 +01:00
Cosimo Lupo
76dc5d2607
areaPen.py: use tabs for indentation as that's the norm in fontTools
...
(despite I prefer spaces)
2016-06-11 23:07:23 +01:00
Cosimo Lupo
2dc88be8a7
areaPen.py: remove unused 'distance' function
2016-06-11 23:07:23 +01:00
Cosimo Lupo
2cb93ee7dd
areaPen.py: hook up quadratic_curve_area to AreaPen._qCurveToOne method
2016-06-11 23:07:23 +01:00
Cosimo Lupo
ac3b30e0db
areaPen.py: add default __future__ imports
2016-06-11 23:07:23 +01:00
Cosimo Lupo
ad4b94f4b9
areaPen.py: use regular tuples for points instead of namedtuple
2016-06-11 23:07:23 +01:00
Cosimo Lupo
046333dda5
areaPen.py: pen to calculate the area of a glyph (by Behdad)
...
https://github.com/behdad/fonttools/issues/617#issuecomment-225029592
2016-06-11 23:07:23 +01:00
Cosimo Lupo
d4b9a2bec3
[ttGlyphPen_test] ttProgram has __eq__ now, remove unnecessary assignments
...
previously assertEqual would fail, despite the `program` attributes where both empty, as the object have different id(). The Program.__eq__ method now compares self.__dict__ == other.__dict__, hence the test pass.
2016-03-11 15:10:50 +00:00
Cosimo Lupo
9b83c377c2
[ttGlyphPen] only add empty ttProgram to simple glyphs, not to composites
...
Unlike simple glyphs (with contours) which must always have `instructionLength`, the field is optional in composite glyphs and depends on whether `WE_HAVE_INSTR` flag is set:
https://www.microsoft.com/typography/otspec/glyf.htm
In the previous code, the TTGlyphPen was adding an empty `program` attribute to any new glyph, including composite glyphs. It should only do it for simple glyphs.
For example, if you take Roboto-Regular.ttf from here:
https://github.com/google/roboto/releases/tag/v2.129
The font (unhinted) was compiled using the ttGlyphPen. It has 1434 composite glyphs. For each of them, a USHORT value for the number of instructions (0) is written, so the binary ttf is 2.868 KB greater than
what it should be.
2016-03-11 10:53:41 +00:00