]> git.saurik.com Git - wxWidgets.git/commitdiff
use facename in wxFontRefData::Init() in Unicode build (part of patch 1671684)
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 8 Mar 2007 00:40:38 +0000 (00:40 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 8 Mar 2007 00:40:38 +0000 (00:40 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44676 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/x11/font.cpp

index 32ebc2ac8531de13dd480e0945118f67b259a675..5b37c975e8b7fb441b443ac67fa27a7e54fc63d2 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "wx/fontutil.h"    // for wxNativeFontInfo
 #include "wx/tokenzr.h"
+#include "wx/fontenum.h"
 
 #include "wx/x11/private.h"
 
@@ -196,27 +197,42 @@ void wxFontRefData::Init(int pointSize,
     m_encoding = encoding;
 
 #if wxUSE_UNICODE
+    if ( m_nativeFontInfo.description )
+        pango_font_description_free(m_nativeFontInfo.description);
+
     // Create native font info
     m_nativeFontInfo.description = pango_font_description_new();
 
-    // And set its values
-    switch (m_family)
+    // if a face name is specified, use it if it's available, otherwise use
+    // just the family
+    if ( faceName.empty() || !wxFontEnumerator::IsValidFacename(faceName) )
     {
-        case wxFONTFAMILY_MODERN:
-        case wxFONTFAMILY_TELETYPE:
-           pango_font_description_set_family( m_nativeFontInfo.description, "monospace" );
-           break;
-        case wxFONTFAMILY_ROMAN:
-           pango_font_description_set_family( m_nativeFontInfo.description, "serif" );
-           break;
-        default:
-           pango_font_description_set_family( m_nativeFontInfo.description, "sans" );
-           break;
+        // TODO: scan system for valid fonts matching the given family instead
+        //       of hardcoding them here
+        switch ( m_family )
+        {
+            case wxFONTFAMILY_TELETYPE:
+                m_faceName = wxT("monospace");
+                break;
+
+            case wxFONTFAMILY_ROMAN:
+                m_faceName = wxT("serif");
+                break;
+
+            default:
+                m_faceName = wxT("sans");
+        }
     }
-    SetStyle( m_style );
-    SetPointSize( m_pointSize );
-    SetWeight( m_weight );
-#endif
+    else // specified face name is available, use it
+    {
+        m_faceName = faceName;
+    }
+
+    m_nativeFontInfo.SetFaceName(m_faceName);
+    m_nativeFontInfo.SetPointSize(m_pointSize);
+    m_nativeFontInfo.SetWeight((wxFontWeight)m_weight);
+    m_nativeFontInfo.SetStyle((wxFontStyle)m_style);
+#endif // wxUSE_UNICODE
 }
 
 void wxFontRefData::InitFromNative()