A couple of point pens to filter contours in various ways.

class ThresholdPointPen(otherPointPen, threshold=10)

Rewrite of the ThresholdPen as a PointPen so that we can preserve named points and other arguments. This pen will add components from the original glyph, but but it won’t filter those components.

“move”, “line”, “curve” or “qcurve”


Start a new sub path.


End the current sub path.

addPoint(pt, segmentType=None, smooth=False, name=None, **kwargs)

Add a point to the current sub path.

addComponent(baseGlyphName, transformation)

Add a sub glyph. Note: this way components are not filtered.

class ThresholdPen(otherPen, threshold=10)

Removes segments shorter in length than the threshold value.

thresholdGlyph(aGlyph, threshold=10)

Convenience function that handles the filtering.

thresholdGlyphPointPen(aGlyph, threshold=10)

Same a thresholdGlyph, but using the ThresholdPointPen, which should respect anchors.

class FlattenPen(otherPen, approximateSegmentLength=5, segmentLines=False, filterDoubles=True)

Process the contours into a series of straight lines by flattening the curves.

flattenGlyph(aGlyph, threshold=10, segmentLines=True)

Replace curves with series of straight l ines.

spikeGlyph(aGlyph, segmentLength=20, spikeLength=40, patternFunc=None)

Add narly spikes or dents to the glyph. patternFunc is an optional function which recalculates the offset.

halftoneGlyph(aGlyph, invert=False)

Convert the glyph into some sort of halftoning pattern. Measure a bunch of inside/outside points to simulate grayscale levels. Slow.