]> git.saurik.com Git - wxWidgets.git/blobdiff - src/x11/font.cpp
adapting keycode field usage for EVT_CHAR in unicode to MSW variant (full unicode...
[wxWidgets.git] / src / x11 / font.cpp
index b6fa33d36aee4e7c41079ca2a6bedaa474f6e15b..53d2bebcca9378859e9dbbbb7636f88b93e662be 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     17/09/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
 // Created:     17/09/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
-// Licence:     wxWidgets licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
 /////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
 // headers
 // ----------------------------------------------------------------------------
 
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "font.h"
-#endif
-
 #ifdef __VMS
 #pragma message disable nosimpint
 #include "wx/vms_x_fix.h"
 #ifdef __VMS
 #pragma message disable nosimpint
 #include "wx/vms_x_fix.h"
@@ -79,10 +75,10 @@ wxXFont::wxXFont()
 
 wxXFont::~wxXFont()
 {
 
 wxXFont::~wxXFont()
 {
-    // TODO: why does freeing the font produce a segv???
-    // Note that XFreeFont wasn't called in wxWin 1.68 either.
-    // XFontStruct* fontStruct = (XFontStruct*) m_fontStruct;
-    //        XFreeFont((Display*) m_display, fontStruct);
+    // Freeing the font used to produce a segv, but
+    // appears to be OK now (bug fix in X11?)
+    XFontStruct* fontStruct = (XFontStruct*) m_fontStruct;
+    XFreeFont((Display*) m_display, fontStruct);
 }
 #endif
 
 }
 #endif
 
@@ -123,7 +119,7 @@ public:
     void SetEncoding(wxFontEncoding encoding);
 
     void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; }
     void SetEncoding(wxFontEncoding encoding);
 
     void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; }
-    bool GetNoAntiAliasing() { return m_noAA; }
+    bool GetNoAntiAliasing() const { return m_noAA; }
 
     // and this one also modifies all the other font data fields
     void SetNativeFontInfo(const wxNativeFontInfo& info);
 
     // and this one also modifies all the other font data fields
     void SetNativeFontInfo(const wxNativeFontInfo& info);
@@ -202,7 +198,7 @@ void wxFontRefData::Init(int pointSize,
         case wxFONTFAMILY_TELETYPE:
            pango_font_description_set_family( m_nativeFontInfo.description, "monospace" );
            break;
         case wxFONTFAMILY_TELETYPE:
            pango_font_description_set_family( m_nativeFontInfo.description, "monospace" );
            break;
-        case wxFONTFAMILY_SWISS:
+        case wxFONTFAMILY_ROMAN:
            pango_font_description_set_family( m_nativeFontInfo.description, "serif" );
            break;
         default:
            pango_font_description_set_family( m_nativeFontInfo.description, "serif" );
            break;
         default:
@@ -745,7 +741,7 @@ wxFontEncoding wxFont::GetEncoding() const
     return M_FONTDATA->m_encoding;
 }
 
     return M_FONTDATA->m_encoding;
 }
 
-bool wxFont::GetNoAntiAliasing()
+bool wxFont::GetNoAntiAliasing() const
 {
     wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
 
 {
     wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
 
@@ -883,6 +879,11 @@ wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
         node = node->GetNext();
     }
 
         node = node->GetNext();
     }
 
+    wxString xFontName = M_FONTDATA->m_nativeFontInfo.GetXFontName();
+    if (xFontName == "-*-*-*-*-*--*-*-*-*-*-*-*-*")
+      // wxFont constructor not called with native font info parameter => take M_FONTDATA values
+      xFontName.Clear();
+    
     // not found, create a new one
     XFontStruct *font = (XFontStruct *)
                         wxLoadQueryNearestFont(pointSize,
     // not found, create a new one
     XFontStruct *font = (XFontStruct *)
                         wxLoadQueryNearestFont(pointSize,
@@ -891,7 +892,8 @@ wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
                                                M_FONTDATA->m_weight,
                                                M_FONTDATA->m_underlined,
                                                wxT(""),
                                                M_FONTDATA->m_weight,
                                                M_FONTDATA->m_underlined,
                                                wxT(""),
-                                               M_FONTDATA->m_encoding);
+                                               M_FONTDATA->m_encoding,
+                                               & xFontName);
 
     if ( !font )
     {
 
     if ( !font )
     {