]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/font.cpp
1. wxFontMapper starts to materialise
[wxWidgets.git] / src / msw / font.cpp
index 6f1ea88cf84a9b4d4d86b21b3fa6c527ecd0f030..0c45d9b9e81d98fcbb8de5ecb9c2989f59021b4a 100644 (file)
@@ -200,7 +200,7 @@ bool wxFont::RealizeResource()
     {
         // VZ: the old code returned FALSE in this case, but it doesn't seem
         //     to make sense because the font _was_ created
-        wxLogDebug(T("Calling wxFont::RealizeResource() twice"));
+        wxLogDebug(wxT("Calling wxFont::RealizeResource() twice"));
 
         return TRUE;
     }
@@ -212,7 +212,7 @@ bool wxFont::RealizeResource()
     {
         case wxSCRIPT:
             ff_family = FF_SCRIPT ;
-            ff_face = T("Script") ;
+            ff_face = wxT("Script") ;
             break ;
 
         case wxDECORATIVE:
@@ -221,24 +221,24 @@ bool wxFont::RealizeResource()
 
         case wxROMAN:
             ff_family = FF_ROMAN;
-            ff_face = T("Times New Roman") ;
+            ff_face = wxT("Times New Roman") ;
             break;
 
         case wxTELETYPE:
         case wxMODERN:
             ff_family = FF_MODERN;
-            ff_face = T("Courier New") ;
+            ff_face = wxT("Courier New") ;
             break;
 
         case wxSWISS:
             ff_family = FF_SWISS;
-            ff_face = T("Arial") ;
+            ff_face = wxT("Arial") ;
             break;
 
         case wxDEFAULT:
         default:
             ff_family = FF_SWISS;
-            ff_face = T("Arial") ; 
+            ff_face = wxT("Arial") ; 
     }
 
     BYTE ff_italic;
@@ -250,7 +250,7 @@ bool wxFont::RealizeResource()
             break;
 
         default:
-            wxFAIL_MSG(T("unknown font slant"));
+            wxFAIL_MSG(wxT("unknown font slant"));
             // fall through
 
         case wxNORMAL:
@@ -261,7 +261,7 @@ bool wxFont::RealizeResource()
     switch ( M_FONTDATA->m_weight )
     {
         default:
-            wxFAIL_MSG(T("unknown font weight"));
+            wxFAIL_MSG(wxT("unknown font weight"));
             // fall through
 
         case wxNORMAL:
@@ -328,68 +328,7 @@ bool wxFont::RealizeResource()
 
     BYTE ff_underline = M_FONTDATA->m_underlined;
 
-    wxFontEncoding encoding = M_FONTDATA->m_encoding;
-    if ( encoding == wxFONTENCODING_DEFAULT )
-    {
-        encoding = wxFont::GetDefaultEncoding();
-    }
-
-    DWORD charset;
-    switch ( encoding )
-    {
-        case wxFONTENCODING_ISO8859_1:
-        case wxFONTENCODING_ISO8859_15:
-        case wxFONTENCODING_CP1250:
-            charset = ANSI_CHARSET;
-            break;
-
-        case wxFONTENCODING_ISO8859_2:
-        case wxFONTENCODING_CP1252:
-            charset = EASTEUROPE_CHARSET;
-            break;
-
-        case wxFONTENCODING_ISO8859_4:
-        case wxFONTENCODING_ISO8859_10:
-            charset = BALTIC_CHARSET;
-            break;
-
-        case wxFONTENCODING_ISO8859_5:
-        case wxFONTENCODING_CP1251:
-            charset = RUSSIAN_CHARSET;
-            break;
-
-        case wxFONTENCODING_ISO8859_6:
-            charset = ARABIC_CHARSET;
-            break;
-
-        case wxFONTENCODING_ISO8859_7:
-            charset = GREEK_CHARSET;
-            break;
-
-        case wxFONTENCODING_ISO8859_8:
-            charset = HEBREW_CHARSET;
-            break;
-
-        case wxFONTENCODING_ISO8859_9:
-            charset = TURKISH_CHARSET;
-            break;
-
-        case wxFONTENCODING_ISO8859_11:
-            charset = THAI_CHARSET;
-            break;
-
-        case wxFONTENCODING_CP437:
-            charset = OEM_CHARSET;
-            break;
-
-        default:
-            wxFAIL_MSG(T("unsupported encoding"));
-            // fall through
-
-        case wxFONTENCODING_SYSTEM:
-            charset = ANSI_CHARSET;
-    }
-
+    DWORD charset = wxCharsetFromEncoding(GetEncoding());
     HFONT hFont = ::CreateFont
                   (
                    nHeight,             // height
@@ -575,3 +514,80 @@ wxFontEncoding wxFont::GetEncoding() const
 {
     return M_FONTDATA->m_encoding;
 }
+
+// ----------------------------------------------------------------------------
+// public functions
+// ----------------------------------------------------------------------------
+
+int wxCharsetFromEncoding(wxFontEncoding encoding, bool *exact)
+{
+    if ( encoding == wxFONTENCODING_DEFAULT )
+    {
+        encoding = wxFont::GetDefaultEncoding();
+    }
+
+    if ( exact )
+        *exact = TRUE;
+
+    int charset;
+    switch ( encoding )
+    {
+        case wxFONTENCODING_ISO8859_1:
+        case wxFONTENCODING_ISO8859_15:
+        case wxFONTENCODING_CP1250:
+            charset = ANSI_CHARSET;
+            break;
+
+#if !defined(__WIN16__)
+        case wxFONTENCODING_ISO8859_2:
+        case wxFONTENCODING_CP1252:
+            charset = EASTEUROPE_CHARSET;
+            break;
+
+        case wxFONTENCODING_ISO8859_4:
+        case wxFONTENCODING_ISO8859_10:
+            charset = BALTIC_CHARSET;
+            break;
+
+        case wxFONTENCODING_ISO8859_5:
+        case wxFONTENCODING_CP1251:
+            charset = RUSSIAN_CHARSET;
+            break;
+
+        case wxFONTENCODING_ISO8859_6:
+            charset = ARABIC_CHARSET;
+            break;
+
+        case wxFONTENCODING_ISO8859_7:
+            charset = GREEK_CHARSET;
+            break;
+
+        case wxFONTENCODING_ISO8859_8:
+            charset = HEBREW_CHARSET;
+            break;
+
+        case wxFONTENCODING_ISO8859_9:
+            charset = TURKISH_CHARSET;
+            break;
+
+        case wxFONTENCODING_ISO8859_11:
+            charset = THAI_CHARSET;
+            break;
+#endif // BC++ 16-bit
+
+        case wxFONTENCODING_CP437:
+            charset = OEM_CHARSET;
+            break;
+
+        default:
+            if ( exact )
+                *exact = FALSE;
+            // fall through
+
+        case wxFONTENCODING_SYSTEM:
+            charset = ANSI_CHARSET;
+    }
+
+    return charset;
+}
+