Esempio n. 1
0
    def drawPoints(self, pointPen):
        if self.drawInner:
            reversePen = ReverseContourPointPen(pointPen)
            self.innerGlyph.drawPoints(CleanPointPen(reversePen))
        if self.drawOuter:
            self.outerGlyph.drawPoints(CleanPointPen(pointPen))

        if self.drawOriginal:
            if self.drawOuter:
                pointPen = ReverseContourPointPen(pointPen)
            self.originalGlyph.drawPoints(CleanPointPen(pointPen))

        for glyphName, transform in self.components:
            pointPen.addComponent(glyphName, transform)
Esempio n. 2
0
def makeShadowGlyph(p, g, offsetValue):
    m  = Identity
    m = m.scale(1)
    m = tuple(m)
    makeShadowGlyphBackground(p, g)
    shadowGlyph = p[str(g.name+".shadow")]
    makeShadow(shadowGlyph, extrusionX, extrusionY)
    shadowGlyph.removeOverlap()
    insetPen = shadowGlyph.getPointPen()
    transformPen = TransformPointPen(insetPen, m)
    reversePen = ReverseContourPointPen(transformPen)
    g.drawPoints(reversePen)
    outlinePen = OutlinePen(p, contrast=0, offset=offsetValue, connection="square", miterLimit=10)
    g.draw(outlinePen)
    shadowGlyph.removeOverlap()
    outlinePen.drawSettings(drawInner=True, drawOuter=True)
    outlinePen.drawPoints(insetPen)
def test_reverse_point_pen(contour, expected):
    from fontTools.ufoLib.pointPen import (ReverseContourPointPen,
                                           PointToSegmentPen,
                                           SegmentToPointPen)

    recpen = RecordingPen()
    pt2seg = PointToSegmentPen(recpen, outputImpliedClosingLine=True)
    revpen = ReverseContourPointPen(pt2seg)
    seg2pt = SegmentToPointPen(revpen)
    for operator, operands in contour:
        getattr(seg2pt, operator)(*operands)

    # for closed contours that have a lineTo following the moveTo,
    # and whose points don't overlap, our current implementation diverges
    # from the ReverseContourPointPen as wrapped by ufoLib's pen converters.
    # In the latter case, an extra lineTo is added because of
    # outputImpliedClosingLine=True. This is redundant but not incorrect,
    # as the number of points is the same in both.
    if (contour and contour[-1][0] == "closePath" and contour[1][0] == "lineTo"
            and contour[1][1] != contour[0][1]):
        expected = expected[:-1] + [("lineTo", contour[0][1])] + expected[-1:]

    assert recpen.value == expected
Esempio n. 4
0
 def getReversePen(self):
     adapterPen = PointToSegmentPen(self.otherPen)
     reversePen = ReverseContourPointPen(adapterPen)
     return SegmentToPointPen(reversePen)