]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/unix/fontenum.cpp | |
3 | // Purpose: wxFontEnumerator class for MGL | |
4 | // Author: Vaclav Slavik | |
5 | // RCS-ID: $Id$ | |
6 | // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | // ============================================================================ | |
11 | // declarations | |
12 | // ============================================================================ | |
13 | ||
14 | // ---------------------------------------------------------------------------- | |
15 | // headers | |
16 | // ---------------------------------------------------------------------------- | |
17 | ||
18 | #ifdef __GNUG__ | |
19 | #pragma implementation "fontenum.h" | |
20 | #endif | |
21 | ||
22 | // For compilers that support precompilation, includes "wx.h". | |
23 | #include "wx/wxprec.h" | |
24 | ||
25 | #ifdef __BORLANDC__ | |
26 | #pragma hdrstop | |
27 | #endif | |
28 | ||
29 | #include "wx/defs.h" | |
30 | #include "wx/dynarray.h" | |
31 | #include "wx/string.h" | |
32 | #include "wx/utils.h" | |
33 | ||
34 | #include "wx/fontenum.h" | |
35 | #include "wx/fontutil.h" | |
36 | ||
37 | #include <mgraph.h> | |
38 | ||
39 | // ============================================================================ | |
40 | // implementation | |
41 | // ============================================================================ | |
42 | ||
43 | ||
44 | // ---------------------------------------------------------------------------- | |
45 | // wxFontEnumerator | |
46 | // ---------------------------------------------------------------------------- | |
47 | ||
48 | bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding, | |
49 | bool fixedWidthOnly) | |
50 | { | |
51 | bool found = FALSE; | |
52 | wxMGLFontFamilyList *list = wxTheFontsManager->GetFamilyList(); | |
53 | wxMGLFontFamilyList::Node *node; | |
54 | wxMGLFontFamily *f = NULL; | |
55 | wxNativeEncodingInfo info; | |
56 | ||
57 | if ( encoding != wxFONTENCODING_SYSTEM ) | |
58 | wxGetNativeFontEncoding(encoding, &info); | |
59 | ||
60 | for (node = list->GetFirst(); node; node = node->GetNext()) | |
61 | { | |
62 | f = node->GetData(); | |
63 | info.facename = f->GetName(); | |
64 | if ( (!fixedWidthOnly || f->GetInfo()->isFixed) && | |
65 | (encoding == wxFONTENCODING_SYSTEM || wxTestFontEncoding(info)) ) | |
66 | { | |
67 | found = TRUE; | |
68 | if ( !OnFacename(f->GetName()) ) | |
69 | return TRUE; | |
70 | } | |
71 | } | |
72 | ||
73 | return found; | |
74 | } | |
75 | ||
76 | bool wxFontEnumerator::EnumerateEncodings(const wxString& family) | |
77 | { | |
78 | static wxFontEncoding encodings[] = | |
79 | { | |
80 | wxFONTENCODING_ISO8859_1, | |
81 | wxFONTENCODING_ISO8859_2, | |
82 | wxFONTENCODING_ISO8859_3, | |
83 | wxFONTENCODING_ISO8859_4, | |
84 | wxFONTENCODING_ISO8859_5, | |
85 | wxFONTENCODING_ISO8859_6, | |
86 | wxFONTENCODING_ISO8859_7, | |
87 | wxFONTENCODING_ISO8859_8, | |
88 | wxFONTENCODING_ISO8859_9, | |
89 | wxFONTENCODING_ISO8859_10, | |
90 | //wxFONTENCODING_ISO8859_11, | |
91 | //wxFONTENCODING_ISO8859_12, | |
92 | wxFONTENCODING_ISO8859_13, | |
93 | wxFONTENCODING_ISO8859_14, | |
94 | wxFONTENCODING_ISO8859_15, | |
95 | wxFONTENCODING_CP1250, | |
96 | wxFONTENCODING_CP1251, | |
97 | wxFONTENCODING_CP1252, | |
98 | wxFONTENCODING_CP1253, | |
99 | wxFONTENCODING_CP1254, | |
100 | wxFONTENCODING_CP1255, | |
101 | wxFONTENCODING_CP1256, | |
102 | wxFONTENCODING_CP1257, | |
103 | wxFONTENCODING_KOI8, | |
104 | ||
105 | wxFONTENCODING_SYSTEM | |
106 | }; | |
107 | ||
108 | static const char *encodingNames[] = | |
109 | { | |
110 | "iso88590-1", | |
111 | "iso88590-2", | |
112 | "iso88590-3", | |
113 | "iso88590-4", | |
114 | "iso88590-5", | |
115 | "iso88590-6", | |
116 | "iso88590-7", | |
117 | "iso88590-8", | |
118 | "iso88590-9", | |
119 | "iso88590-10", | |
120 | "iso88590-13", | |
121 | "iso88590-14", | |
122 | "iso88590-15", | |
123 | "windows-1250", | |
124 | "windows-1251", | |
125 | "windows-1252", | |
126 | "windows-1253", | |
127 | "windows-1254", | |
128 | "windows-1255", | |
129 | "windows-1256", | |
130 | "windows-1257", | |
131 | "koi-8", | |
132 | NULL | |
133 | }; | |
134 | ||
135 | wxNativeEncodingInfo info; | |
136 | info.facename = family; | |
137 | ||
138 | for (size_t i = 0; encodings[i] != wxFONTENCODING_SYSTEM; i++) | |
139 | { | |
140 | if ( !wxGetNativeFontEncoding(encodings[i], &info) || | |
141 | !wxTestFontEncoding(info) ) | |
142 | continue; | |
143 | if ( !OnFontEncoding(family, encodingNames[i]) ) | |
144 | break; | |
145 | } | |
146 | ||
147 | return TRUE; | |
148 | } |