]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/fontenum.cpp
delay setting the window shape until it is realized (slightly modified patch 1935497)
[wxWidgets.git] / src / unix / fontenum.cpp
index 3f4f7ae079add0e63456c3a515a75bb660068c86..b7a026e5b6ce71837f808a776574808586fa1b92 100644 (file)
 // 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"
 
@@ -55,62 +58,50 @@ 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<n_families; i++)
-        {
-#if defined(__WXGTK24__) || defined(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE)
-            if (!fixedWidthOnly || (
-#ifdef __WXGTK24__
-                !gtk_check_version(2,4,0) &&
-#endif
-                pango_font_family_is_monospace(families[i])
-                                   ) )
+    for ( int i = 0; i < n_families; i++ )
+    {
+#if defined(__WXGTK20__) || defined(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE)
+        if ( !fixedWidthOnly ||
+            pango_font_family_is_monospace(families[i]) )
 #endif
-            {
-                const gchar *name = pango_font_family_get_name(families[i]);
-                OnFacename(wxString(name, wxConvUTF8));
-            }
+        {
+            const gchar *name = pango_font_family_get_name(families[i]);
+            OnFacename(wxString(name, wxConvUTF8));
         }
-        g_free(families);
     }
+    g_free(families);
 
     return true;
 }
 
-bool wxFontEnumerator::EnumerateEncodings(const wxString& family)
+bool wxFontEnumerator::EnumerateEncodings(const wxString& facename)
 {
-    return false;
+    return EnumerateEncodingsUTF8(facename);
 }
 
 
-#else
-  // Pango
+#else // !wxUSE_PANGO
 
 #ifdef __VMS__ // Xlib.h for VMS is not (yet) compatible with C++
                // The resulting warnings are switched off here
@@ -197,6 +188,7 @@ static bool ProcessFamiliesFromFontList(wxFontEnumerator *This,
             continue;
         }
 
+        // coverity[returned_null]
         char *dash = strchr(font + 1, '-');
         char *family = dash + 1;
         dash = strchr(family, '-');
@@ -353,3 +345,5 @@ bool wxFontEnumerator::EnumerateEncodings(const wxString& family)
 }
 
 #endif // !wxUSE_PANGO
+
+#endif // wxUSE_FONTENUM