]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/fontutil.cpp
use ES_AUTOHSCROLL for multiline controls as well (fixes 966692)
[wxWidgets.git] / src / unix / fontutil.cpp
index beac3babe431e704849ca90a38f6a99dedcb4e93..09c673e0c225ac4bf17f4544698c6cfc4fef3d4b 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     05.11.99
 // RCS-ID:      $Id$
 // Copyright:   (c) Vadim Zeitlin
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
@@ -17,7 +17,7 @@
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "fontutil.h"
 #endif
 
@@ -29,6 +29,7 @@
 #endif
 
 #ifndef WX_PRECOMP
+    #include "wx/encinfo.h"
 #endif // PCH
 
 #include "wx/fontutil.h"
@@ -132,6 +133,44 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
     return wxFONTENCODING_SYSTEM;
 }
 
+
+void wxNativeFontInfo::SetPointSize(int WXUNUSED(pointsize))
+{
+    wxFAIL_MSG( _T("not implemented") );
+}
+
+void wxNativeFontInfo::SetStyle(wxFontStyle WXUNUSED(style))
+{
+    wxFAIL_MSG( _T("not implemented") );
+}
+
+void wxNativeFontInfo::SetWeight(wxFontWeight WXUNUSED(weight))
+{
+    wxFAIL_MSG( _T("not implemented") );
+}
+
+void wxNativeFontInfo::SetUnderlined(bool WXUNUSED(underlined))
+{
+    wxFAIL_MSG( _T("not implemented") );
+}
+
+void wxNativeFontInfo::SetFaceName(wxString WXUNUSED(facename))
+{
+    wxFAIL_MSG( _T("not implemented") );
+}
+
+void wxNativeFontInfo::SetFamily(wxFontFamily WXUNUSED(family))
+{
+    wxFAIL_MSG( _T("not implemented") );
+}
+
+void wxNativeFontInfo::SetEncoding(wxFontEncoding WXUNUSED(encoding))
+{
+    wxFAIL_MSG( _T("not implemented") );
+}
+
+
+
 bool wxNativeFontInfo::FromString(const wxString& s)
 {
     if (description)
@@ -235,7 +274,13 @@ static wxHashTable *g_fontHash = (wxHashTable*) NULL;
 #elif defined(__WXGTK__)
     wxNativeFont wxLoadFont(const wxString& fontSpec)
     {
-       return gdk_font_load( wxConvertWX2MB(fontSpec) );
+        // VZ: we should use gdk_fontset_load() instead of gdk_font_load()
+        //     here to be able to display Japanese fonts correctly (at least
+        //     this is what people report) but unfortunately doing it results
+        //     in tons of warnings when using GTK with "normal" European
+        //     languages and so we can't always do it and I don't know enough
+        //     to determine when should this be done... (FIXME)
+        return gdk_font_load( wxConvertWX2MB(fontSpec) );
     }
 
     inline void wxFreeFont(wxNativeFont font)
@@ -388,16 +433,20 @@ bool wxNativeFontInfo::FromXFontName(const wxString& fontname)
             return FALSE;
         }
 
-        fontElements[n] = tokenizer.GetNextToken();
+        wxString field = tokenizer.GetNextToken();
+        if ( !field.empty() && field != _T('*') )
+        {
+            // we're really initialized now
+            m_isDefault = FALSE;
+        }
+
+        fontElements[n] = field;
     }
 
     // this should be all
     if ( tokenizer.HasMoreTokens() )
         return FALSE;
 
-    // we're initialized now
-    m_isDefault = FALSE;
-
     return TRUE;
 }
 
@@ -514,13 +563,13 @@ bool wxNativeFontInfo::GetUnderlined() const
 
 wxString wxNativeFontInfo::GetFaceName() const
 {
-    // wxWindows facename probably more accurately corresponds to X family
+    // wxWidgets facename probably more accurately corresponds to X family
     return GetXFontComponent(wxXLFD_FAMILY);
 }
 
 wxFontFamily wxNativeFontInfo::GetFamily() const
 {
-    // and wxWindows family -- to X foundry, but we have to translate it to
+    // and wxWidgets family -- to X foundry, but we have to translate it to
     // wxFontFamily somehow...
     wxFAIL_MSG(_T("not implemented")); // GetXFontComponent(wxXLFD_FOUNDRY);
 
@@ -666,6 +715,7 @@ bool wxGetNativeFontEncoding(wxFontEncoding encoding,
             break;
 
         case wxFONTENCODING_KOI8:
+        case wxFONTENCODING_KOI8_U:
             info->xregistry = wxT("koi8");
 
             // we don't make distinction between koi8-r, koi8-u and koi8-ru (so far)
@@ -787,27 +837,49 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
           *xFontName = newFontName;
     }
 
-    // try to load exactly the font requested first
-    if( !font )
-    {
-        font = wxLoadQueryFont( pointSize, family, style, weight,
-                                underlined, facename,
-                                info.xregistry, info.xencoding,
-                                xFontName );
-    }
-
     if ( !font )
     {
         // search up and down by stepsize 10
         int max_size = pointSize + 20 * (1 + (pointSize/180));
         int min_size = pointSize - 20 * (1 + (pointSize/180));
 
-        int i;
+        int i, round; // counters
+
+        // first round: search for equal, then for smaller and for larger size with the given weight and style
+        int testweight = weight;
+        int teststyle = style;
 
-        // Search for smaller size (approx.)
-        for ( i = pointSize - 10; !font && i >= 10 && i >= min_size; i -= 10 )
+        for ( round = 0; round < 3; round++ )
         {
-            font = wxLoadQueryFont(i, family, style, weight, underlined,
+            // second round: use normal weight
+            if ( round == 1 )
+        {
+                if ( testweight != wxNORMAL )
+                {
+                    testweight = wxNORMAL;
+                }
+                else
+                {
+                    ++round; // fall through to third round
+                }
+            }
+
+            // third round: ... and use normal style
+            if ( round == 2 )
+            {
+                if ( teststyle != wxNORMAL )
+                {
+                    teststyle = wxNORMAL;
+                }
+                else
+                {
+                    break;
+                }
+            }
+            // Search for equal or smaller size (approx.)
+            for ( i = pointSize; !font && i >= 10 && i >= min_size; i -= 10 )
+            {
+                font = wxLoadQueryFont(i, family, teststyle, testweight, underlined,
                                    facename, info.xregistry, info.xencoding,
                                    xFontName);
         }
@@ -815,9 +887,10 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
         // Search for larger size (approx.)
         for ( i = pointSize + 10; !font && i <= max_size; i += 10 )
         {
-            font = wxLoadQueryFont(i, family, style, weight, underlined,
+                font = wxLoadQueryFont(i, family, teststyle, testweight, underlined,
                                    facename, info.xregistry, info.xencoding,
                                    xFontName);
+            }
         }
 
         // Try default family