]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/fontutil.cpp
warning fixed
[wxWidgets.git] / src / unix / fontutil.cpp
index c32a5acfbbd50bf6105b007cd89ead9d2eb2106a..8bdd44191eb31d1ed4290d4aad258d4f5a776b0c 100644 (file)
 #ifndef WX_PRECOMP
 #endif // PCH
 
+#ifdef __X__
+    #include <X11/Xlib.h>
+
+    #include "wx/utils.h"       // for wxGetDisplay()
+#elif defined(__WXGTK__)
+    #include "gdk/gdk.h"
+#endif
+
 #include "wx/fontutil.h"
 #include "wx/fontmap.h"
 #include "wx/tokenzr.h"
 
     static inline void wxFreeFont(wxNativeFont font)
     {
-        XFreeFont((Display *)wxGetDisplay(), font);
+        XFreeFont((Display *)wxGetDisplay(), (XFontStruct *)font);
     }
 #elif defined(__WXGTK__)
-    #include "gdk/gdk.h"
-
     static inline wxNativeFont wxLoadFont(const wxString& fontSpec)
     {
         return gdk_font_load( wxConvertWX2MB(fontSpec) );
@@ -178,7 +184,7 @@ bool wxGetNativeFontEncoding(wxFontEncoding encoding,
 
         case wxFONTENCODING_SYSTEM:
             info->xregistry =
-            info->xencoding = wxT('*');
+            info->xencoding = wxT("*");
             break;
 
         default:
@@ -216,20 +222,29 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
     // encoding, it's useless to do all other approximations (i.e. size,
     // family &c don't matter much)
     wxNativeEncodingInfo info;
-    if ( !wxGetNativeFontEncoding(encoding, &info) ||
-         !wxTestFontEncoding(info) )
+    if (encoding == wxFONTENCODING_SYSTEM)
+    {
+        // This will always work so we don't test to save time
+        wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info);
+    }
+    else
     {
-        if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) )
+        if ( !wxGetNativeFontEncoding(encoding, &info) ||
+             !wxTestFontEncoding(info) )
         {
-            // unspported encoding - replace it with the default
-            //
-            // NB: we can't just return 0 from here because wxGTK code doesn't
-            //     check for it (i.e. it supposes that we'll always succeed),
-            //     so it would provoke a crash
-            wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info);
-        }
+            if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) )
+            {
+                // unspported encoding - replace it with the default
+                //
+                // NB: we can't just return 0 from here because wxGTK code doesn't
+                //     check for it (i.e. it supposes that we'll always succeed),
+                //     so it would provoke a crash
+                wxGetNativeFontEncoding(wxFONTENCODING_SYSTEM, &info);
+            }
+       }
     }
-    //else: we have the correct xregistry/xencoding in info structure
+    
+    // OK, we have the correct xregistry/xencoding in info structure
 
     wxNativeFont font = wxLoadQueryFont( pointSize, family, style, weight,
                                          underlined, facename,