From 8b3df6cee43fe38cdab6eec2c19288bf77d05db9 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 21 Aug 2025 21:24:46 +0200 Subject: [PATCH] Remove incorrect FromDIP from wxSVGFileDC Input for wxDC functions and constructor are in DPI-independent pixels, so no scaling should be performed. This ensures the SVG will get the same size on every platform. --- src/common/dcsvg.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index 272485e118..33d6cd0bcd 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -24,7 +24,6 @@ #include "wx/filename.h" #include "wx/mstream.h" #include "wx/scopedarray.h" -#include "wx/display.h" #include "wx/private/rescale.h" #if wxUSE_MARKUP @@ -530,8 +529,8 @@ void wxSVGFileDCImpl::Init(const wxString& filename, int width, int height, m_gradientUniqueId = 0; - m_mm_to_pix_x = dpi / 25.4; - m_mm_to_pix_y = dpi / 25.4; + m_mm_to_pix_x = m_dpi / 25.4; + m_mm_to_pix_y = m_dpi / 25.4; m_backgroundBrush = *wxTRANSPARENT_BRUSH; m_textForegroundColour = *wxBLACK; @@ -555,14 +554,12 @@ void wxSVGFileDCImpl::Init(const wxString& filename, int width, int height, else m_outfile.reset(new wxFileOutputStream(m_filename)); - const wxSize dpiSize = FromDIP(wxSize(m_width, m_height)); - wxString s; s += wxS("\n"); s += wxS("\n\n"); s += wxS("\n"), - NumStr(m_width / dpi * 2.54), NumStr(m_height / dpi * 2.54), dpiSize.GetWidth(), dpiSize.GetHeight()); + NumStr(m_width / m_dpi * 2.54), NumStr(m_height / m_dpi * 2.54), m_width, m_height); s += wxString::Format(wxS("%s\n"), title); s += wxString(wxS("Picture generated by wxSVG ")) + wxSVGVersion + wxS("\n\n"); s += wxS("\n"); @@ -597,14 +594,12 @@ wxSize wxSVGFileDCImpl::GetPPI() const wxSize wxSVGFileDCImpl::FromDIP(const wxSize& sz) const { - const wxSize baseline = wxDisplay::GetStdPPI(); - return wxRescaleCoord(sz).From(baseline).To(SVG_DPI); + return sz; } wxSize wxSVGFileDCImpl::ToDIP(const wxSize& sz) const { - const wxSize baseline = wxDisplay::GetStdPPI(); - return wxRescaleCoord(sz).From(SVG_DPI).To(baseline); + return sz; } void wxSVGFileDCImpl::Clear() @@ -612,8 +607,7 @@ void wxSVGFileDCImpl::Clear() { wxDCBrushChanger setBackground(*GetOwner(), m_backgroundBrush); wxDCPenChanger setTransp(*GetOwner(), *wxTRANSPARENT_PEN); - const wxSize dpiSize = FromDIP(wxSize(m_width, m_height)); - DoDrawRectangle(0, 0, dpiSize.GetWidth(), dpiSize.GetHeight()); + DoDrawRectangle(0, 0, m_width, m_height); } NewGraphicsIfNeeded();