Adjust the font size when DPI of window changes

This commit is contained in:
Vadim Zeitlin
2018-12-30 01:06:19 +01:00
committed by Maarten Bent
parent e3d3a0b7e8
commit e563d4858a
6 changed files with 48 additions and 1 deletions

View File

@@ -4837,6 +4837,17 @@ wxSize wxWindowMSW::GetDPI() const
return dpi;
}
void wxWindowMSW::MSWUpdateFontOnDPIChange(const wxSize& newDPI)
{
if ( m_font.IsOk() )
{
m_font.WXAdjustToPPI(newDPI);
// WXAdjustToPPI() changes the HFONT, so reassociate it with the window.
wxSetWindowFont(GetHwnd(), m_font);
}
}
// Helper function to update the given coordinate by the scaling factor if it
// is set, i.e. different from wxDefaultCoord.
static void ScaleCoordIfSet(int& coord, float scaleFactor)
@@ -4861,6 +4872,9 @@ wxWindowMSW::MSWUpdateOnDPIChange(const wxSize& oldDPI, const wxSize& newDPI)
InvalidateBestSize();
// update font if necessary
MSWUpdateFontOnDPIChange(newDPI);
// update children
wxWindowList::compatibility_iterator current = GetChildren().GetFirst();
while ( current )