Add wxWindow::WXAdjustFontToOwnPPI()
Avoid calling GeTDPI() in font.WXAdjustToPPI(GetDPI()); invocations in common code on platforms that don't need any adjustment (i.e. anything other than MSW). This fixes wxOSX crashes when GetFont() is called too early during window creation, but is the right thing to do regardless. Closes https://github.com/wxWidgets/wxWidgets/pull/2036 Closes #18903.
This commit is contained in:
committed by
Vadim Zeitlin
parent
9e68df224f
commit
8efc6fb003
@@ -1710,7 +1710,7 @@ wxFont wxWindowBase::GetFont() const
|
||||
if ( !font.IsOk() )
|
||||
font = GetClassDefaultAttributes().font;
|
||||
|
||||
font.WXAdjustToPPI(GetDPI());
|
||||
WXAdjustFontToOwnPPI(font);
|
||||
|
||||
return font;
|
||||
}
|
||||
@@ -1731,7 +1731,7 @@ bool wxWindowBase::SetFont(const wxFont& font)
|
||||
m_inheritFont = m_hasFont;
|
||||
|
||||
if ( m_hasFont )
|
||||
m_font.WXAdjustToPPI(GetDPI());
|
||||
WXAdjustFontToOwnPPI(m_font);
|
||||
|
||||
InvalidateBestSize();
|
||||
|
||||
|
||||
@@ -4864,6 +4864,11 @@ double wxWindowMSW::GetDPIScaleFactor() const
|
||||
return GetDPI().y / (double)wxDisplay::GetStdPPIValue();
|
||||
}
|
||||
|
||||
void wxWindowMSW::WXAdjustFontToOwnPPI(wxFont& font) const
|
||||
{
|
||||
font.WXAdjustToPPI(GetDPI());
|
||||
}
|
||||
|
||||
void wxWindowMSW::MSWUpdateFontOnDPIChange(const wxSize& newDPI)
|
||||
{
|
||||
if ( m_font.IsOk() )
|
||||
|
||||
Reference in New Issue
Block a user