qtPen.py 634 B

1234567891011121314151617181920212223242526272829
  1. from fontTools.pens.basePen import BasePen
  2. __all__ = ["QtPen"]
  3. class QtPen(BasePen):
  4. def __init__(self, glyphSet, path=None):
  5. BasePen.__init__(self, glyphSet)
  6. if path is None:
  7. from PyQt5.QtGui import QPainterPath
  8. path = QPainterPath()
  9. self.path = path
  10. def _moveTo(self, p):
  11. self.path.moveTo(*p)
  12. def _lineTo(self, p):
  13. self.path.lineTo(*p)
  14. def _curveToOne(self, p1, p2, p3):
  15. self.path.cubicTo(*p1, *p2, *p3)
  16. def _qCurveToOne(self, p1, p2):
  17. self.path.quadTo(*p1, *p2)
  18. def _closePath(self):
  19. self.path.closeSubpath()