]>
Commit | Line | Data |
---|---|---|
72e7876b SC |
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> | |
65571936 | 9 | // Licence: wxWindows licence |
72e7876b SC |
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" | |
050ffabb | 39 | #include "wx/encinfo.h" |
72e7876b SC |
40 | |
41 | #include "wx/tokenzr.h" | |
42 | ||
43 | // ============================================================================ | |
44 | // implementation | |
45 | // ============================================================================ | |
46 | ||
47 | // ---------------------------------------------------------------------------- | |
48 | // wxNativeEncodingInfo | |
49 | // ---------------------------------------------------------------------------- | |
50 | ||
51 | // convert to/from the string representation: format is | |
2f1ae414 | 52 | // facename[;charset] |
72e7876b SC |
53 | |
54 | bool wxNativeEncodingInfo::FromString(const wxString& s) | |
55 | { | |
56 | wxStringTokenizer tokenizer(s, _T(";")); | |
57 | ||
58 | facename = tokenizer.GetNextToken(); | |
59 | if ( !facename ) | |
60 | return FALSE; | |
61 | ||
62 | wxString tmp = tokenizer.GetNextToken(); | |
63 | if ( !tmp ) | |
64 | { | |
65 | // default charset (don't use DEFAULT_CHARSET though because of subtle | |
66 | // Windows 9x/NT differences in handling it) | |
67 | charset = 0; | |
68 | } | |
69 | else | |
70 | { | |
71 | if ( wxSscanf(tmp, _T("%u"), &charset) != 1 ) | |
72 | { | |
73 | // should be a number! | |
74 | return FALSE; | |
75 | } | |
76 | } | |
77 | ||
78 | return TRUE; | |
79 | } | |
80 | ||
81 | wxString wxNativeEncodingInfo::ToString() const | |
82 | { | |
2f1ae414 | 83 | wxString s(facename); |
72e7876b SC |
84 | if ( charset != 0 ) |
85 | { | |
86 | s << _T(';') << charset; | |
87 | } | |
88 | ||
89 | return s; | |
90 | } | |
91 | ||
92 | // ---------------------------------------------------------------------------- | |
93 | // helper functions | |
94 | // ---------------------------------------------------------------------------- | |
95 | ||
96 | bool wxGetNativeFontEncoding(wxFontEncoding encoding, | |
97 | wxNativeEncodingInfo *info) | |
98 | { | |
99 | wxCHECK_MSG( info, FALSE, _T("bad pointer in wxGetNativeFontEncoding") ); | |
100 | ||
101 | if ( encoding == wxFONTENCODING_DEFAULT ) | |
102 | { | |
103 | encoding = wxFont::GetDefaultEncoding(); | |
104 | } | |
105 | ||
25b1b566 | 106 | info->encoding = encoding ; |
72e7876b SC |
107 | |
108 | return TRUE; | |
109 | } | |
110 | ||
111 | bool wxTestFontEncoding(const wxNativeEncodingInfo& info) | |
112 | { | |
908d407c SC |
113 | // basically we should be able to support every encoding via the OS |
114 | return true ; | |
72e7876b | 115 | } |
25b1b566 | 116 | |
25b1b566 | 117 |