summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/svg/qsvgtinydocument.cpp8
-rw-r--r--tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp3
2 files changed, 5 insertions, 6 deletions
diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp
index 3143ad2..7e35508 100644
--- a/src/svg/qsvgtinydocument.cpp
+++ b/src/svg/qsvgtinydocument.cpp
@@ -434,10 +434,6 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
// but the entire document. This attempts to emulate the default values of the <preserveAspectRatio>
// tag that's implicitly defined when <viewbox> is used.
- // Apply the view box translation if specified.
- p->translate(target.x() - source.x(),
- target.y() - source.y());
-
// Scale the view box into the view port (target) by preserve the aspect ratio.
QSizeF viewBoxSize = source.size();
viewBoxSize.scale(target.width(), target.height(), Qt::KeepAspectRatio);
@@ -448,6 +444,10 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
p->scale(viewBoxSize.width() / source.width(),
viewBoxSize.height() / source.height());
+
+ // Apply the view box translation if specified.
+ p->translate(target.x() - source.x(),
+ target.y() - source.y());
}
}
}
diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
index cf19213..eb3ecba 100644
--- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
@@ -269,14 +269,13 @@ void tst_QSvgRenderer::testMapViewBoxToTarget()
}
{ // Viewport and viewBox specified -> scale 500x500 square to 1000x750 while preserving aspect ratio gives 750x750
- // however the box is centered at 375, 250
data = "<svg width=\"1000\" height=\"750\" viewBox=\"-250 -250 500 500\"><g><rect x=\"0\" y=\"0\" width=\"500\" height=\"500\" /></g></svg>";
QPicture picture;
QPainter painter(&picture);
QSvgRenderer rend(data);
rend.render(&painter);
painter.end();
- QCOMPARE(picture.boundingRect(), QRect(375, 250, 750, 750));
+ QCOMPARE(picture.boundingRect(), QRect(500, 375, 750, 750));
}
}