From ae7a033cbd190c231fb565eeebc42570f7755cbf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 19 Jul 2020 19:33:53 +0200 Subject: [PATCH] Fix units produced by wxSVGFileDC after the previous commit Reimplement the logic of 16a02e6338 (Use DPI independent text size in wxSVGFileDC, 2019-08-06) without using GetContentScaleFactor(), but using wxDC::GetPPI() directly and do it under the platforms not using logical pixels only. This makes the units correct again in SVGs produced when using high DPI under MSW even although wxDC::GetContentScaleFactor() now returns 1 in this case. --- src/common/dcsvg.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index 2dcb7e5874..72be21b2c9 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -358,7 +358,13 @@ wxString CreateBrushFill(const wxBrush& brush, wxSVGShapeRenderingMode mode) void SetScaledScreenDCFont(wxScreenDC& sDC, const wxFont& font) { - const double scale = sDC.GetContentScaleFactor(); + // When using DPI-independent pixels, the results of GetTextExtent() and + // similar don't depend on DPI anyhow. +#ifndef wxHAVE_DPI_INDEPENDENT_PIXELS + static const int SVG_DPI = 96; + + const double screenDPI = sDC.GetPPI().y; + const double scale = screenDPI / SVG_DPI; if ( scale > 1 ) { // wxScreenDC uses the DPI of the main screen to determine the text @@ -373,6 +379,7 @@ void SetScaledScreenDCFont(wxScreenDC& sDC, const wxFont& font) sDC.SetFont(scaledFont); } else +#endif // !wxHAVE_DPI_INDEPENDENT_PIXELS { sDC.SetFont(font); }