def addShapeInGlyphForPoint(self, glyph, point): w = h = self.size if self.useGrid: x = int(floor(point.x / float(w))) * w y = int(floor(point.y / float(h))) * h else: x = point.x - w*.5 y = point.y - h*.5 pen = glyph.getPointPen() if glyph.preferedSegmentType == "qcurve": pen = ReverseContourPointPen(pen) if self.drawingMode == RECT_MODE: pen.beginPath() pen.addPoint(_roundPoint(x, y), "line") pen.addPoint(_roundPoint(x + w, y), "line") pen.addPoint(_roundPoint(x + w, y + h), "line") pen.addPoint(_roundPoint(x, y + h), "line") pen.endPath() elif self.drawingMode == OVAL_MODE: hw = w/2. hh = h/2. r = .55 segmentType = glyph.preferedSegmentType if glyph.preferedSegmentType == "qcurve": r = .42 pen.beginPath() pen.addPoint(_roundPoint(x + hw, y), segmentType) pen.addPoint(_roundPoint(x + hw + hw*r, y)) pen.addPoint(_roundPoint(x + w, y + hh - hh*r)) pen.addPoint(_roundPoint(x + w, y + hh), segmentType) pen.addPoint(_roundPoint(x + w, y + hh + hh*r)) pen.addPoint(_roundPoint(x + hw + hw*r, y + h)) pen.addPoint(_roundPoint(x + hw, y + h), segmentType) pen.addPoint(_roundPoint(x + hw - hw*r, y + h)) pen.addPoint(_roundPoint(x, y + hh + hh*r)) pen.addPoint(_roundPoint(x, y + hh), segmentType) pen.addPoint(_roundPoint(x, y + hh - hh*r)) pen.addPoint(_roundPoint(x + hw - hw*r, y)) pen.endPath() elif self.drawingMode == COMPONENT_MODE and self.componentName and self.componentName != glyph.name: pen.addComponent(self.componentName, [1, 0, 0, 1, x, y])
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)