Always set the font to use in wxMSW wxTextMeasure when using a window.

The default window HDC font is not the same as the wxWindow font, so we need
to always set the font explicitly in this case (when using a wxDC, its HDC
does have the current wxDC font already selected into it, so doing it once
again would be unnecessarily wasteful).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72845 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-11-01 17:15:19 +00:00
parent e0da9e871a
commit d78aa51b17

View File

@@ -69,8 +69,12 @@ void wxTextMeasure::BeginMeasuring()
m_hdc = ::GetDC(GetHwndOf(m_win));
}
if ( m_font )
m_hfontOld = (HFONT)::SelectObject(m_hdc, GetHfontOf(*m_font));
// We need to set the font if it's explicitly specified, of course, but
// also if we're associated with a window because the window HDC created
// above has the default font selected into it and not the font of the
// window.
if ( m_font || m_win )
m_hfontOld = (HFONT)::SelectObject(m_hdc, GetHfontOf(GetFont()));
}
void wxTextMeasure::EndMeasuring()