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
Cosimo Lupo
87d13888ce
[ttGlyphPen] check last point in qCurveTo is not None
...
otherwise, if points[-1] == 0, the on-curve point won't be added.
2016-03-09 17:58:48 +00:00
James Godfrey-Kittle
fd5b6de3ba
[TTGlyphPen] Add component flags argument
2016-03-07 14:48:46 -08:00
James Godfrey-Kittle
f02e771527
[TTGlyphPen] Don't cast values to int
...
The glyf table will handle rounding when compiling, so this is
unnecessary.
2016-02-16 17:17:14 -08:00
Cosimo Lupo
c4d2ebca66
remove deprecated use of 'quiet' option in test modules
2016-02-01 13:39:39 +00:00
Cosimo Lupo
974421e8b0
boundsPen_test: test single-point contours, with/without 'ignoreSinglePoints'
2016-01-07 15:48:23 +00:00
Cosimo Lupo
dc2ef2e341
boundsPen: add 'ignoreSinglePoints' argument to do like robofab.pens.boundsPen
...
if `ignoreSinglePoints` is True, single points are excluded from the computation of the bounds.
The default value (False) keeps the current behaviour (i.e., single points are not ignored).
https://github.com/robofab-developers/robofab/blob/master/Lib/robofab/pens/boundsPen.py
See discussion at: https://github.com/typemytype/booleanOperations/pull/20
2016-01-07 15:47:31 +00:00
James Godfrey-Kittle
45e496fdb8
[TTGlyphPen] Use bytes for array.array for python3
2015-11-06 11:50:39 -08:00
James Godfrey-Kittle
981ad5978c
Add endPath method to TransformPen
...
I think this was just forgotten before.
2015-11-06 11:25:48 -08:00
James Godfrey-Kittle
9ff7d62454
[TTGlyphPen] Do special case ignoring anchors
...
This fixes the ignoring anchors test, which led me to believe we
didn't need to special case them (which we do, and now are).
2015-11-05 15:28:19 -08:00
James Godfrey-Kittle
6dc5092e2b
[TTGlyphPen] Move some code around
...
No effective differences, just lingering un-committed local changes.
2015-11-05 15:19:53 -08:00
James Godfrey-Kittle
ec2daf00e4
[TTGlyphPen] Add unit tests
...
These test some pen methods which can't be tested via TTFont objects.
The other option seemed to be using UFOs, but this is simpler.
2015-11-05 15:18:32 -08:00
James Godfrey-Kittle
1bff12f311
[TTGlyphPen] Don't explicitly relcalc glyph bounds
...
There's no need to do this explicitly; it happens during the calls to
compile().
2015-11-05 15:13:43 -08:00
James Godfrey-Kittle
0b3b83f765
[TTGlyphPen] Don't special case ignoring anchors
...
There's no need to special case this, it happens anyways.
2015-11-05 15:12:18 -08:00
James Godfrey-Kittle
f5b9ec0186
[TTGlyphPen] Add a new e2e test
2015-11-05 14:11:51 -08:00
James Godfrey-Kittle
b511b2b0d8
[TTGlyphPen] Go back to using AbstractPen
...
Using BasePen breaks on quadratic splines, since there's no way to
know if a on-curve point was added by the pen or in the original
glyph. Should have considered this before....
2015-11-05 13:57:53 -08:00
James Godfrey-Kittle
7767683ea4
[TTGlyphPen] Abstract out a _popPoint method
2015-11-05 13:57:06 -08:00
James Godfrey-Kittle
9f5c51897c
[TTGlyphPen] Move checks for closed contours
...
We probably don't want to raise errors in init, which allows a drawer
to reset the pen state.
2015-11-05 13:54:51 -08:00
James Godfrey-Kittle
943d258bdb
[TTGlyphPen] Add a test using existing test data
2015-11-04 18:01:34 -08:00
James Godfrey-Kittle
fa82fcd213
[TTGlyphPen] Make components with correct defaults
...
This seems consistent with what one sees opening up an existing TTF.
2015-11-04 17:59:57 -08:00
James Godfrey-Kittle
8c61d08d94
[TTGlyphPen] Remove last point in closed contours
...
When a pen adds the first point to a contour at the end to close it,
we should remove it for the TrueType outline.
2015-11-04 17:58:27 -08:00
James Godfrey-Kittle
1c73a1942a
Don't use lineTo in moveTo
...
It shouldn't make a difference, but semantically this is now correct.
2015-11-04 17:21:17 -08:00