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