- M_FONTDATA->m_hFont = (WXHFONT) CreateFont(nHeight, 0, 0, 0,ff_weight,ff_italic,(BYTE)ff_underline,
- 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
- PROOF_QUALITY, DEFAULT_PITCH | ff_family, pzFace);
-#ifdef WXDEBUG_CREATE
- if (m_hFont==NULL) wxError("Cannot create font","Internal Error") ;
-#endif
- return (M_FONTDATA->m_hFont != (WXHFONT) NULL);
- }
- return FALSE;
+ 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(wxT("unsupported encoding"));
+ // fall through
+
+ case wxFONTENCODING_SYSTEM:
+ charset = ANSI_CHARSET;
+ }
+
+ HFONT hFont = ::CreateFont
+ (
+ nHeight, // height
+ 0, // width (choose best)
+ 0, // escapement
+ 0, // orientation
+ ff_weight, // weight
+ ff_italic, // italic?
+ ff_underline, // underlined?
+ 0, // strikeout?
+ charset, // charset
+ OUT_DEFAULT_PRECIS, // precision
+ CLIP_DEFAULT_PRECIS, // clip precision
+ PROOF_QUALITY, // quality of match
+ DEFAULT_PITCH | // fixed or variable
+ ff_family, // family id
+ pzFace // face name
+ );
+
+ M_FONTDATA->m_hFont = (WXHFONT)hFont;
+ if ( !hFont )
+ {
+ wxLogLastError("CreateFont");
+ }
+
+ return hFont != 0;