23 Commits

Author SHA1 Message Date
Cosimo Lupo
c0074ee26f
[pointPen] add DecomposingPointPen, point-pen eqivalent to DecomposingPen 2024-03-05 15:18:39 +00:00
Behdad Esfahbod
d342440235 [pointPen] Raise AttributeError in addVarComponent 2023-02-06 08:33:30 -07:00
Behdad Esfahbod
11b2427f61 [pointPen] Add addVarComponent to GuessSmoothPointPen 2023-02-03 11:19:04 -07:00
Behdad Esfahbod
2e20e47473 [transform] Rename VarTransform to DecomposedTransform 2023-02-03 09:05:55 -07:00
Behdad Esfahbod
69966aa5d7 [BasePen] Add addVarComponent() 2023-02-02 15:25:09 -07:00
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Takaaki Fuji
58d6ccf8ae Fix math.atan2 call
Shouldn't make any difference here, but math.atan2(y, x) should be the
correct order.
2021-06-25 09:47:21 +09:00
Takaaki Fuji
4c22d11aa7 Keep GuessSmoothPointPen in sync with fontPens
Imported 9b7ecb4 from fontPens, which is the version modified to accept
a parameterized tolerance. Recent changes in fontTools such as 2831096,
186e461 and 7d5530e were considered so that the diff will be minimal.
2021-06-25 09:39:58 +09:00
Nikolaus Waxweiler
b449686a84 Use TypeError for not enough points 2021-05-01 18:56:38 +01:00
Nikolaus Waxweiler
2831096eeb Introduce PenError, use instead of asserts 2021-04-30 17:19:40 +01:00
Just van Rossum
5fc65d7168
Misc py23 cleanups (#2243)
* Replaced all from ...py23 import * with explicit name imports, or removed completely when possible.
* Replaced tounicode() with tostr()
* Changed all BytesIO ans StringIO imports to from io import ..., replaced all UnicodeIO with StringIO.
* Replaced all unichr() with chr()
* Misc minor tweaks and fixes
2021-03-29 11:45:58 +02:00
justvanrossum
2429a187fc Revert ABC changes to Pens, fixes #2198 2021-02-26 20:18:37 +01:00
Nikolaus Waxweiler
ab1883da1d Turn AbstractPen and AbstractPointPen into ABCs plus typing 2021-02-21 10:20:37 +00:00
Just van Rossum
07140c12bd
[pens] Improve error message if pen.moveTo() is omitted. (#1757)
Improve error message if pen.moveTo() is omitted. See also robotools/fontParts#470
2019-10-30 14:45:55 +01:00
Cosimo Lupo
d33eaaf4ca
PointToSegmentPen: preserve duplicate last point
The PointToSegmentPen translates between PointPen and (Segment)Pen
protocol.

In the SegmentPen protocol, closed contours always imply a final 'lineTo'
segment from the last oncurve point to the starting point.
So the PointToSegmentPen omits the final 'lineTo' segment for closed
contours -- unless the option 'outputImpliedClosingLine' is True
(it is False by default, and defcon.Glyph.draw method initializes the
converter pen without this option).

However, if the last oncurve point is on a "line" segment and has same
coordinates as the starting point of a closed contour, the converter pen must
always output the closing 'lineTo' explicitly (regardless of the value of the
'outputImpliedClosingLine' option) in order to disambiguate this case from
the implied closing 'lineTo'.

If it doesn't do that, a duplicate 'line' point at the end of a closed
contour gets lost in the conversion.

See https://github.com/googlefonts/fontmake/issues/572.
2019-09-10 13:05:36 +02:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Cosimo Lupo
fdb3974dd9 add identifier parameter to PointToSegmentPen.addComponent method
'identifier' param is part of the AbstractPointPen interface.
Even though it is unused by the segment pen protocol, the caller may attempt
to pass it by positional argument instead of keyword argument, e.g.
2920ddd07c/Lib/fontMath/mathGlyph.py (L486)

this patch avoids the resulting TypeError exception
2019-02-27 16:30:20 -08:00
justvanrossum
7bcb67f0cc avoid %r to eliminate unicode repr problems in the tests 2018-10-29 20:47:17 +01:00
justvanrossum
6b4a4e3087 don't use unicode literals in pointPen 2018-10-29 19:58:33 +01:00
justvanrossum
7d5530ec91 more pointpen method signature consistency fixes 2018-10-29 16:42:07 +01:00
justvanrossum
186e4615ab fix some PointPen method signatures 2018-10-29 16:23:54 +01:00
Cosimo Lupo
e871b2f41d
pointPen: add missing classes to __all__ 2018-10-18 16:12:58 +01:00
Cosimo Lupo
6b1bf4247b
move pointPen to fontTools.pens subpackage; keep ufoLib.pointPen alias 2018-10-18 16:03:09 +01:00