From f24e70dc91544c5f704be67cce5b081d307a096e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 22 Oct 2023 23:45:10 +0200 Subject: [PATCH] Fixed maximal lines angle check --- src/map/textpathitem.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/map/textpathitem.cpp b/src/map/textpathitem.cpp index bc9c3c27..c568963e 100644 --- a/src/map/textpathitem.cpp +++ b/src/map/textpathitem.cpp @@ -235,6 +235,12 @@ static bool reverse(const QPainterPath &path) return (angle > 90 && angle < 270) ? true : false; } +static qreal diff(qreal a1, qreal a2) +{ + qreal d = qAbs(a1 - a2); + return (d > 180) ? 360 - d : d; +} + template static QPainterPath textPath(const T &path, qreal textWidth, qreal charWidth, const QRectF &tileRect) @@ -254,11 +260,16 @@ static QPainterPath textPath(const T &path, qreal textWidth, qreal charWidth, qreal sl = l.length(); qreal a = l.angle(); - if ((sl < charWidth) || (j > 1 && qAbs(angle - a) > MAX_ANGLE)) { + 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) > MAX_ANGLE) { + if (length > textWidth) + return subpath(pl, last, j - 1, length - textWidth); + last = j - 1; + length = sl; } else length += sl;