From e489a325769d295ee3b3948d98f5d07814dffd97 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 12 Nov 2019 22:10:34 +0100 Subject: Re-fix scaling when rendering a specific element by id This is a modification of 14fa4591eb34a35cf3d485fd901e3f1e2caa7770 That patch corrected the handling of the view box when rendering an entire SVG document. However, contrary to intention stated in the comment of that patch, it turns out that the new viewbox handling code path can be taken also for the case of rendering only a single element by id. Instead, we want to keep the original behavior where the element's origin bounds are transformed to fit into the user requested target bounds, allowing non-proportional scaling. Since the render-single-element case is easily and uniqely identifiable by the sourceRect parameter being non-null, just add an explicit check for that to the code path branching. Done-with: Eirik Aavitsland Fixes: QTBUG-79933 Change-Id: I64a35bbb193db22c33670b48ea165a91df8e719e Reviewed-by: Simon Hausmann --- src/svg/qsvgtinydocument.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp index a2bf1c7..56960bf 100644 --- a/src/svg/qsvgtinydocument.cpp +++ b/src/svg/qsvgtinydocument.cpp @@ -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()); -- cgit v1.2.1