pointPen
PointPens
Where SegmentPens have an intuitive approach to drawing (if you’re familiar with postscript anyway), the PointPen is geared towards accessing all the data in the contours of the glyph. A PointPen has a very simple interface, it just steps through all the points in a call from glyph.drawPoints(). This allows the caller to provide more data for each point. For instance, whether or not a point is smooth, and its name.
- class fontTools.pens.pointPen.AbstractPointPen[source]
Bases:
object
Baseclass for all PointPens.
- addPoint(pt: Tuple[float, float], segmentType: str | None = None, smooth: bool = False, name: str | None = None, identifier: str | None = None, **kwargs: Any) None [source]
Add a point to the current sub path.
- addComponent(baseGlyphName: str, transformation: Tuple[float, float, float, float, float, float], identifier: str | None = None, **kwargs: Any) None [source]
Add a sub glyph.
- addVarComponent(glyphName: str, transformation: DecomposedTransform, location: Dict[str, float], identifier: str | None = None, **kwargs: Any) None [source]
Add a VarComponent sub glyph. The ‘transformation’ argument must be a DecomposedTransform from the fontTools.misc.transform module, and the ‘location’ argument must be a dictionary mapping axis tags to their locations.
- class fontTools.pens.pointPen.BasePointToSegmentPen[source]
Bases:
AbstractPointPen
Base class for retrieving the outline in a segment-oriented way. The PointPen protocol is simple yet also a little tricky, so when you need an outline presented as segments but you have as points, do use this base implementation as it properly takes care of all the edge cases.
- class fontTools.pens.pointPen.PointToSegmentPen(segmentPen, outputImpliedClosingLine=False)[source]
Bases:
BasePointToSegmentPen
Adapter class that converts the PointPen protocol to the (Segment)Pen protocol.
NOTE: The segment pen does not support and will drop point names, identifiers and kwargs.
- class fontTools.pens.pointPen.SegmentToPointPen(pointPen, guessSmooth=True)[source]
Bases:
AbstractPen
Adapter class that converts the (Segment)Pen protocol to the PointPen protocol.
- class fontTools.pens.pointPen.GuessSmoothPointPen(outPen, error=0.05)[source]
Bases:
AbstractPointPen
Filtering PointPen that tries to determine whether an on-curve point should be “smooth”, ie. that it’s a “tangent” point or a “curve” point.
- class fontTools.pens.pointPen.ReverseContourPointPen(outputPointPen)[source]
Bases:
AbstractPointPen
This is a PointPen that passes outline data to another PointPen, but reversing the winding direction of all contours. Components are simply passed through unchanged.
Closed contours are reversed in such a way that the first point remains the first point.