summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-11-16 03:01:30 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-11-16 03:01:30 +0100
commit64841de96485d5dfd7c24c052626bff6a953bca3 (patch)
treef65badaf28508cff0e27990ce8d3ed9ece8a9baf /src
parentf35b26751c7320868e56c3fbe1b5d5d7a55ed239 (diff)
parente489a325769d295ee3b3948d98f5d07814dffd97 (diff)
downloadqtsvg-64841de96485d5dfd7c24c052626bff6a953bca3.tar.gz
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I6d5d6b486fbd7d0d9324937e24edff2890f02bdf
Diffstat (limited to 'src')
-rw-r--r--src/svg/qsvgtinydocument.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp
index 3143ad2..56960bf 100644
--- a/src/svg/qsvgtinydocument.cpp
+++ b/src/svg/qsvgtinydocument.cpp
@@ -338,7 +338,7 @@ void QSvgTinyDocument::setHeight(int len, bool percent)
void QSvgTinyDocument::setViewBox(const QRectF &rect)
{
m_viewBox = rect;
- m_implicitViewBox = false;
+ m_implicitViewBox = rect.isNull();
}
void QSvgTinyDocument::addSvgFont(QSvgFont *font)
@@ -420,7 +420,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
source = viewBox();
if (source != target && !source.isNull()) {
- if (m_implicitViewBox) {
+ if (m_implicitViewBox || !sourceRect.isNull()) {
+ // Code path used when no view box is set, or when an explicit source size is given which
+ // overrides it (which is the case when we're rendering only a specific element by id).
QTransform transform;
transform.scale(target.width() / source.width(),
target.height() / source.height());
@@ -434,10 +436,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 +446,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());
}
}
}