]> git.saurik.com Git - wxWidgets.git/blob - src/mac/fontutil.cpp
Implemented DoBlit().
[wxWidgets.git] / src / mac / fontutil.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/fontutil.cpp
3 // Purpose: font-related helper functions for wxMSW
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 05.11.99
7 // RCS-ID: $Id$
8 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "fontutil.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/string.h"
33 #include "wx/log.h"
34 #include "wx/intl.h"
35 #endif //WX_PRECOMP
36
37 #include "wx/fontutil.h"
38 #include "wx/fontmap.h"
39
40 #include "wx/tokenzr.h"
41
42 // ============================================================================
43 // implementation
44 // ============================================================================
45
46 // ----------------------------------------------------------------------------
47 // wxNativeEncodingInfo
48 // ----------------------------------------------------------------------------
49
50 // convert to/from the string representation: format is
51 // facename[;charset]
52
53 bool wxNativeEncodingInfo::FromString(const wxString& s)
54 {
55 wxStringTokenizer tokenizer(s, _T(";"));
56
57 facename = tokenizer.GetNextToken();
58 if ( !facename )
59 return FALSE;
60
61 wxString tmp = tokenizer.GetNextToken();
62 if ( !tmp )
63 {
64 // default charset (don't use DEFAULT_CHARSET though because of subtle
65 // Windows 9x/NT differences in handling it)
66 charset = 0;
67 }
68 else
69 {
70 if ( wxSscanf(tmp, _T("%u"), &charset) != 1 )
71 {
72 // should be a number!
73 return FALSE;
74 }
75 }
76
77 return TRUE;
78 }
79
80 wxString wxNativeEncodingInfo::ToString() const
81 {
82 wxString s(facename);
83 if ( charset != 0 )
84 {
85 s << _T(';') << charset;
86 }
87
88 return s;
89 }
90
91 // ----------------------------------------------------------------------------
92 // helper functions
93 // ----------------------------------------------------------------------------
94
95 bool wxGetNativeFontEncoding(wxFontEncoding encoding,
96 wxNativeEncodingInfo *info)
97 {
98 wxCHECK_MSG( info, FALSE, _T("bad pointer in wxGetNativeFontEncoding") );
99
100 if ( encoding == wxFONTENCODING_DEFAULT )
101 {
102 encoding = wxFont::GetDefaultEncoding();
103 }
104
105 switch ( encoding )
106 {
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:
113 info->charset = 0;
114 break;
115
116 case wxFONTENCODING_CP1250:
117 info->charset = 0;
118 break;
119
120 case wxFONTENCODING_CP1251:
121 info->charset = 0;
122 break;
123
124 case wxFONTENCODING_CP1253:
125 info->charset = 0;
126 break;
127
128 case wxFONTENCODING_CP1254:
129 info->charset = 0;
130 break;
131
132 case wxFONTENCODING_CP1255:
133 info->charset = 0;
134 break;
135
136 case wxFONTENCODING_CP1256:
137 info->charset = 0;
138 break;
139
140 case wxFONTENCODING_CP1257:
141 info->charset = 0;
142 break;
143
144 case wxFONTENCODING_CP437:
145 info->charset = 0;
146 break;
147
148 default:
149 // no way to translate this encoding into a Windows charset
150 return FALSE;
151 }
152
153 return TRUE;
154 }
155
156 bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
157 {
158 return TRUE;
159 }