Skip to content
This repository has been archived by the owner on Jan 28, 2019. It is now read-only.

Write tests for adapter pens #11

Open
adrientetar opened this issue Jan 13, 2016 · 5 comments
Open

Write tests for adapter pens #11

adrientetar opened this issue Jan 13, 2016 · 5 comments

Comments

@adrientetar
Copy link
Collaborator

No description provided.

@anthrotype
Copy link
Member

yea, it's a paradox the adapter pens are perhaps the most used classes from ufoLib but have no tests of their own. Hopefully they are tested "in the real world" :)
But yeah, we should add tests once we move ufoLib to fontTools.ufoLib.

@anthrotype
Copy link
Member

just found a nasty bug in BasePointToSegmentPen..
for the special case of quadratic contours with no on-curve points, where it adds a special starting point with None coordinates, it also sets the kwargs to None.. But then if subclasses pass that kwargs to another pointpen's addPoint, using **dict unpacking, it will fail with TypeError as it's not a mapping.

@anthrotype
Copy link
Member

relevant trufont issue here trufont/trufont#595

@anthrotype
Copy link
Member

if firstOnCurve is None:
# Special case for quadratics: a contour with no on-curve
# points. Add a "None" point. (See also the Pen protocol's
# qCurveTo() method and fontTools.pens.basePen.py.)
points.append((None, "qcurve", None, None, None))

@anthrotype
Copy link
Member

just found a nasty bug in BasePointToSegmentPen..

well, it turns out it wasn't a bug, I just was using it improperly.
The cu2qu Cu2QuPointPen is a filter (point)pen that subclasses BasePointToSegmentPen; that's because the algorithm works on segments, not points; the super-class is used to collect points into lists of segments before converting the curves.
A point with None coordinates is a special marker that in the SegmentPen protocol means, this is a contour with no on-curve points, only quadratic off-curves (with implicit interpolated mid-points).
The Cu2QuPointPen should not forward this special None point on to the drawing pointpen, because a None point is not a valid point in the PointPen protocol. Points must always have (x, y) tuple.
Anyway mistery solved, ignore my previous posts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants