]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/dcclient.cpp
Build fix for SmartPhoneCE.
[wxWidgets.git] / src / gtk / dcclient.cpp
index 78269d6bbed548d3b7dde331fc207e1442e717a6..6df12003f0062a1218e11edc4f19fc61388606dc 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        gtk/dcclient.cpp
+// Name:        src/gtk/dcclient.cpp
 // Purpose:
 // Author:      Robert Roebling
 // RCS-ID:      $Id$
 #endif
 
 #include "wx/dcclient.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/log.h"
+#endif
+
 #include "wx/dcmemory.h"
 #include "wx/image.h"
 #include "wx/module.h"
-#include "wx/log.h"
 #include "wx/fontutil.h"
 
 #include "wx/gtk/win_gtk.h"
@@ -1696,16 +1700,24 @@ void wxWindowDC::DoGetTextExtent(const wxString &string,
         *externalLeading = 0;
 
     if (string.empty())
-    {
         return;
-    }
 
-    // Set new font description
-    if (theFont)
-        pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description );
+    // ensure that theFont is always non-NULL
+    if ( !theFont || !theFont->Ok() )
+        theFont = wx_const_cast(wxFont *, &m_font);
+
+    // and use it if it's valid
+    if ( theFont->Ok() )
+    {
+        pango_layout_set_font_description
+        (
+            m_layout,
+            theFont->GetNativeFontInfo()->description
+        );
+    }
 
     // Set layout's text
-    const wxCharBuffer dataUTF8 = wxGTK_CONV(string);
+    const wxCharBuffer dataUTF8 = wxGTK_CONV_FONT(string, *theFont);
     if ( !dataUTF8 )
     {
         // hardly ideal, but what else can we do if conversion failed?