]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/font.cpp
Correct form of mnemonics returned by wxGTK wxMenu::GetTitle().
[wxWidgets.git] / src / msw / font.cpp
index 499478eace27028413d28f05f6c90f205407d996..0acbf1aae6d91a57ed117c4624abf0e3ec0dea0e 100644 (file)
@@ -663,6 +663,10 @@ void wxNativeFontInfo::SetFamily(wxFontFamily family)
         case wxFONTFAMILY_DEFAULT:
             ff_family = FF_SWISS;
             break;
+
+        case wxFONTFAMILY_UNKNOWN:
+            wxFAIL_MSG( "invalid font family" );
+            return;
     }
 
     wxCHECK_RET( ff_family != FF_DONTCARE, "unknown wxFontFamily" );
@@ -1012,10 +1016,8 @@ bool wxFont::IsUsingSizeInPixels() const
     return M_FONTDATA->IsUsingSizeInPixels();
 }
 
-wxFontFamily wxFont::GetFamily() const
+wxFontFamily wxFont::DoGetFamily() const
 {
-    wxCHECK_MSG( IsOk(), wxFONTFAMILY_MAX, wxT("invalid font") );
-
     return M_FONTDATA->GetFamily();
 }
 
@@ -1063,10 +1065,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());
+
+    TEXTMETRIC tm;
+    if ( !::GetTextMetrics(hdc, &tm) )
+    {
+        wxLogLastError(wxT("GetTextMetrics"));
+        return false;
+    }
 
-    return pitch == FIXED_PITCH;
+    // 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);
 }