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"
39 #include "wx/encinfo.h"
41 #include "wx/tokenzr.h"
43 // ============================================================================
45 // ============================================================================
47 // ----------------------------------------------------------------------------
48 // wxNativeEncodingInfo
49 // ----------------------------------------------------------------------------
51 // convert to/from the string representation: format is
54 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
56 wxStringTokenizer
tokenizer(s
, _T(";"));
58 facename
= tokenizer
.GetNextToken();
62 wxString tmp
= tokenizer
.GetNextToken();
65 // default charset (don't use DEFAULT_CHARSET though because of subtle
66 // Windows 9x/NT differences in handling it)
71 if ( wxSscanf(tmp
, _T("%u"), &charset
) != 1 )
73 // should be a number!
81 wxString
wxNativeEncodingInfo::ToString() const
86 s
<< _T(';') << charset
;
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
97 wxNativeEncodingInfo
*info
)
99 wxCHECK_MSG( info
, FALSE
, _T("bad pointer in wxGetNativeFontEncoding") );
101 if ( encoding
== wxFONTENCODING_DEFAULT
)
103 encoding
= wxFont::GetDefaultEncoding();
108 // although this function is supposed to return an exact match, do do
109 // some mappings here for the most common case of "standard" encoding
110 case wxFONTENCODING_SYSTEM
:
111 case wxFONTENCODING_ISO8859_1
:
112 case wxFONTENCODING_ISO8859_15
:
113 case wxFONTENCODING_CP1252
:
117 case wxFONTENCODING_CP1250
:
121 case wxFONTENCODING_CP1251
:
125 case wxFONTENCODING_CP1253
:
129 case wxFONTENCODING_CP1254
:
133 case wxFONTENCODING_CP1255
:
137 case wxFONTENCODING_CP1256
:
141 case wxFONTENCODING_CP1257
:
145 case wxFONTENCODING_CP437
:
150 // no way to translate this encoding into a Windows charset
157 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)