1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/fontutil.cpp
3 // Purpose: font-related helper functions for wxMSW
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "fontutil.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/string.h"
37 #include "wx/fontutil.h"
38 #include "wx/fontmap.h"
40 #include "wx/tokenzr.h"
42 // ============================================================================
44 // ============================================================================
46 // ----------------------------------------------------------------------------
47 // wxNativeEncodingInfo
48 // ----------------------------------------------------------------------------
50 // convert to/from the string representation: format is
53 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
55 wxStringTokenizer
tokenizer(s
, _T(";"));
57 facename
= tokenizer
.GetNextToken();
61 wxString tmp
= tokenizer
.GetNextToken();
64 // default charset (don't use DEFAULT_CHARSET though because of subtle
65 // Windows 9x/NT differences in handling it)
70 if ( wxSscanf(tmp
, _T("%u"), &charset
) != 1 )
72 // should be a number!
80 wxString
wxNativeEncodingInfo::ToString() const
85 s
<< _T(';') << charset
;
91 // ----------------------------------------------------------------------------
93 // ----------------------------------------------------------------------------
95 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
96 wxNativeEncodingInfo
*info
)
98 wxCHECK_MSG( info
, FALSE
, _T("bad pointer in wxGetNativeFontEncoding") );
100 if ( encoding
== wxFONTENCODING_DEFAULT
)
102 encoding
= wxFont::GetDefaultEncoding();
107 // although this function is supposed to return an exact match, do do
108 // some mappings here for the most common case of "standard" encoding
109 case wxFONTENCODING_SYSTEM
:
110 case wxFONTENCODING_ISO8859_1
:
111 case wxFONTENCODING_ISO8859_15
:
112 case wxFONTENCODING_CP1252
:
116 case wxFONTENCODING_CP1250
:
120 case wxFONTENCODING_CP1251
:
124 case wxFONTENCODING_CP1253
:
128 case wxFONTENCODING_CP1254
:
132 case wxFONTENCODING_CP1255
:
136 case wxFONTENCODING_CP1256
:
140 case wxFONTENCODING_CP1257
:
144 case wxFONTENCODING_CP437
:
149 // no way to translate this encoding into a Windows charset
156 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)