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:
Václav Slavík
2020-08-27 15:49:48 +02:00
committed by Vadim Zeitlin
parent 9e68df224f
commit 8efc6fb003
6 changed files with 21 additions and 10 deletions

View File

@@ -120,7 +120,11 @@ public:
virtual bool IsFixedWidth() const wxOVERRIDE;
virtual void WXAdjustToPPI(const wxSize& ppi) wxOVERRIDE;
// MSW needs to modify the font object when the DPI of the window it
// is used with changes, this function can be used to do it.
//
// This method is not considered to be part of wxWidgets public API.
void WXAdjustToPPI(const wxSize& ppi);
wxDEPRECATED_MSG("use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants ie: wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD")
wxFont(int size,