From b36fb5fa9272d56d342a9d6793b50121b9c5ce62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 22 Oct 2023 23:53:39 +0200 Subject: [PATCH] Fixed maximal lines angle check --- src/textpathitem.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/textpathitem.cpp b/src/textpathitem.cpp index 5efc291..0fa0406 100644 --- a/src/textpathitem.cpp +++ b/src/textpathitem.cpp @@ -171,6 +171,12 @@ static QList polyLines(const QPainterPath &path, const QRectF &rect) 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, qreal maxAngle, qreal charWidth, const QRectF &tileRect) { @@ -189,11 +195,16 @@ static QPainterPath textPath(const QPainterPath &path, qreal textWidth, qreal sl = l.length(); qreal a = l.angle(); - if ((sl < charWidth) || (j > 1 && qAbs(angle - a) > maxAngle)) { + if (sl < charWidth) { if (length > textWidth) return subpath(pl, last, j - 1, length - textWidth); last = j; 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 length += sl;