fontTools.pens.pointInsidePen – Pen implementing “point inside” testing for shapes.

class fontTools.pens.pointInsidePen.PointInsidePen(glyphSet, testPoint, evenOdd=0)

Bases: fontTools.pens.basePen.BasePen

This pen implements “point inside” testing: to test whether a given point lies inside the shape (black) or outside (white). Instances of this class can be recycled, as long as the setTestPoint() method is used to set the new point to test.

Typical usage:

pen = PointInsidePen(glyphSet, (100, 200)) outline.draw(pen) isInside = pen.getResult()

Both the even-odd algorithm and the non-zero-winding-rule algorithm are implemented. The latter is the default, specify True for the evenOdd argument of __init__ or setTestPoint to use the even-odd algorithm.

setTestPoint(testPoint, evenOdd=0)

Set the point to test. Call this _before_ the outline gets drawn.


After the shape has been drawn, getResult() returns True if the test point lies within the (black) shape, and False if it doesn’t.

_curveToOne(bcp1, bcp2, point)
_qCurveToOne_unfinished(bcp, point)