diff options
author | Wladimir Leuschner <wladimir.leuschner@qt.io> | 2024-03-19 14:40:46 +0100 |
---|---|---|
committer | Wladimir Leuschner <wladimir.leuschner@qt.io> | 2024-03-21 14:02:24 +0100 |
commit | 3ca87bcb8385a968ee4b7d77e3736dfb40ef70f7 (patch) | |
tree | 6bd9808ca7103fdb17b270930945068e31e0358b /src | |
parent | 863929f44639203c6678ca0f1a16e69e2d941cf0 (diff) |
Draw solid line if all elements in stroke-dasharray are zero
Rendering a line with stroke-dasharray that only contains zeroes as
elements produces a solid line in modern browsers, whereas QtSvg does
not draw a line at all. An additional check whether all elements in
stroke-dasharray are zero was added and in this case the line is forced
to be drawn solid
Fixes: QTBUG-123178
Change-Id: I5c00aaf49f887dc31cec4770010fba0c23e2e872
Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/svg/qsvghandler.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 666865c..28a6fe5 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -1231,10 +1231,24 @@ static void parsePen(QSvgNode *node, QString dashArray = attributes.strokeDashArray.toString(); const QChar *s = dashArray.constData(); QList<qreal> dashes = parseNumbersList(s); - // if the dash count is odd the dashes should be duplicated - if ((dashes.size() & 1) != 0) - dashes << QList<qreal>(dashes); - prop->setDashArray(dashes); + bool allZeroes = true; + for (qreal dash : dashes) { + if (dash != 0.0) { + allZeroes = false; + break; + } + } + + // if the stroke dash array contains only zeros, + // force drawing of solid line. + if (allZeroes == false) { + // if the dash count is odd the dashes should be duplicated + if ((dashes.size() & 1) != 0) + dashes << QList<qreal>(dashes); + prop->setDashArray(dashes); + } else { + prop->setDashArrayNone(); + } } } |