The following code draws text around a QPainterPath
:
QString text = "Short text";
QPainterPath rawPath;
// fill path ...
while (...)
{
double percent = ...;
double angle = rawPath.angleAtPercent(percent);
QPointF point = rawPath.pointAtPercent(percent);
m_painter.save();
m_painter.translate(point);
m_painter.rotate(-angle);
// Version 1:
//m_painter.drawText(0, 0, text.at(currentChar));
// Version 2:
QPainterPath p2;
p2.addText(0, 0, font, text.at(currentChar));
m_painter.drawPath(p2);
m_painter.restore();
}
The graphical result is as expected but the performance of both, Version 1 and Version 2 is very poor. The bottleneck is the QPainter::drawText()
respectively the QPainterPath::addText()
method. Is there a more efficient way to draw text around a path?
Regards,