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.
This commit is contained in:
Vadim Zeitlin
2022-03-19 22:30:55 +01:00
parent e9bbe21fb5
commit a00b0336a1

View File

@@ -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)