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; }