Skip to content

Commit b36fb5f

Browse files
committed
Fixed maximal lines angle check
1 parent a7b7d16 commit b36fb5f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/textpathitem.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ static QList<QPolygonF> polyLines(const QPainterPath &path, const QRectF &rect)
171171
return lines;
172172
}
173173

174+
static qreal diff(qreal a1, qreal a2)
175+
{
176+
qreal d = qAbs(a1 - a2);
177+
return (d > 180) ? 360 - d : d;
178+
}
179+
174180
static QPainterPath textPath(const QPainterPath &path, qreal textWidth,
175181
qreal maxAngle, qreal charWidth, const QRectF &tileRect)
176182
{
@@ -189,11 +195,16 @@ static QPainterPath textPath(const QPainterPath &path, qreal textWidth,
189195
qreal sl = l.length();
190196
qreal a = l.angle();
191197

192-
if ((sl < charWidth) || (j > 1 && qAbs(angle - a) > maxAngle)) {
198+
if (sl < charWidth) {
193199
if (length > textWidth)
194200
return subpath(pl, last, j - 1, length - textWidth);
195201
last = j;
196202
length = 0;
203+
} else if (j > 1 && diff(angle, a) > maxAngle) {
204+
if (length > textWidth)
205+
return subpath(pl, last, j - 1, length - textWidth);
206+
last = j - 1;
207+
length = sl;
197208
} else
198209
length += sl;
199210

0 commit comments

Comments
 (0)