]> git.saurik.com Git - wxWidgets.git/commitdiff
[wxGTK2] Return wxTELETYPE with GetFamily() for monospaced fonts, fixing IsFixedWidth...
authorMart Raudsepp <leio@gentoo.org>
Mon, 22 Aug 2005 20:42:03 +0000 (20:42 +0000)
committerMart Raudsepp <leio@gentoo.org>
Mon, 22 Aug 2005 20:42:03 +0000 (20:42 +0000)
after get accessor changes, and returning the right thing in GetFamily() in this case. Other families TODO.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35268 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/unix/fontutil.cpp

index 2a7ad2ea3c00198f5a66013d7c8a2382300dad66..08e33a21c1453a73022d5cf103c89d45c8f35026 100644 (file)
@@ -45,6 +45,7 @@
 
 #ifdef __WXGTK20__
 #include "wx/gtk/private.h"
+extern GtkWidget *wxGetRootWindow();
 #else
 #include "wx/x11/private.h"
 #endif
@@ -137,6 +138,42 @@ wxString wxNativeFontInfo::GetFaceName() const
 
 wxFontFamily wxNativeFontInfo::GetFamily() const
 {
+#ifndef HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
+    if (g_ascii_strcasecmp( pango_font_description_get_family( description ), "monospace" ) == 0)
+        return wxFONTFAMILY_TELETYPE;
+#else
+
+    PangoFontFamily **families;
+    PangoFontFamily  *family;
+    int n_families;
+    pango_context_list_families(
+#ifdef __WXGTK20__
+            gtk_widget_get_pango_context( wxGetRootWindow() ),
+#else
+            wxTheApp->GetPangoContext(),
+#endif
+            &families, &n_families);
+
+    for (int i = 0;i < n_families;++i)
+    {
+        if (g_ascii_strcasecmp(pango_font_family_get_name( families[i] ), pango_font_description_get_family( description )) == 0 )
+        {
+            family = families[i];
+            break;
+        }
+    }
+
+    g_free(families);
+
+    wxASSERT_MSG( family, wxT("wxNativeFontInfo::GetFamily() - No appropriate PangoFontFamily found for ::description") );
+
+    //BCI: Cache the wxFontFamily inside the class. Validate cache with
+    //BCI: g_ascii_strcasecmp(pango_font_description_get_family(description), pango_font_family_get_name(family)) == 0
+
+    if (pango_font_family_is_monospace( family ))
+        return wxFONTFAMILY_TELETYPE;
+#endif // pango_font_family_is_monospace
+
     return wxFONTFAMILY_SWISS;
 }