X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/461e93f921df33c09637db5dddcfd07411ff0ded..c4e387521b7297a24e4aa016b588cf77d32d1b5f:/src/unix/fontenum.cpp diff --git a/src/unix/fontenum.cpp b/src/unix/fontenum.cpp index bc76c80086..4c5392c094 100644 --- a/src/unix/fontenum.cpp +++ b/src/unix/fontenum.cpp @@ -31,6 +31,63 @@ #include "wx/fontenum.h" #include "wx/fontutil.h" +// ---------------------------------------------------------------------------- +// GTK 2.0 +// ---------------------------------------------------------------------------- + +#ifdef __WXGTK20__ + +#include "wx/gtk/private.h" + +extern GtkWidget *wxGetRootWindow(); + +static int +cmp_families (const void *a, const void *b) +{ + const char *a_name = pango_font_family_get_name (*(PangoFontFamily **)a); + const char *b_name = pango_font_family_get_name (*(PangoFontFamily **)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 ( fixedWidthOnly ) + { + OnFacename( wxT("monospaced") ); + } + else + { + PangoFontFamily **families = NULL; + gint n_families = 0; + pango_context_list_families ( + gtk_widget_get_pango_context( wxGetRootWindow() ), + &families, &n_families ); + qsort (families, n_families, sizeof (PangoFontFamily *), cmp_families); + + for (int i=0; iGetAltForEncoding(encoding, &info); + (void)wxFontMapper::Get()->GetAltForEncoding(encoding, &info); } #endif // wxUSE_FONTMAP @@ -270,3 +327,6 @@ bool wxFontEnumerator::EnumerateEncodings(const wxString& family) #endif // wxUSE_NANOX } + +#endif + // __WXGTK20__