pointInsidePen

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.

getResult()

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

_addIntersection(goingUp)
_moveTo(point)
_lineTo(point)
_curveToOne(bcp1, bcp2, point)
_qCurveToOne_unfinished(bcp, point)
_closePath()
_endPath()