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

class robofab.pens.filterPen.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 robofab.pens.filterPen.ThresholdPen(otherPen, threshold=10)

Removes segments shorter in length than the threshold value.

robofab.pens.filterPen.thresholdGlyph(aGlyph, threshold=10)

Convenience function that handles the filtering.

robofab.pens.filterPen.thresholdGlyphPointPen(aGlyph, threshold=10)

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

class robofab.pens.filterPen.FlattenPen(otherPen, approximateSegmentLength=5, segmentLines=False, filterDoubles=True)

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

robofab.pens.filterPen.flattenGlyph(aGlyph, threshold=10, segmentLines=True)

Replace curves with series of straight l ines.

robofab.pens.filterPen.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.

robofab.pens.filterPen.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.