]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxFont}}\label{wxfont} |
2 | ||
3 | A font is an object which determines the appearance of text. Fonts are | |
4 | used for drawing text to a device context, and setting the appearance of | |
5 | a window's text. | |
6 | ||
7 | \wxheading{Derived from} | |
8 | ||
9 | \helpref{wxGDIObject}{wxgdiobject}\\ | |
10 | \helpref{wxObject}{wxobject} | |
11 | ||
954b8ae6 JS |
12 | \wxheading{Include files} |
13 | ||
14 | <wx/font.h> | |
15 | ||
dccce9ea VZ |
16 | \wxheading{Constants} |
17 | ||
18 | \begin{verbatim} | |
19 | enum wxFontEncoding | |
20 | { | |
21 | wxFONTENCODING_SYSTEM = -1, // system default | |
22 | wxFONTENCODING_DEFAULT, // current default encoding | |
23 | ||
24 | // ISO8859 standard defines a number of single-byte charsets | |
25 | wxFONTENCODING_ISO8859_1, // West European (Latin1) | |
26 | wxFONTENCODING_ISO8859_2, // Central and East European (Latin2) | |
27 | wxFONTENCODING_ISO8859_3, // Esperanto (Latin3) | |
28 | wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4) | |
29 | wxFONTENCODING_ISO8859_5, // Cyrillic | |
30 | wxFONTENCODING_ISO8859_6, // Arabic | |
31 | wxFONTENCODING_ISO8859_7, // Greek | |
32 | wxFONTENCODING_ISO8859_8, // Hebrew | |
33 | wxFONTENCODING_ISO8859_9, // Turkish (Latin5) | |
34 | wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6) | |
35 | wxFONTENCODING_ISO8859_11, // Thai | |
36 | wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it | |
37 | // here anyhow to make all ISO8859 | |
38 | // consecutive numbers | |
39 | wxFONTENCODING_ISO8859_13, // Baltic (Latin7) | |
40 | wxFONTENCODING_ISO8859_14, // Latin8 | |
41 | wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro) | |
42 | wxFONTENCODING_ISO8859_MAX, | |
43 | ||
44 | // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html) | |
45 | wxFONTENCODING_KOI8, // we don't support any of KOI8 variants | |
46 | wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866 | |
47 | wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria | |
48 | ||
49 | // what would we do without Microsoft? They have their own encodings | |
50 | // for DOS | |
51 | wxFONTENCODING_CP437, // original MS-DOS codepage | |
52 | wxFONTENCODING_CP850, // CP437 merged with Latin1 | |
53 | wxFONTENCODING_CP852, // CP437 merged with Latin2 | |
54 | wxFONTENCODING_CP855, // another cyrillic encoding | |
55 | wxFONTENCODING_CP866, // and another one | |
56 | // and for Windows | |
57 | wxFONTENCODING_CP874, // WinThai | |
58 | wxFONTENCODING_CP1250, // WinLatin2 | |
59 | wxFONTENCODING_CP1251, // WinCyrillic | |
60 | wxFONTENCODING_CP1252, // WinLatin1 | |
61 | wxFONTENCODING_CP1253, // WinGreek (8859-7) | |
62 | wxFONTENCODING_CP1254, // WinTurkish | |
63 | wxFONTENCODING_CP1255, // WinHebrew | |
64 | wxFONTENCODING_CP1256, // WinArabic | |
65 | wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7) | |
66 | wxFONTENCODING_CP12_MAX, | |
67 | ||
68 | wxFONTENCODING_UTF7, // UTF-7 Unicode encoding | |
69 | wxFONTENCODING_UTF8, // UTF-8 Unicode encoding | |
70 | ||
71 | wxFONTENCODING_UNICODE, // Unicode - currently used only by | |
72 | // wxEncodingConverter class | |
73 | ||
74 | wxFONTENCODING_MAX | |
75 | }; | |
76 | \end{verbatim} | |
77 | ||
20e85460 JS |
78 | \wxheading{Predefined objects} |
79 | ||
80 | Objects: | |
81 | ||
82 | {\bf wxNullFont} | |
83 | ||
84 | Pointers: | |
85 | ||
86 | {\bf wxNORMAL\_FONT\\ | |
87 | wxSMALL\_FONT\\ | |
88 | wxITALIC\_FONT\\ | |
89 | wxSWISS\_FONT} | |
90 | ||
a660d684 KB |
91 | \wxheading{See also} |
92 | ||
93 | \helpref{wxFont overview}{wxfontoverview}, \helpref{wxDC::SetFont}{wxdcsetfont},\rtfsp | |
94 | \helpref{wxDC::DrawText}{wxdcdrawtext}, \helpref{wxDC::GetTextExtent}{wxdcgettextextent},\rtfsp | |
95 | \helpref{wxFontDialog}{wxfontdialog} | |
96 | ||
97 | \latexignore{\rtfignore{\wxheading{Members}}} | |
98 | ||
99 | \membersection{wxFont::wxFont}\label{wxfontconstr} | |
100 | ||
101 | \func{}{wxFont}{\void} | |
102 | ||
103 | Default constructor. | |
104 | ||
eaaa6a06 | 105 | \func{}{wxFont}{\param{int}{ pointSize}, \param{int}{ family}, \param{int}{ style}, \param{int}{ weight}, |
0c5d3e1c VZ |
106 | \param{const bool}{ underline = FALSE}, \param{const wxString\& }{faceName = ""}, |
107 | \param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}} | |
a660d684 | 108 | |
775a998e VZ |
109 | Creates a font object (see \helpref{font encoding |
110 | overview}{wxfontencodingoverview} for the meaning of the last parameter). | |
a660d684 KB |
111 | |
112 | \wxheading{Parameters} | |
113 | ||
114 | \docparam{pointSize}{Size in points.} | |
115 | ||
116 | \docparam{family}{Font family, a generic way of referring to fonts without specifying actual facename. One of: | |
117 | ||
118 | \twocolwidtha{5cm} | |
119 | \begin{twocollist}\itemsep=0pt | |
120 | \twocolitem{{\bf wxDEFAULT}}{Chooses a default font.} | |
121 | \twocolitem{{\bf wxDECORATIVE}}{A decorative font.} | |
122 | \twocolitem{{\bf wxROMAN}}{A formal, serif font.} | |
123 | \twocolitem{{\bf wxSCRIPT}}{A handwriting font.} | |
124 | \twocolitem{{\bf wxSWISS}}{A sans-serif font.} | |
125 | \twocolitem{{\bf wxMODERN}}{A fixed pitch font.} | |
126 | \end{twocollist}} | |
127 | ||
128 | \docparam{style}{One of {\bf wxNORMAL}, {\bf wxSLANT} and {\bf wxITALIC}.} | |
129 | ||
130 | \docparam{weight}{One of {\bf wxNORMAL}, {\bf wxLIGHT} and {\bf wxBOLD}.} | |
131 | ||
132 | \docparam{underline}{The value can be TRUE or FALSE. At present this has an effect on Windows only.} | |
133 | ||
134 | \docparam{faceName}{An optional string specifying the actual typeface to be used. If the empty string, | |
135 | a default typeface will chosen based on the family.} | |
136 | ||
0c5d3e1c VZ |
137 | \docparam{encoding}{An encoding which may be one of |
138 | \twocolwidtha{5cm} | |
139 | \begin{twocollist}\itemsep=0pt | |
140 | \twocolitem{{\bf wxFONTENCODING\_SYSTEM}}{Default system encoding.} | |
141 | \twocolitem{{\bf wxFONTENCODING\_DEFAULT}}{Default application encoding: this | |
142 | is the encoding set by calls to | |
88b1927c | 143 | \helpref{SetDefaultEncoding}{wxfontsetdefaultencoding} and which may be set to, |
0c5d3e1c VZ |
144 | say, KOI8 to create all fonts by default with KOI8 encoding. Initially, the |
145 | default application encoding is the same as default system encoding.} | |
146 | \twocolitem{{\bf wxFONTENCODING\_ISO8859\_1...15}}{ISO8859 encodings.} | |
147 | \twocolitem{{\bf wxFONTENCODING\_KOI8}}{The standard russian encoding for Internet.} | |
148 | \twocolitem{{\bf wxFONTENCODING\_CP1250...1252}}{Windows encodings similar to ISO8859 (but not identical).} | |
149 | \end{twocollist} | |
150 | If the specified encoding isn't available, no font is created. | |
151 | } | |
152 | ||
a660d684 KB |
153 | \wxheading{Remarks} |
154 | ||
155 | If the desired font does not exist, the closest match will be chosen. | |
156 | Under Windows, only scaleable TrueType fonts are used. | |
157 | ||
a660d684 KB |
158 | See also \helpref{wxDC::SetFont}{wxdcsetfont}, \helpref{wxDC::DrawText}{wxdcdrawtext} |
159 | and \helpref{wxDC::GetTextExtent}{wxdcgettextextent}. | |
160 | ||
161 | \membersection{wxFont::\destruct{wxFont}} | |
162 | ||
163 | \func{}{\destruct{wxFont}}{\void} | |
164 | ||
165 | Destructor. | |
166 | ||
167 | \wxheading{Remarks} | |
168 | ||
169 | The destructor may not delete the underlying font object of the native windowing | |
775a998e | 170 | system, since wxFont uses a reference counting system for efficiency. |
a660d684 KB |
171 | |
172 | Although all remaining fonts are deleted when the application exits, | |
173 | the application should try to clean up all fonts itself. This is because | |
174 | wxWindows cannot know if a pointer to the font object is stored in an | |
175 | application data structure, and there is a risk of double deletion. | |
176 | ||
775a998e VZ |
177 | \membersection{wxFont::GetDefaultEncoding}\label{wxfontgetdefaultencoding} |
178 | ||
179 | \func{static wxFontEncoding}{GetDefaultEncoding}{\void} | |
180 | ||
181 | Returns the current applications default encoding. | |
182 | ||
183 | \wxheading{See also} | |
184 | ||
185 | \helpref{Font encoding overview}{wxfontencodingoverview}, | |
186 | \helpref{SetDefaultEncoding}{wxfontsetdefaultencoding} | |
187 | ||
a660d684 KB |
188 | \membersection{wxFont::GetFaceName}\label{wxfontgetfacename} |
189 | ||
190 | \constfunc{wxString}{GetFaceName}{\void} | |
191 | ||
192 | Returns the typeface name associated with the font, or the empty string if there is no | |
193 | typeface information. | |
194 | ||
195 | \wxheading{See also} | |
196 | ||
197 | \helpref{wxFont::SetFaceName}{wxfontsetfacename} | |
198 | ||
199 | \membersection{wxFont::GetFamily}\label{wxfontgetfamily} | |
200 | ||
201 | \constfunc{int}{GetFamily}{\void} | |
202 | ||
203 | Gets the font family. See \helpref{wxFont::wxFont}{wxfontconstr} for a list of valid | |
204 | family identifiers. | |
205 | ||
206 | \wxheading{See also} | |
207 | ||
208 | \helpref{wxFont::SetFamily}{wxfontsetfamily} | |
209 | ||
210 | \membersection{wxFont::GetFontId}\label{wxfontgetfontid} | |
211 | ||
212 | \constfunc{int}{GetFontId}{\void} | |
213 | ||
214 | Returns the font id, if the portable font system is in operation. See \helpref{Font overview}{wxfontoverview} for | |
215 | further details. | |
216 | ||
217 | \membersection{wxFont::GetPointSize}\label{wxfontgetpointsize} | |
218 | ||
219 | \constfunc{int}{GetPointSize}{\void} | |
220 | ||
221 | Gets the point size. | |
222 | ||
223 | \wxheading{See also} | |
224 | ||
225 | \helpref{wxFont::SetPointSize}{wxfontsetpointsize} | |
226 | ||
227 | \membersection{wxFont::GetStyle}\label{wxfontgetstyle} | |
228 | ||
229 | \constfunc{int}{GetStyle}{\void} | |
230 | ||
231 | Gets the font style. See \helpref{wxFont::wxFont}{wxfontconstr} for a list of valid | |
232 | styles. | |
233 | ||
234 | \wxheading{See also} | |
235 | ||
236 | \helpref{wxFont::SetStyle}{wxfontsetstyle} | |
237 | ||
238 | \membersection{wxFont::GetUnderlined}\label{wxfontgetunderlined} | |
239 | ||
240 | \constfunc{bool}{GetUnderlined}{\void} | |
241 | ||
242 | Returns TRUE if the font is underlined, FALSE otherwise. | |
243 | ||
244 | \wxheading{See also} | |
245 | ||
246 | \helpref{wxFont::SetUnderlined}{wxfontsetunderlined} | |
247 | ||
248 | \membersection{wxFont::GetWeight}\label{wxfontgetweight} | |
249 | ||
250 | \constfunc{int}{GetWeight}{\void} | |
251 | ||
252 | Gets the font weight. See \helpref{wxFont::wxFont}{wxfontconstr} for a list of valid | |
253 | weight identifiers. | |
254 | ||
255 | \wxheading{See also} | |
256 | ||
257 | \helpref{wxFont::SetWeight}{wxfontsetweight} | |
258 | ||
88b1927c JS |
259 | \membersection{wxFont::SetDefaultEncoding}\label{wxfontsetdefaultencoding} |
260 | ||
261 | \func{static void}{SetDefaultEncoding}{\param{wxFontEncoding }{encoding}} | |
262 | ||
263 | Sets the default font encoding. | |
264 | ||
775a998e VZ |
265 | \wxheading{See also} |
266 | ||
267 | \helpref{Font encoding overview}{wxfontencodingoverview}, | |
268 | \helpref{GetDefaultEncoding}{wxfontgetdefaultencoding} | |
269 | ||
a660d684 KB |
270 | \membersection{wxFont::SetFaceName}\label{wxfontsetfacename} |
271 | ||
272 | \func{void}{SetFaceName}{\param{const wxString\& }{faceName}} | |
273 | ||
274 | Sets the facename for the font. | |
275 | ||
276 | \wxheading{Parameters} | |
277 | ||
278 | \docparam{faceName}{A valid facename, which should be on the end-user's system.} | |
279 | ||
280 | \wxheading{Remarks} | |
281 | ||
282 | To avoid portability problems, don't rely on a specific face, but specify the font family | |
283 | instead or as well. A suitable font will be found on the end-user's system. If both the | |
284 | family and the facename are specified, wxWindows will first search for the specific face, | |
285 | and then for a font belonging to the same family. | |
286 | ||
287 | \wxheading{See also} | |
288 | ||
289 | \helpref{wxFont::GetFaceName}{wxfontgetfacename}, \helpref{wxFont::SetFamily}{wxfontsetfamily} | |
290 | ||
291 | \membersection{wxFont::SetFamily}\label{wxfontsetfamily} | |
292 | ||
eaaa6a06 | 293 | \func{void}{SetFamily}{\param{int}{ family}} |
a660d684 KB |
294 | |
295 | Sets the font family. | |
296 | ||
297 | \wxheading{Parameters} | |
298 | ||
299 | \docparam{family}{One of: | |
300 | ||
301 | \twocolwidtha{5cm} | |
302 | \begin{twocollist}\itemsep=0pt | |
303 | \twocolitem{{\bf wxDEFAULT}}{Chooses a default font.} | |
304 | \twocolitem{{\bf wxDECORATIVE}}{A decorative font.} | |
305 | \twocolitem{{\bf wxROMAN}}{A formal, serif font.} | |
306 | \twocolitem{{\bf wxSCRIPT}}{A handwriting font.} | |
307 | \twocolitem{{\bf wxSWISS}}{A sans-serif font.} | |
308 | \twocolitem{{\bf wxMODERN}}{A fixed pitch font.} | |
309 | \end{twocollist}} | |
310 | ||
311 | \wxheading{See also} | |
312 | ||
313 | \helpref{wxFont::GetFamily}{wxfontgetfamily}, \helpref{wxFont::SetFaceName}{wxfontsetfacename} | |
314 | ||
315 | \membersection{wxFont::SetPointSize}\label{wxfontsetpointsize} | |
316 | ||
eaaa6a06 | 317 | \func{void}{SetPointSize}{\param{int}{ pointSize}} |
a660d684 KB |
318 | |
319 | Sets the point size. | |
320 | ||
321 | \wxheading{Parameters} | |
322 | ||
323 | \docparam{pointSize}{Size in points.} | |
324 | ||
325 | \wxheading{See also} | |
326 | ||
327 | \helpref{wxFont::GetPointSize}{wxfontgetpointsize} | |
328 | ||
329 | \membersection{wxFont::SetStyle}\label{wxfontsetstyle} | |
330 | ||
eaaa6a06 | 331 | \func{void}{SetStyle}{\param{int}{ style}} |
a660d684 KB |
332 | |
333 | Sets the font style. | |
334 | ||
335 | \wxheading{Parameters} | |
336 | ||
337 | \docparam{style}{One of {\bf wxNORMAL}, {\bf wxSLANT} and {\bf wxITALIC}.} | |
338 | ||
339 | \wxheading{See also} | |
340 | ||
341 | \helpref{wxFont::GetStyle}{wxfontgetstyle} | |
342 | ||
343 | \membersection{wxFont::SetUnderlined}\label{wxfontsetunderlined} | |
344 | ||
345 | \func{void}{SetUnderlined}{\param{const bool}{ underlined}} | |
346 | ||
347 | Sets underlining. | |
348 | ||
349 | \wxheading{Parameters} | |
350 | ||
351 | \docparam{underlining}{TRUE to underline, FALSE otherwise.} | |
352 | ||
353 | \wxheading{See also} | |
354 | ||
355 | \helpref{wxFont::GetUnderlined}{wxfontgetunderlined} | |
356 | ||
357 | \membersection{wxFont::SetWeight}\label{wxfontsetweight} | |
358 | ||
eaaa6a06 | 359 | \func{void}{SetWeight}{\param{int}{ weight}} |
a660d684 KB |
360 | |
361 | Sets the font weight. | |
362 | ||
363 | \wxheading{Parameters} | |
364 | ||
365 | \docparam{weight}{One of {\bf wxNORMAL}, {\bf wxLIGHT} and {\bf wxBOLD}.} | |
366 | ||
367 | \wxheading{See also} | |
368 | ||
369 | \helpref{wxFont::GetWeight}{wxfontgetweight} | |
370 | ||
371 | \membersection{wxFont::operator $=$}\label{wxfontassignment} | |
372 | ||
373 | \func{wxFont\&}{operator $=$}{\param{const wxFont\& }{font}} | |
374 | ||
375 | Assignment operator, using reference counting. Returns a reference | |
376 | to `this'. | |
377 | ||
378 | \membersection{wxFont::operator $==$}\label{wxfontequals} | |
379 | ||
380 | \func{bool}{operator $==$}{\param{const wxFont\& }{font}} | |
381 | ||
382 | Equality operator. Two fonts are equal if they contain pointers | |
383 | to the same underlying font data. It does not compare each attribute, | |
384 | so two indefontdently-created fonts using the same parameters will | |
385 | fail the test. | |
386 | ||
387 | \membersection{wxFont::operator $!=$}\label{wxfontnotequals} | |
388 | ||
389 | \func{bool}{operator $!=$}{\param{const wxFont\& }{font}} | |
390 | ||
391 | Inequality operator. Two fonts are not equal if they contain pointers | |
392 | to different underlying font data. It does not compare each attribute. | |
393 | ||
394 |