1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mgl/fontutil.cpp
3 // Purpose: Font helper functions for MGL
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
23 #include "wx/fontutil.h"
24 #include "wx/encinfo.h"
25 #include "wx/fontmap.h"
26 #include "wx/tokenzr.h"
28 #include "wx/listimpl.cpp"
29 #include "wx/sysopt.h"
30 #include "wx/mgl/private.h"
31 #include "wx/private/fontmgr.h"
35 // ============================================================================
37 // ============================================================================
39 // ----------------------------------------------------------------------------
40 // wxNativeEncodingInfo
41 // ----------------------------------------------------------------------------
43 // convert to/from the string representation: format is
44 // encoding[;facename]
45 bool wxNativeEncodingInfo::FromString(const wxString
& s
)
47 wxStringTokenizer
tokenizer(s
, wxT(";"));
49 wxString encid
= tokenizer
.GetNextToken();
51 if ( !encid
.ToLong(&enc
) )
53 encoding
= (wxFontEncoding
)enc
;
56 facename
= tokenizer
.GetNextToken();
61 wxString
wxNativeEncodingInfo::ToString() const
65 if ( !facename
.empty() )
67 s
<< wxT(';') << facename
;
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 bool wxGetNativeFontEncoding(wxFontEncoding encoding
,
78 wxNativeEncodingInfo
*info
)
80 wxCHECK_MSG( info
, false, wxT("bad pointer in wxGetNativeFontEncoding") );
82 if ( encoding
== wxFONTENCODING_DEFAULT
)
84 encoding
= wxFont::GetDefaultEncoding();
89 case wxFONTENCODING_ISO8859_1
:
90 case wxFONTENCODING_ISO8859_2
:
91 case wxFONTENCODING_ISO8859_3
:
92 case wxFONTENCODING_ISO8859_4
:
93 case wxFONTENCODING_ISO8859_5
:
94 case wxFONTENCODING_ISO8859_6
:
95 case wxFONTENCODING_ISO8859_7
:
96 case wxFONTENCODING_ISO8859_8
:
97 case wxFONTENCODING_ISO8859_9
:
98 case wxFONTENCODING_ISO8859_10
:
99 case wxFONTENCODING_ISO8859_11
:
100 case wxFONTENCODING_ISO8859_13
:
101 case wxFONTENCODING_ISO8859_14
:
102 case wxFONTENCODING_ISO8859_15
:
103 info
->mglEncoding
= MGL_ENCODING_ISO8859_1
+
104 (encoding
- wxFONTENCODING_ISO8859_1
);
107 case wxFONTENCODING_KOI8
:
108 info
->mglEncoding
= MGL_ENCODING_KOI8
;
111 case wxFONTENCODING_CP1250
:
112 case wxFONTENCODING_CP1251
:
113 case wxFONTENCODING_CP1252
:
114 case wxFONTENCODING_CP1253
:
115 case wxFONTENCODING_CP1254
:
116 case wxFONTENCODING_CP1255
:
117 case wxFONTENCODING_CP1256
:
118 case wxFONTENCODING_CP1257
:
119 info
->mglEncoding
= MGL_ENCODING_CP1250
+
120 (encoding
- wxFONTENCODING_CP1250
);
123 case wxFONTENCODING_SYSTEM
:
124 info
->mglEncoding
= MGL_ENCODING_ASCII
;
128 // encoding not known to MGL
132 info
->encoding
= encoding
;
137 bool wxTestFontEncoding(const wxNativeEncodingInfo
& info
)
139 if ( !info
.facename
)
142 wxFontBundle
*bundle
= wxFontsManager::Get()->GetBundle(info
.facename
);
145 if ( bundle
->GetInfo()->fontLibType
== MGL_BITMAPFONT_LIB
)
147 return (info
.mglEncoding
== MGL_ENCODING_ASCII
||
148 info
.mglEncoding
== MGL_ENCODING_ISO8859_1
||
149 info
.mglEncoding
== MGL_ENCODING_ISO8859_15
||
150 info
.mglEncoding
== MGL_ENCODING_CP1252
);