transformPen

class fontTools.pens.transformPen.TransformPen(outPen, transformation)[source]

Bases: FilterPen

Pen that transforms all coordinates using a Affine transformation, and passes them to another pen.

moveTo(pt)[source]
lineTo(pt)[source]
curveTo(*points)[source]
qCurveTo(*points)[source]
closePath()[source]
endPath()[source]
addComponent(glyphName, transformation)[source]
class fontTools.pens.transformPen.TransformPointPen(outPointPen, transformation)[source]

Bases: FilterPointPen

PointPen that transforms all coordinates using a Affine transformation, and passes them to another PointPen.

For example:

>>> from fontTools.pens.recordingPen import RecordingPointPen
>>> rec = RecordingPointPen()
>>> pen = TransformPointPen(rec, (2, 0, 0, 2, -10, 5))
>>> v = iter(rec.value)
>>> pen.beginPath(identifier="contour-0")
>>> next(v)
('beginPath', (), {'identifier': 'contour-0'})

>>> pen.addPoint((100, 100), "line")
>>> next(v)
('addPoint', ((190, 205), 'line', False, None), {})

>>> pen.endPath()
>>> next(v)
('endPath', (), {})

>>> pen.addComponent("a", (1, 0, 0, 1, -10, 5), identifier="component-0")
>>> next(v)
('addComponent', ('a', <Transform [2 0 0 2 -30 15]>), {'identifier': 'component-0'})
addPoint(pt, segmentType=None, smooth=False, name=None, **kwargs)[source]
addComponent(baseGlyphName, transformation, **kwargs)[source]