Fixed maximal lines angle check

This commit is contained in:
Martin Tůma 2023-10-22 23:53:39 +02:00
parent a7b7d16f4f
commit b36fb5fa92

View File

@ -171,6 +171,12 @@ static QList<QPolygonF> polyLines(const QPainterPath &path, const QRectF &rect)
return lines; return lines;
} }
static qreal diff(qreal a1, qreal a2)
{
qreal d = qAbs(a1 - a2);
return (d > 180) ? 360 - d : d;
}
static QPainterPath textPath(const QPainterPath &path, qreal textWidth, static QPainterPath textPath(const QPainterPath &path, qreal textWidth,
qreal maxAngle, qreal charWidth, const QRectF &tileRect) qreal maxAngle, qreal charWidth, const QRectF &tileRect)
{ {
@ -189,11 +195,16 @@ static QPainterPath textPath(const QPainterPath &path, qreal textWidth,
qreal sl = l.length(); qreal sl = l.length();
qreal a = l.angle(); qreal a = l.angle();
if ((sl < charWidth) || (j > 1 && qAbs(angle - a) > maxAngle)) { if (sl < charWidth) {
if (length > textWidth) if (length > textWidth)
return subpath(pl, last, j - 1, length - textWidth); return subpath(pl, last, j - 1, length - textWidth);
last = j; last = j;
length = 0; length = 0;
} else if (j > 1 && diff(angle, a) > maxAngle) {
if (length > textWidth)
return subpath(pl, last, j - 1, length - textWidth);
last = j - 1;
length = sl;
} else } else
length += sl; length += sl;