]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/font.tex
Misc small changes, some for VC++ 1.5
[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
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
20e85460
JS
16\wxheading{Predefined objects}
17
18Objects:
19
20{\bf wxNullFont}
21
22Pointers:
23
24{\bf wxNORMAL\_FONT\\
25wxSMALL\_FONT\\
26wxITALIC\_FONT\\
27wxSWISS\_FONT}
28
a660d684
KB
29\wxheading{See also}
30
31\helpref{wxFont overview}{wxfontoverview}, \helpref{wxDC::SetFont}{wxdcsetfont},\rtfsp
32\helpref{wxDC::DrawText}{wxdcdrawtext}, \helpref{wxDC::GetTextExtent}{wxdcgettextextent},\rtfsp
33\helpref{wxFontDialog}{wxfontdialog}
34
35\latexignore{\rtfignore{\wxheading{Members}}}
36
37\membersection{wxFont::wxFont}\label{wxfontconstr}
38
39\func{}{wxFont}{\void}
40
41Default constructor.
42
eaaa6a06 43\func{}{wxFont}{\param{int}{ pointSize}, \param{int}{ family}, \param{int}{ style}, \param{int}{ weight},
0c5d3e1c
VZ
44 \param{const bool}{ underline = FALSE}, \param{const wxString\& }{faceName = ""},
45 \param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}}
a660d684 46
775a998e
VZ
47Creates a font object (see \helpref{font encoding
48overview}{wxfontencodingoverview} for the meaning of the last parameter).
a660d684
KB
49
50\wxheading{Parameters}
51
52\docparam{pointSize}{Size in points.}
53
54\docparam{family}{Font family, a generic way of referring to fonts without specifying actual facename. One of:
55
56\twocolwidtha{5cm}
57\begin{twocollist}\itemsep=0pt
58\twocolitem{{\bf wxDEFAULT}}{Chooses a default font.}
59\twocolitem{{\bf wxDECORATIVE}}{A decorative font.}
60\twocolitem{{\bf wxROMAN}}{A formal, serif font.}
61\twocolitem{{\bf wxSCRIPT}}{A handwriting font.}
62\twocolitem{{\bf wxSWISS}}{A sans-serif font.}
63\twocolitem{{\bf wxMODERN}}{A fixed pitch font.}
64\end{twocollist}}
65
66\docparam{style}{One of {\bf wxNORMAL}, {\bf wxSLANT} and {\bf wxITALIC}.}
67
68\docparam{weight}{One of {\bf wxNORMAL}, {\bf wxLIGHT} and {\bf wxBOLD}.}
69
70\docparam{underline}{The value can be TRUE or FALSE. At present this has an effect on Windows only.}
71
72\docparam{faceName}{An optional string specifying the actual typeface to be used. If the empty string,
73a default typeface will chosen based on the family.}
74
0c5d3e1c
VZ
75\docparam{encoding}{An encoding which may be one of
76\twocolwidtha{5cm}
77\begin{twocollist}\itemsep=0pt
78\twocolitem{{\bf wxFONTENCODING\_SYSTEM}}{Default system encoding.}
79\twocolitem{{\bf wxFONTENCODING\_DEFAULT}}{Default application encoding: this
80is the encoding set by calls to
88b1927c 81\helpref{SetDefaultEncoding}{wxfontsetdefaultencoding} and which may be set to,
0c5d3e1c
VZ
82say, KOI8 to create all fonts by default with KOI8 encoding. Initially, the
83default application encoding is the same as default system encoding.}
84\twocolitem{{\bf wxFONTENCODING\_ISO8859\_1...15}}{ISO8859 encodings.}
85\twocolitem{{\bf wxFONTENCODING\_KOI8}}{The standard russian encoding for Internet.}
86\twocolitem{{\bf wxFONTENCODING\_CP1250...1252}}{Windows encodings similar to ISO8859 (but not identical).}
87\end{twocollist}
88If the specified encoding isn't available, no font is created.
89}
90
a660d684
KB
91\wxheading{Remarks}
92
93If the desired font does not exist, the closest match will be chosen.
94Under Windows, only scaleable TrueType fonts are used.
95
96Underlining only works under Windows at present.
97
98See also \helpref{wxDC::SetFont}{wxdcsetfont}, \helpref{wxDC::DrawText}{wxdcdrawtext}
99and \helpref{wxDC::GetTextExtent}{wxdcgettextextent}.
100
101\membersection{wxFont::\destruct{wxFont}}
102
103\func{}{\destruct{wxFont}}{\void}
104
105Destructor.
106
107\wxheading{Remarks}
108
109The destructor may not delete the underlying font object of the native windowing
775a998e 110system, since wxFont uses a reference counting system for efficiency.
a660d684
KB
111
112Although all remaining fonts are deleted when the application exits,
113the application should try to clean up all fonts itself. This is because
114wxWindows cannot know if a pointer to the font object is stored in an
115application data structure, and there is a risk of double deletion.
116
775a998e
VZ
117\membersection{wxFont::GetDefaultEncoding}\label{wxfontgetdefaultencoding}
118
119\func{static wxFontEncoding}{GetDefaultEncoding}{\void}
120
121Returns the current applications default encoding.
122
123\wxheading{See also}
124
125\helpref{Font encoding overview}{wxfontencodingoverview},
126\helpref{SetDefaultEncoding}{wxfontsetdefaultencoding}
127
a660d684
KB
128\membersection{wxFont::GetFaceName}\label{wxfontgetfacename}
129
130\constfunc{wxString}{GetFaceName}{\void}
131
132Returns the typeface name associated with the font, or the empty string if there is no
133typeface information.
134
135\wxheading{See also}
136
137\helpref{wxFont::SetFaceName}{wxfontsetfacename}
138
139\membersection{wxFont::GetFamily}\label{wxfontgetfamily}
140
141\constfunc{int}{GetFamily}{\void}
142
143Gets the font family. See \helpref{wxFont::wxFont}{wxfontconstr} for a list of valid
144family identifiers.
145
146\wxheading{See also}
147
148\helpref{wxFont::SetFamily}{wxfontsetfamily}
149
150\membersection{wxFont::GetFontId}\label{wxfontgetfontid}
151
152\constfunc{int}{GetFontId}{\void}
153
154Returns the font id, if the portable font system is in operation. See \helpref{Font overview}{wxfontoverview} for
155further details.
156
157\membersection{wxFont::GetPointSize}\label{wxfontgetpointsize}
158
159\constfunc{int}{GetPointSize}{\void}
160
161Gets the point size.
162
163\wxheading{See also}
164
165\helpref{wxFont::SetPointSize}{wxfontsetpointsize}
166
167\membersection{wxFont::GetStyle}\label{wxfontgetstyle}
168
169\constfunc{int}{GetStyle}{\void}
170
171Gets the font style. See \helpref{wxFont::wxFont}{wxfontconstr} for a list of valid
172styles.
173
174\wxheading{See also}
175
176\helpref{wxFont::SetStyle}{wxfontsetstyle}
177
178\membersection{wxFont::GetUnderlined}\label{wxfontgetunderlined}
179
180\constfunc{bool}{GetUnderlined}{\void}
181
182Returns TRUE if the font is underlined, FALSE otherwise.
183
184\wxheading{See also}
185
186\helpref{wxFont::SetUnderlined}{wxfontsetunderlined}
187
188\membersection{wxFont::GetWeight}\label{wxfontgetweight}
189
190\constfunc{int}{GetWeight}{\void}
191
192Gets the font weight. See \helpref{wxFont::wxFont}{wxfontconstr} for a list of valid
193weight identifiers.
194
195\wxheading{See also}
196
197\helpref{wxFont::SetWeight}{wxfontsetweight}
198
88b1927c
JS
199\membersection{wxFont::SetDefaultEncoding}\label{wxfontsetdefaultencoding}
200
201\func{static void}{SetDefaultEncoding}{\param{wxFontEncoding }{encoding}}
202
203Sets the default font encoding.
204
775a998e
VZ
205\wxheading{See also}
206
207\helpref{Font encoding overview}{wxfontencodingoverview},
208\helpref{GetDefaultEncoding}{wxfontgetdefaultencoding}
209
a660d684
KB
210\membersection{wxFont::SetFaceName}\label{wxfontsetfacename}
211
212\func{void}{SetFaceName}{\param{const wxString\& }{faceName}}
213
214Sets the facename for the font.
215
216\wxheading{Parameters}
217
218\docparam{faceName}{A valid facename, which should be on the end-user's system.}
219
220\wxheading{Remarks}
221
222To avoid portability problems, don't rely on a specific face, but specify the font family
223instead or as well. A suitable font will be found on the end-user's system. If both the
224family and the facename are specified, wxWindows will first search for the specific face,
225and then for a font belonging to the same family.
226
227\wxheading{See also}
228
229\helpref{wxFont::GetFaceName}{wxfontgetfacename}, \helpref{wxFont::SetFamily}{wxfontsetfamily}
230
231\membersection{wxFont::SetFamily}\label{wxfontsetfamily}
232
eaaa6a06 233\func{void}{SetFamily}{\param{int}{ family}}
a660d684
KB
234
235Sets the font family.
236
237\wxheading{Parameters}
238
239\docparam{family}{One of:
240
241\twocolwidtha{5cm}
242\begin{twocollist}\itemsep=0pt
243\twocolitem{{\bf wxDEFAULT}}{Chooses a default font.}
244\twocolitem{{\bf wxDECORATIVE}}{A decorative font.}
245\twocolitem{{\bf wxROMAN}}{A formal, serif font.}
246\twocolitem{{\bf wxSCRIPT}}{A handwriting font.}
247\twocolitem{{\bf wxSWISS}}{A sans-serif font.}
248\twocolitem{{\bf wxMODERN}}{A fixed pitch font.}
249\end{twocollist}}
250
251\wxheading{See also}
252
253\helpref{wxFont::GetFamily}{wxfontgetfamily}, \helpref{wxFont::SetFaceName}{wxfontsetfacename}
254
255\membersection{wxFont::SetPointSize}\label{wxfontsetpointsize}
256
eaaa6a06 257\func{void}{SetPointSize}{\param{int}{ pointSize}}
a660d684
KB
258
259Sets the point size.
260
261\wxheading{Parameters}
262
263\docparam{pointSize}{Size in points.}
264
265\wxheading{See also}
266
267\helpref{wxFont::GetPointSize}{wxfontgetpointsize}
268
269\membersection{wxFont::SetStyle}\label{wxfontsetstyle}
270
eaaa6a06 271\func{void}{SetStyle}{\param{int}{ style}}
a660d684
KB
272
273Sets the font style.
274
275\wxheading{Parameters}
276
277\docparam{style}{One of {\bf wxNORMAL}, {\bf wxSLANT} and {\bf wxITALIC}.}
278
279\wxheading{See also}
280
281\helpref{wxFont::GetStyle}{wxfontgetstyle}
282
283\membersection{wxFont::SetUnderlined}\label{wxfontsetunderlined}
284
285\func{void}{SetUnderlined}{\param{const bool}{ underlined}}
286
287Sets underlining.
288
289\wxheading{Parameters}
290
291\docparam{underlining}{TRUE to underline, FALSE otherwise.}
292
293\wxheading{See also}
294
295\helpref{wxFont::GetUnderlined}{wxfontgetunderlined}
296
297\membersection{wxFont::SetWeight}\label{wxfontsetweight}
298
eaaa6a06 299\func{void}{SetWeight}{\param{int}{ weight}}
a660d684
KB
300
301Sets the font weight.
302
303\wxheading{Parameters}
304
305\docparam{weight}{One of {\bf wxNORMAL}, {\bf wxLIGHT} and {\bf wxBOLD}.}
306
307\wxheading{See also}
308
309\helpref{wxFont::GetWeight}{wxfontgetweight}
310
311\membersection{wxFont::operator $=$}\label{wxfontassignment}
312
313\func{wxFont\&}{operator $=$}{\param{const wxFont\& }{font}}
314
315Assignment operator, using reference counting. Returns a reference
316to `this'.
317
318\membersection{wxFont::operator $==$}\label{wxfontequals}
319
320\func{bool}{operator $==$}{\param{const wxFont\& }{font}}
321
322Equality operator. Two fonts are equal if they contain pointers
323to the same underlying font data. It does not compare each attribute,
324so two indefontdently-created fonts using the same parameters will
325fail the test.
326
327\membersection{wxFont::operator $!=$}\label{wxfontnotequals}
328
329\func{bool}{operator $!=$}{\param{const wxFont\& }{font}}
330
331Inequality operator. Two fonts are not equal if they contain pointers
332to different underlying font data. It does not compare each attribute.
333
334