From a00b0336a1a451c2efe177fd8933405fde0847c8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 19 Mar 2022 22:30:55 +0100 Subject: [PATCH] Don't adjust the font to DPI if the window isn't created yet This is at best useless, as we can't get the correct DPI to use before the window is created anyhow. See #22193. --- src/msw/window.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index df90f28422..fcd3279269 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -4891,7 +4891,13 @@ double wxWindowMSW::GetDPIScaleFactor() const void wxWindowMSW::WXAdjustFontToOwnPPI(wxFont& font) const { - font.WXAdjustToPPI(GetDPI()); + // We don't need to adjust the font if the window hasn't been created yet, + // as our MSWUpdateFontOnDPIChange() will be called when it is created if a + // non-default DPI is used and it will be done then, so skip doing it now, + // especially because we can't get the correct DPI in GetDPI() anyhow + // without a valid HWND. + if ( GetHwnd() ) + font.WXAdjustToPPI(GetDPI()); } void wxWindowMSW::MSWUpdateFontOnDPIChange(const wxSize& newDPI)