]> git.saurik.com Git - wxWidgets.git/blobdiff - src/x11/font.cpp
Hack to support iso8859 and other wrongly formated
[wxWidgets.git] / src / x11 / font.cpp
index 7215b892302ec33845dba4edec1bb24aad616bbe..32ebc2ac8531de13dd480e0945118f67b259a675 100644 (file)
@@ -35,9 +35,9 @@
     #include "wx/string.h"
     #include "wx/utils.h"       // for wxGetDisplay()
     #include "wx/settings.h"
+    #include "wx/gdicmn.h"
 #endif
 
-#include "wx/gdicmn.h"
 #include "wx/fontutil.h"    // for wxNativeFontInfo
 #include "wx/tokenzr.h"
 
@@ -65,7 +65,7 @@ class wxXFont : public wxObject
 {
 public:
     wxXFont();
-    ~wxXFont();
+    virtual ~wxXFont();
 
     WXFontStructPtr     m_fontStruct;   // XFontStruct
     WXDisplay*          m_display;      // XDisplay
@@ -121,7 +121,7 @@ public:
     void SetStyle(int style);
     void SetWeight(int weight);
     void SetUnderlined(bool underlined);
-    void SetFaceName(const wxString& facename);
+    bool SetFaceName(const wxString& facename);
     void SetEncoding(wxFontEncoding encoding);
 
     void SetNoAntiAliasing( bool no = true ) { m_noAA = no; }
@@ -164,6 +164,8 @@ protected:
 #endif
 };
 
+#define M_FONTDATA ((wxFontRefData*)m_refData)
+
 // ----------------------------------------------------------------------------
 // wxFontRefData
 // ----------------------------------------------------------------------------
@@ -243,23 +245,27 @@ void wxFontRefData::InitFromNative()
             break;
     }
 
+// Not defined in some Pango versions
+#define wxPANGO_WEIGHT_SEMIBOLD 600
+
     switch (pango_font_description_get_weight( desc ))
     {
         case PANGO_WEIGHT_ULTRALIGHT:
-            m_weight = wxFONTWEIGHT_LIGHT;
-            break;
         case PANGO_WEIGHT_LIGHT:
             m_weight = wxFONTWEIGHT_LIGHT;
             break;
+
+        default:
+            wxFAIL_MSG(_T("unknown Pango font weight"));
+            // fall through
+
         case PANGO_WEIGHT_NORMAL:
             m_weight = wxFONTWEIGHT_NORMAL;
             break;
+
+        case wxPANGO_WEIGHT_SEMIBOLD:
         case PANGO_WEIGHT_BOLD:
-            m_weight = wxFONTWEIGHT_BOLD;
-            break;
         case PANGO_WEIGHT_ULTRABOLD:
-            m_weight = wxFONTWEIGHT_BOLD;
-            break;
         case PANGO_WEIGHT_HEAVY:
             m_weight = wxFONTWEIGHT_BOLD;
             break;
@@ -503,9 +509,10 @@ void wxFontRefData::SetUnderlined(bool underlined)
     // the XLFD doesn't have "underlined" field anyhow
 }
 
-void wxFontRefData::SetFaceName(const wxString& facename)
+bool wxFontRefData::SetFaceName(const wxString& facename)
 {
     m_faceName = facename;
+    return true;
 }
 
 void wxFontRefData::SetEncoding(wxFontEncoding encoding)
@@ -816,11 +823,12 @@ void wxFont::SetWeight(int weight)
     M_FONTDATA->SetWeight(weight);
 }
 
-void wxFont::SetFaceName(const wxString& faceName)
+bool wxFont::SetFaceName(const wxString& faceName)
 {
     Unshare();
 
-    M_FONTDATA->SetFaceName(faceName);
+    return M_FONTDATA->SetFaceName(faceName) &&
+        wxFontBase::SetFaceName(faceName);
 }
 
 void wxFont::SetUnderlined(bool underlined)