diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-03-05 15:59:01 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-03-08 16:15:52 (GMT) |
commit | 7b500ed543bb86429ef6fdb82b103784d6cc6a0c (patch) | |
tree | dfe4b34e18551cca9f98e03f02a0ae1c2c4ad768 | |
parent | d54484122b7653ad1a96e7ef361c6250bb666f3d (diff) | |
download | Qt-7b500ed543bb86429ef6fdb82b103784d6cc6a0c.zip Qt-7b500ed543bb86429ef6fdb82b103784d6cc6a0c.tar.gz Qt-7b500ed543bb86429ef6fdb82b103784d6cc6a0c.tar.bz2 |
Fixed vector-effect property output from QSvgGenerator.
The vector-effect property is not inherited by default, so it
must be set on each item with a stroke. It is not sufficient
to set it on G nodes.
Task-number: QTBUG-8733
Reviewed-by: Trond
-rw-r--r-- | src/svg/qsvggenerator.cpp | 27 | ||||
-rw-r--r-- | tests/auto/qsvggenerator/referenceSvgs/fileName_output.svg | 6 | ||||
-rw-r--r-- | tests/auto/qsvggenerator/referenceSvgs/radial_gradient.svg | 10 |
3 files changed, 19 insertions, 24 deletions
diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp index 4a8fc0b..cb9086c 100644 --- a/src/svg/qsvggenerator.cpp +++ b/src/svg/qsvggenerator.cpp @@ -310,7 +310,6 @@ public: { *d_func()->stream << QLatin1String("fill=\"none\" "); *d_func()->stream << QLatin1String("stroke=\"black\" "); - *d_func()->stream << QLatin1String("vector-effect=\"non-scaling-stroke\" "); *d_func()->stream << QLatin1String("stroke-width=\"1\" "); *d_func()->stream << QLatin1String("fill-rule=\"evenodd\" "); *d_func()->stream << QLatin1String("stroke-linecap=\"square\" "); @@ -380,13 +379,10 @@ public: break; } - if (spen.widthF() == 0) { - width = QLatin1String("1"); - stream() << "vector-effect=\"non-scaling-stroke\" "; - } + if (spen.widthF() == 0) + stream() <<"stroke-width=\"1\" "; else - width = QString::number(spen.widthF()); - stream() <<"stroke-width=\""<<width<<"\" "; + stream() <<"stroke-width=\"" << spen.widthF() << "\" "; switch (spen.capStyle()) { case Qt::FlatCap: @@ -983,14 +979,11 @@ void QSvgPaintEngine::drawPath(const QPainterPath &p) { Q_D(QSvgPaintEngine); - *d->stream << "<path " - "fill-rule="; - if (p.fillRule() == Qt::OddEvenFill) - *d->stream << "\"evenodd\" "; - else - *d->stream << "\"nonzero\" "; - - *d->stream << "d=\""; + *d->stream << "<path vector-effect=\"" + << (state->pen().isCosmetic() ? "non-scaling-stroke" : "none") + << "\" fill-rule=\"" + << (p.fillRule() == Qt::OddEvenFill ? "evenodd" : "nonzero") + << "\" d=\""; for (int i=0; i<p.elementCount(); ++i) { const QPainterPath::Element &e = p.elementAt(i); @@ -1038,7 +1031,9 @@ void QSvgPaintEngine::drawPolygon(const QPointF *points, int pointCount, path.lineTo(points[i]); if (mode == PolylineMode) { - stream() << "<polyline fill=\"none\" points=\""; + stream() << "<polyline fill=\"none\" vector-effect=\"" + << (state->pen().isCosmetic() ? "non-scaling-stroke" : "none") + << "\" points=\""; for (int i = 0; i < pointCount; ++i) { const QPointF &pt = points[i]; stream() << pt.x() << ',' << pt.y() << ' '; diff --git a/tests/auto/qsvggenerator/referenceSvgs/fileName_output.svg b/tests/auto/qsvggenerator/referenceSvgs/fileName_output.svg index 99926b3..f1f9e35 100644 --- a/tests/auto/qsvggenerator/referenceSvgs/fileName_output.svg +++ b/tests/auto/qsvggenerator/referenceSvgs/fileName_output.svg @@ -4,12 +4,12 @@ <desc>Generated with Qt</desc> <defs> </defs> -<g fill="none" stroke="black" vector-effect="non-scaling-stroke" stroke-width="1" fill-rule="evenodd" stroke-linecap="square" stroke-linejoin="bevel" > +<g fill="none" stroke="black" stroke-width="1" fill-rule="evenodd" stroke-linecap="square" stroke-linejoin="bevel" > <g fill="#ff0000" fill-opacity="1" stroke="none" transform="matrix(1,0,0,1,0,0)" -font-family="Arial" font-size="11pt" font-weight="400" font-style="normal" +font-family="Sans Serif" font-size="8.25" font-weight="400" font-style="normal" > -<path fill-rule="evenodd" d="M0,0 L100,0 L100,100 L0,100 L0,0"/> +<path vector-effect="non-scaling-stroke" fill-rule="evenodd" d="M0,0 L100,0 L100,100 L0,100 L0,0"/> </g> </g> </svg> diff --git a/tests/auto/qsvggenerator/referenceSvgs/radial_gradient.svg b/tests/auto/qsvggenerator/referenceSvgs/radial_gradient.svg index f61dd40..84afbf3 100644 --- a/tests/auto/qsvggenerator/referenceSvgs/radial_gradient.svg +++ b/tests/auto/qsvggenerator/referenceSvgs/radial_gradient.svg @@ -13,18 +13,18 @@ <stop offset="1" stop-color="#0000ff" stop-opacity="1" /> </radialGradient> </defs> -<g fill="none" stroke="black" vector-effect="non-scaling-stroke" stroke-width="1" fill-rule="evenodd" stroke-linecap="square" stroke-linejoin="bevel" > +<g fill="none" stroke="black" stroke-width="1" fill-rule="evenodd" stroke-linecap="square" stroke-linejoin="bevel" > <g fill="url(#gradient1)" stroke="none" transform="matrix(1,0,0,1,0,0)" -font-family="Sans Serif" font-size="9pt" font-weight="400" font-style="normal" +font-family="Sans Serif" font-size="8.25" font-weight="400" font-style="normal" > -<path fill-rule="evenodd" d="M0,0 L100,0 L100,100 L0,100 L0,0"/> +<path vector-effect="non-scaling-stroke" fill-rule="evenodd" d="M0,0 L100,0 L100,100 L0,100 L0,0"/> </g> <g fill="url(#gradient2)" stroke="none" transform="matrix(1,0,0,1,0,0)" -font-family="Sans Serif" font-size="9pt" font-weight="400" font-style="normal" +font-family="Sans Serif" font-size="8.25" font-weight="400" font-style="normal" > -<path fill-rule="evenodd" d="M100,0 L200,0 L200,100 L100,100 L100,0"/> +<path vector-effect="non-scaling-stroke" fill-rule="evenodd" d="M100,0 L200,0 L200,100 L100,100 L100,0"/> </g> </g> </svg> |