X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a4a0bff1662e9c729e95baf12082aa6144df48c8..e19dbcf76b35cabe9487926b3a96d69c7f949d64:/src/msw/font.cpp diff --git a/src/msw/font.cpp b/src/msw/font.cpp index 3add9ac4cc..b1e347d674 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -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); }