From: Mart Raudsepp Date: Mon, 22 Aug 2005 20:42:03 +0000 (+0000) Subject: [wxGTK2] Return wxTELETYPE with GetFamily() for monospaced fonts, fixing IsFixedWidth... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/38d446db26624162bef5cf577df6a6897bf95126 [wxGTK2] Return wxTELETYPE with GetFamily() for monospaced fonts, fixing IsFixedWidth() after it broke completely 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 --- diff --git a/src/unix/fontutil.cpp b/src/unix/fontutil.cpp index 2a7ad2ea3c..08e33a21c1 100644 --- a/src/unix/fontutil.cpp +++ b/src/unix/fontutil.cpp @@ -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; }