0
  1. With Qt, if you use QPainter.drawText() you can pass a string of characters you want to draw and coordinates of the bounding rect as argument. However when drawing a path with QPainter.drawPath() you can't just specify a bounding rect or coordinates the path should fit in.
    Is there a built-in method of QPainterPath to make it fit inside a bounding rect or coordinates? Or do I have to program the appropriate translation and scaling manually?

  2. Also, how do I create a QPixmap from a QPainterPath of a given size?

What I'm trying to do: I have a font object which hosts vector coordinates and would like to draw its glyphs. I already have a function that creates a QPainterPath() from the Font object. It's for a font editor.

Thanks for stepping-by.

Andy
  • 49,085
  • 60
  • 166
  • 233
blameless75
  • 2,148
  • 2
  • 19
  • 14

1 Answers1

0

Well, answering myself for the first part of the question: it's not the path that should be changed but the painter, you can save its state then translate,scale it etc... then draw your path and restore its state afterwards. E.g.:

            painter.save()
            painter.translate(0,-self.squareSize)
            painter.scale(factor, -factor)
            painter.fillPath(glyph, Qt.black)
            painter.restore()
blameless75
  • 2,148
  • 2
  • 19
  • 14
  • Can you elaborate and explain about this? My red `Qpainterpath` should appear at the 10th day rect, but I don't get how to get it inside: https://image.prntscr.com/image/28ogDnFJR-yQ4u3xXELA3g.png – Saelyth Dec 10 '18 at 09:58