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 license
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
51 // encodingid;facename[;charset]
53 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
55 wxStringTokenizer
tokenizer(s
, _T(";"));
57 wxString encid
= tokenizer
.GetNextToken();
59 if ( !encid
.ToLong(&enc
) )
61 encoding
= (wxFontEncoding
)enc
;
63 facename
= tokenizer
.GetNextToken();
67 wxString tmp
= tokenizer
.GetNextToken();
70 // default charset (don't use DEFAULT_CHARSET though because of subtle
71 // Windows 9x/NT differences in handling it)
76 if ( wxSscanf(tmp
, _T("%u"), &charset
) != 1 )
78 // should be a number!
86 wxString
wxNativeEncodingInfo::ToString() const
90 s
<< (long)encoding
<< _T(';') << facename
;
94 s
<< _T(';') << charset
;
100 // ----------------------------------------------------------------------------
102 // ----------------------------------------------------------------------------
104 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
105 wxNativeEncodingInfo
*info
)
107 wxCHECK_MSG( info
, FALSE
, _T("bad pointer in wxGetNativeFontEncoding") );
109 if ( encoding
== wxFONTENCODING_DEFAULT
)
111 encoding
= wxFont::GetDefaultEncoding();
116 // although this function is supposed to return an exact match, do do
117 // some mappings here for the most common case of "standard" encoding
118 case wxFONTENCODING_SYSTEM
:
119 case wxFONTENCODING_ISO8859_1
:
120 case wxFONTENCODING_ISO8859_15
:
121 case wxFONTENCODING_CP1252
:
125 case wxFONTENCODING_CP1250
:
129 case wxFONTENCODING_CP1251
:
133 case wxFONTENCODING_CP1253
:
137 case wxFONTENCODING_CP1254
:
141 case wxFONTENCODING_CP1255
:
145 case wxFONTENCODING_CP1256
:
149 case wxFONTENCODING_CP1257
:
153 case wxFONTENCODING_CP437
:
158 // no way to translate this encoding into a Windows charset
162 info
->encoding
= encoding
;
167 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)