Fix wxFont::IsFixedWidth() under MSW to always return correct result.
This function worked erratically, returning the correct result or not depending on the way it was created. Reimplement it using GetTextMetrics() to get the correct result in any case. Closes #4714. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64446 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
7cfac8c83a
commit
cd49ac33b3
@ -1067,10 +1067,19 @@ bool wxFont::IsFixedWidth() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
|
||||
|
||||
// the two low-order bits specify the pitch of the font, the rest is
|
||||
// family
|
||||
BYTE pitch =
|
||||
(BYTE)(M_FONTDATA->GetNativeFontInfo().lf.lfPitchAndFamily & PITCH_MASK);
|
||||
// LOGFONT doesn't contain the correct pitch information so we need to call
|
||||
// GetTextMetrics() to get it
|
||||
ScreenHDC hdc;
|
||||
SelectInHDC selectFont(hdc, M_FONTDATA->GetHFONT());
|
||||
|
||||
return pitch == FIXED_PITCH;
|
||||
TEXTMETRIC tm;
|
||||
if ( !::GetTextMetrics(hdc, &tm) )
|
||||
{
|
||||
wxLogLastError(wxT("GetTextMetrics"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Quoting MSDN description of TMPF_FIXED_PITCH: "Note very carefully that
|
||||
// those meanings are the opposite of what the constant name implies."
|
||||
return !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user