X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/40a0dc1b0ef54d5068d15609924617ce5e5a744f..9db177273906bb393b97b4a98f6a8b4d61e8f0e3:/src/unix/fontenum.cpp diff --git a/src/unix/fontenum.cpp b/src/unix/fontenum.cpp index a72dfdf81e..90a63d4a7c 100644 --- a/src/unix/fontenum.cpp +++ b/src/unix/fontenum.cpp @@ -20,16 +20,19 @@ // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_FONTENUM + +#include "wx/fontenum.h" + #ifndef WX_PRECOMP #include "wx/dynarray.h" + #include "wx/string.h" + #include "wx/app.h" + #include "wx/utils.h" #endif -#include "wx/string.h" #include "wx/regex.h" -#include "wx/utils.h" -#include "wx/app.h" #include "wx/fontmap.h" -#include "wx/fontenum.h" #include "wx/fontutil.h" #include "wx/encinfo.h" @@ -46,7 +49,9 @@ extern GtkWidget *wxGetRootWindow(); #endif // __WXGTK20__ -extern "C" int wxCMPFUNC_CONV +extern "C" +{ +static int wxCMPFUNC_CONV wxCompareFamilies (const void *a, const void *b) { const char *a_name = pango_font_family_get_name (*(PangoFontFamily **)a); @@ -54,63 +59,52 @@ wxCompareFamilies (const void *a, const void *b) return g_utf8_collate (a_name, b_name); } +} -// I admit I don't yet understand encodings with Pango bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding, bool fixedWidthOnly) { -#if defined(__WXGTK20__) || !defined(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE) - if ( fixedWidthOnly -#if defined(__WXGTK24__) - && (gtk_check_version(2,4,0) != NULL) -#endif - ) -{ - OnFacename( wxT("monospace") ); - } - else -#endif // __WXGTK20__ || !HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE + if ( encoding != wxFONTENCODING_SYSTEM && encoding != wxFONTENCODING_UTF8 ) { - PangoFontFamily **families = NULL; - gint n_families = 0; - pango_context_list_families ( + // Pango supports only UTF-8 encoding (and system means any, so we + // accept it too) + return false; + } + + PangoFontFamily **families = NULL; + gint n_families = 0; + pango_context_list_families ( #ifdef __WXGTK20__ - gtk_widget_get_pango_context( wxGetRootWindow() ), + gtk_widget_get_pango_context( wxGetRootWindow() ), #else - wxTheApp->GetPangoContext(), + wxTheApp->GetPangoContext(), #endif - &families, &n_families ); - qsort (families, n_families, sizeof (PangoFontFamily *), wxCompareFamilies); + &families, &n_families ); + qsort (families, n_families, sizeof (PangoFontFamily *), wxCompareFamilies); - for (int i=0; i