170 Commits

Author SHA1 Message Date
Cosimo Lupo
6606bbef3c
[ttGlyphPen] simplify 2018-03-01 18:50:45 +00:00
Cosimo Lupo
6a4ccd0e9f
[ttGlyphPen] check for out-of-range values before clamping 2018-03-01 18:00:41 +00:00
Denis Moyogo Jacquerye
098d9ecf6f
TTGlyphPen: handle scale limit
* decompose components with scale out of range [-2, 2)

* use closest F2Dot14 value when 0b1.11111111111111 < scale <= 2
2018-03-01 17:48:48 +00:00
Cosimo Lupo
2cc182ce58
Revert "Revert "t2CharStringPen: specializeCommands expects command args to be list, not tuples""
This reverts commit fe2e897d13aab383d03b7759a15787ed2db99c77.

ufo2ft tests are failing with fonttools master with this error:

fontTools/cffLib/specializer.py:497:
>   commands[i-1] = (new_op, args1+args2)
    TypeError: can only concatenate list (not "tuple") to list
2018-02-20 17:35:10 +00:00
Cosimo Lupo
fe2e897d13
Revert "t2CharStringPen: specializeCommands expects command args to be list, not tuples"
This reverts commit 41445b8449733ade6117b3ae834da518e5623ef8.

41445b8449 (commitcomment-27640426)
2018-02-19 14:57:18 +00:00
Behdad Esfahbod
2d4e76ff0b [bezierTools] Add calcCubicArcLength() and calcCubicArcLengthC()
Fixes https://github.com/fonttools/fonttools/issues/1142
2018-01-09 11:33:57 +01:00
Jens Kutilek
dd558f5df8 Move arc length calculations from pens.perimeterPen to misc.bezierTools 2017-11-14 13:03:58 +01:00
Cosimo Lupo
e201ea9891 [reverseContourPen] don't imply closing lineTo when same as moveTo
Previously, for closed paths, we were always dropping a lineTo segment
that followed moveTo, because after reversing the contour this lineTo
would become the last segment, and in the Pen protocol a closePath
always implies a line to the fist point.

This is OK when the move point and the following lineTo oncurve point
(which becomes last after reversal) don't overlap.

However, if they do, we ended up dropping the duplicate point.

This cu2qu issue exemplify the problem (cu2qu actually uses the
ReverseContourPointPen wrapped by ufoLib's converter pens, but
fontTools' ReverseContourPen does exactly the same):

https://github.com/googlei18n/cu2qu/issues/51

With this patch, the ReverseContourPen now emits the last lineTo
when it is the same as moveTo.
2017-10-24 19:04:38 +01:00
Cosimo Lupo
76e49d6ff5 rename SVGPen to SVGPathPen
This is to make clear that the pen deals specifically with SVG "path" element, not all SVG.
2017-10-15 15:18:35 +02:00
Khaled Hosny
2a69b4b619 I don’t think this rounding is needed 2017-10-15 14:24:14 +03:00
Khaled Hosny
0355d967a0 Add SVGPen
Copied and slightly adapted from:
https://github.com/typesupply/ufo2svg/blob/master/Lib/ufo2svg/svgPathPen.py
2017-10-15 14:24:14 +03:00
Cosimo Lupo
0df9b989be [boundsPen] add init() method to reset ControlBoundsPen
So one can reuse the same pen instance to compute the bounds of more than one glyph in a glyphset, by calling pen.init() before each glyph.draw(pen)
2017-10-13 11:49:36 +01:00
Cosimo Lupo
3f933548b8 [filterPen] clarify ContourFilterPen doesn't touch components 2017-10-12 11:16:43 +01:00
Cosimo Lupo
021de9963b [reverseContourPen] add ReverseContourPen
A filter pen that passes outline data to another pen, but reversing
the winding direction of all contours.

Like ufoLib's ReverseContourPointPen, but using segment-wise pen
interface, without additional point/segment converters, and without
ufoLib.

627f997ddb/Lib/ufoLib/pointPen.py (L327-L406)
2017-10-11 21:13:23 +01:00
Cosimo Lupo
ccf7ab3ab1 [filterPen] add ContourFilterPen
A filter pen that accumulates contour data, passes it through a
`filterContour` method as the contour is closed or ended, and
draws the result with the output pen.
2017-10-11 21:13:23 +01:00
Behdad Esfahbod
7ade0096de [pens.t2CharStringPen] Call BasePen constructor
Fixes https://github.com/fonttools/fonttools/issues/965
2017-05-17 17:06:00 -07:00
Cosimo Lupo
41445b8449
t2CharStringPen: specializeCommands expects command args to be list, not tuples
In the docstring of programToCommands, it says that:

> Each command is a two-tuple of commandname,arg-list

Previously the T2CharStringPen was passing command args as tuples instead
of lists to the specializeCommands function with option generalizeFirst=False,
which would only make a shallow copy of the input commands to modify them
in place. The problem is that it attempted to call list-only methods, leading
to errors like:

File "fontTools/cffLib/specializer.py", line 432, in specializeCommands
    args.insert(pos, 0)
AttributeError: 'tuple' object has no attribute 'insert'

Since the expectation of the code here and elsewhere is that args is a
list, it makes sense that the T2 pen passes lists instead of tuples to the
specializeCommands function.
2017-05-08 10:51:39 +01:00
Behdad Esfahbod
0e94f909a6 [pens.t2CharStringPen] Disallow glyph width in CFF2 2017-05-06 13:16:07 -06:00
Behdad Esfahbod
2abacb9366 [pens.t2CharString] Bump CFF2 stack size from 193 to 513
That's happening in the next version of OpenType spec (and maxstack
operator deprecated.)
2017-05-06 13:14:25 -06:00
Behdad Esfahbod
4b5c1be29b [pens.t2CharStringPen] Add CFF2 mode 2017-05-06 04:54:07 -06:00
Behdad Esfahbod
72ec474f74 [pens.t2CharStringPen] Simplify drastically 2017-05-06 04:50:24 -06:00
Behdad Esfahbod
c8cf233e26 [pens.t2CharStringPen] Hook up to cffLib.specializer
Tests are failing now, as cffLib.specializer combines operations whereas
previous pen didn't.  I checked all failures and they all look like the
expectation needs to be updated to me.

