Avoid calling wxScreenDC::SetFont() more than once

This seems unnecessary when we can call it only once even with high DPI
screens.
This commit is contained in:
Vadim Zeitlin
2019-08-09 23:39:23 +02:00
parent f3adef1047
commit c91c94ab0e

View File

@@ -275,8 +275,6 @@ wxString wxCreateBrushFill(wxBrush& brush)
void wxSetScaledScreenDCFont(wxScreenDC& sDC, const wxFont& font)
{
sDC.SetFont(font);
const double scale = sDC.GetContentScaleFactor();
if ( scale > 1 )
{
@@ -287,10 +285,14 @@ void wxSetScaledScreenDCFont(wxScreenDC& sDC, const wxFont& font)
// We can't just divide the returned sizes by the scale factor, because
// text does not scale linear (at least on Windows). Therefore, we scale
// the font size instead.
wxFont scaledFont = sDC.GetFont();
wxFont scaledFont = font;
scaledFont.SetFractionalPointSize(scaledFont.GetFractionalPointSize() / scale);
sDC.SetFont(scaledFont);
}
else
{
sDC.SetFont(font);
}
}
} // anonymous namespace