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:
@@ -275,8 +275,6 @@ wxString wxCreateBrushFill(wxBrush& brush)
|
|||||||
|
|
||||||
void wxSetScaledScreenDCFont(wxScreenDC& sDC, const wxFont& font)
|
void wxSetScaledScreenDCFont(wxScreenDC& sDC, const wxFont& font)
|
||||||
{
|
{
|
||||||
sDC.SetFont(font);
|
|
||||||
|
|
||||||
const double scale = sDC.GetContentScaleFactor();
|
const double scale = sDC.GetContentScaleFactor();
|
||||||
if ( scale > 1 )
|
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
|
// 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
|
// text does not scale linear (at least on Windows). Therefore, we scale
|
||||||
// the font size instead.
|
// the font size instead.
|
||||||
wxFont scaledFont = sDC.GetFont();
|
wxFont scaledFont = font;
|
||||||
scaledFont.SetFractionalPointSize(scaledFont.GetFractionalPointSize() / scale);
|
scaledFont.SetFractionalPointSize(scaledFont.GetFractionalPointSize() / scale);
|
||||||
sDC.SetFont(scaledFont);
|
sDC.SetFont(scaledFont);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sDC.SetFont(font);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
Reference in New Issue
Block a user