Source code for fontTools.pens.filterPen

from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
from fontTools.pens.basePen import AbstractPen


[docs]class FilterPen(AbstractPen): """ Base class for pens that apply some transformation to the coordinates they receive and pass them to another pen. You can override any of its methods. The default implementation does nothing, but passes the commands unmodified to the other pen. >>> from fontTools.pens.recordingPen import RecordingPen >>> rec = RecordingPen() >>> pen = FilterPen(rec) >>> v = iter(rec.value) >>> pen.moveTo((0, 0)) >>> next(v) ('moveTo', ((0, 0),)) >>> pen.lineTo((1, 1)) >>> next(v) ('lineTo', ((1, 1),)) >>> pen.curveTo((2, 2), (3, 3), (4, 4)) >>> next(v) ('curveTo', ((2, 2), (3, 3), (4, 4))) >>> pen.qCurveTo((5, 5), (6, 6), (7, 7), (8, 8)) >>> next(v) ('qCurveTo', ((5, 5), (6, 6), (7, 7), (8, 8))) >>> pen.closePath() >>> next(v) ('closePath', ()) >>> pen.moveTo((9, 9)) >>> next(v) ('moveTo', ((9, 9),)) >>> pen.endPath() >>> next(v) ('endPath', ()) >>> pen.addComponent('foo', (1, 0, 0, 1, 0, 0)) >>> next(v) ('addComponent', ('foo', (1, 0, 0, 1, 0, 0))) """ def __init__(self, outPen): self._outPen = outPen
[docs] def moveTo(self, pt): self._outPen.moveTo(pt)
[docs] def lineTo(self, pt): self._outPen.lineTo(pt)
[docs] def curveTo(self, *points): self._outPen.curveTo(*points)
[docs] def qCurveTo(self, *points): self._outPen.qCurveTo(*points)
[docs] def closePath(self): self._outPen.closePath()
[docs] def endPath(self): self._outPen.endPath()
[docs] def addComponent(self, glyphName, transformation): self._outPen.addComponent(glyphName, transformation)