Fixes https://github.com/fonttools/fonttools/issues/403
2017-05-05 21:21:30 -06:00
Miguel Sousa
70c695f8f6 [t2CharStringPen] Make it more clear that the variables hold offsets 2017-04-28 03:34:41 -07:00
Miguel Sousa
c757cf7b70 [t2CharStringPen] Support more path construction operators 2017-04-28 03:26:37 -07:00
Behdad Esfahbod
b4827ae965 Add recordingPen.replayRecording 2017-04-20 14:54:13 -07:00
Cosimo Lupo
94c88f56cb
[recordingPen] add DecomposingRecordingPen
Uses the DecomposingPen as mixin, and raise KeyError on missing glyphs

See https://github.com/fonttools/fonttools/pull/880#issuecomment-288558012
2017-04-13 14:22:39 +01:00
Cosimo Lupo
b438dbeee5
[basePen] add LoggingPen and DecomposingPen, subclass BasePen from DecomposingPen
This is so we can reuse addComponent with the recording pen, without having to
inherit from the BasePen (which also splits curveTo and qCurveTo commands).

Log warning message on missing glyphs by default, optionally raise KeyError
if skipMissingComponents = False
2017-04-13 14:22:29 +01:00
Cosimo Lupo
980ac7d415
[transformPen] use FilterPen as the base class instead of AbstractPen 2017-04-12 14:17:15 +01:00
Cosimo Lupo
107bf48ffe
[filterPen] add FilterPen base class
Can be useful for others, e.g.:
https://github.com/googlei18n/ufo2ft/issues/120#issuecomment-288503784
2017-04-12 14:17:15 +01:00
Adrien Tétar
a03eb1137b pens: add a wx pen 2017-04-07 20:50:20 +02:00
Miguel Sousa
e2d4fe9da8 minor 2017-03-17 07:48:22 -07:00
Miguel Sousa
4de5af36cb Add usage example of RecordingPen 2017-03-17 02:19:12 -07:00
Behdad Esfahbod
c2033cb095 Document new pens 2017-02-26 10:41:11 -08:00
Behdad Esfahbod
19ab2c96cc Fix typo
Who knew __all__ does not actually hide symbols not listed from
importing by name?
2017-02-26 10:33:58 -08:00
Behdad Esfahbod
a02a429573 [StatisticsPen] Some more (probably over-) optimization 2017-02-24 15:20:38 -08:00
Behdad Esfahbod
8335af0d1d [statisticsPen] Micro-optimize 2017-02-24 14:06:58 -08:00
Behdad Esfahbod
8879318c0b Move RecordingPen to fontTools.pens.recordingPen 2017-02-21 12:11:36 -06:00
Behdad Esfahbod
55e529f7a3 Add fontTools.pens.teePen 2017-02-21 12:01:10 -06:00
Behdad Esfahbod
6face10ca3 [basePen] Default glyphset to None 2017-02-21 12:01:10 -06:00
Behdad Esfahbod
f3bfea12c6 Add __all__ to pens that didn't have it 2017-02-21 12:01:10 -06:00
Behdad Esfahbod
69f38605d1 [transformPen] Minor 2017-02-21 12:01:10 -06:00
Behdad Esfahbod
14b46cf7a6 [symfont] Move symfont to fontTools.misc.symfont 2017-02-21 12:01:10 -06:00
Behdad Esfahbod
621759b3a8 [symfont] Add endPath() 2017-02-21 12:01:10 -06:00
Behdad Esfahbod
d8e8a657fa [areaPen] Remove unnecessary docstrings 2017-02-21 12:01:10 -06:00
Behdad Esfahbod
821ea7385f Minor 2017-02-21 12:01:10 -06:00
Behdad Esfahbod
0a2c5ef7ae [symfont] Write generator code as main function in printPen() output 2017-02-21 12:01:10 -06:00
Behdad Esfahbod
f3224d7d34 Move StatisticsPen into fontTools.pens.statisticsPen 2017-02-20 13:19:35 -06:00
Behdad Esfahbod
a8db22a077 Move MomentsPen into fontTools.pens.momentsPen 2017-02-20 12:33:12 -06:00
Behdad Esfahbod
8712c20156 [perimeterPen] Use Gauss-Legendre instead of Lobatto-Gauss for qudratic
Uses one fewer point and is no uglier.
2017-02-20 11:16:12 -06:00
Behdad Esfahbod
6738305fb1 [perimeterPoint] Minor 2017-02-20 11:09:14 -06:00