From dcf45475ba18b1c1ff50eddcfba1839ffe824054 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20T=C5=AFma?= Date: Tue, 1 Aug 2023 23:21:49 +0200 Subject: [PATCH] Show the arrows even when no label is set --- src/map/IMG/rastertile.cpp | 12 +++++++----- src/map/textpathitem.cpp | 9 ++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/map/IMG/rastertile.cpp b/src/map/IMG/rastertile.cpp index 02a7616c..a7e35a2f 100644 --- a/src/map/IMG/rastertile.cpp +++ b/src/map/IMG/rastertile.cpp @@ -320,9 +320,6 @@ void RasterTile::processStreetNames(const QList &lines, if (style.img().isNull() && style.foreground() == Qt::NoPen) continue; - if (poly.label.text().isEmpty() - || style.textFontSize() == Style::None) - continue; const QFont *fnt = font(style.textFontSize(), Style::Small); const QColor *color = style.textColor().isValid() @@ -331,9 +328,14 @@ void RasterTile::processStreetNames(const QList &lines, const QImage *img = poly.oneway ? Style::isWaterLine(poly.type) ? &waterArrow : &arrow : 0; + const QString *label = poly.label.text().isEmpty() + ? 0 : &poly.label.text(); + + if (!img && (!label || !fnt)) + continue; - TextPathItem *item = new TextPathItem(poly.points, - &poly.label.text(), _rect, fnt, color, hColor, img); + TextPathItem *item = new TextPathItem(poly.points, label, _rect, fnt, + color, hColor, img); if (item->isValid() && !item->collides(textItems)) textItems.append(item); else { diff --git a/src/map/textpathitem.cpp b/src/map/textpathitem.cpp index a811d450..23499be2 100644 --- a/src/map/textpathitem.cpp +++ b/src/map/textpathitem.cpp @@ -263,12 +263,15 @@ template void TextPathItem::init(const T &line, const QRect &tileRect) { qreal cw, mw, textWidth; + bool label = _text && _font; - if (_text && _img) { + Q_ASSERT(label || _img); + + if (label && _img) { cw = _font->pixelSize() * CHAR_RATIO; mw = _font->pixelSize() / 2.0; textWidth = _text->size() * cw + _img->width() + PADDING; - } else if (_text) { + } else if (label) { cw = _font->pixelSize() * CHAR_RATIO; mw = _font->pixelSize() / 2.0; textWidth = _text->size() * cw; @@ -328,7 +331,7 @@ void TextPathItem::paint(QPainter *painter) const painter->restore(); } - if (_text) { + if (_text && _font) { QFontMetrics fm(*_font); int textWidth = fm.boundingRect(*_text).width(); int imgWidth = _img ? _img->width() + PADDING : 0; -- 2.11.4.GIT