1 \section{\class{wxFont
}}\label{wxfont
}
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
7 \wxheading{Derived from
}
9 \helpref{wxGDIObject
}{wxgdiobject
}\\
10 \helpref{wxObject
}{wxobject
}
12 \wxheading{Include files
}
18 The font flags which can be used during the font creation are:
22 // no special flags: font with default weight/slant/anti-aliasing
23 wxFONTFLAG_DEFAULT =
0,
25 // slant flags (default: no slant)
26 wxFONTFLAG_ITALIC =
1 <<
0,
27 wxFONTFLAG_SLANT =
1 <<
1,
29 // weight flags (default: medium)
30 wxFONTFLAG_LIGHT =
1 <<
2,
31 wxFONTFLAG_BOLD =
1 <<
3,
33 // anti-aliasing flag: force on or off (default: the current system default)
34 wxFONTFLAG_ANTIALIASED =
1 <<
4,
35 wxFONTFLAG_NOT_ANTIALIASED =
1 <<
5,
37 // underlined/strikethrough flags (default: no lines)
38 wxFONTFLAG_UNDERLINED =
1 <<
6,
39 wxFONTFLAG_STRIKETHROUGH =
1 <<
7,
43 The known font encodings are:
47 wxFONTENCODING_SYSTEM = -
1, // system default
48 wxFONTENCODING_DEFAULT, // current default encoding
50 // ISO8859 standard defines a number of single-byte charsets
51 wxFONTENCODING_ISO8859_1, // West European (Latin1)
52 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
53 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
54 wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
55 wxFONTENCODING_ISO8859_5, // Cyrillic
56 wxFONTENCODING_ISO8859_6, // Arabic
57 wxFONTENCODING_ISO8859_7, // Greek
58 wxFONTENCODING_ISO8859_8, // Hebrew
59 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
60 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
61 wxFONTENCODING_ISO8859_11, // Thai
62 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
63 // here anyhow to make all ISO8859
64 // consecutive numbers
65 wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
66 wxFONTENCODING_ISO8859_14, // Latin8
67 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
68 wxFONTENCODING_ISO8859_MAX,
70 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
71 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
72 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
73 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
75 // what would we do without Microsoft? They have their own encodings
77 wxFONTENCODING_CP437, // original MS-DOS codepage
78 wxFONTENCODING_CP850, // CP437 merged with Latin1
79 wxFONTENCODING_CP852, // CP437 merged with Latin2
80 wxFONTENCODING_CP855, // another cyrillic encoding
81 wxFONTENCODING_CP866, // and another one
83 wxFONTENCODING_CP874, // WinThai
84 wxFONTENCODING_CP1250, // WinLatin2
85 wxFONTENCODING_CP1251, // WinCyrillic
86 wxFONTENCODING_CP1252, // WinLatin1
87 wxFONTENCODING_CP1253, // WinGreek (
8859-
7)
88 wxFONTENCODING_CP1254, // WinTurkish
89 wxFONTENCODING_CP1255, // WinHebrew
90 wxFONTENCODING_CP1256, // WinArabic
91 wxFONTENCODING_CP1257, // WinBaltic (same as Latin
7)
92 wxFONTENCODING_CP12_MAX,
94 wxFONTENCODING_UTF7, // UTF-
7 Unicode encoding
95 wxFONTENCODING_UTF8, // UTF-
8 Unicode encoding
97 wxFONTENCODING_UNICODE, // Unicode - currently used only by
98 // wxEncodingConverter class
104 \wxheading{Predefined objects
}
112 {\bf wxNORMAL
\_FONT\\
119 \helpref{wxFont overview
}{wxfontoverview
},
\helpref{wxDC::SetFont
}{wxdcsetfont
},
\rtfsp
120 \helpref{wxDC::DrawText
}{wxdcdrawtext
},
\helpref{wxDC::GetTextExtent
}{wxdcgettextextent
},
\rtfsp
121 \helpref{wxFontDialog
}{wxfontdialog
}
123 \latexignore{\rtfignore{\wxheading{Members
}}}
125 \membersection{wxFont::wxFont
}\label{wxfontconstr
}
127 \func{}{wxFont
}{\void}
131 \func{}{wxFont
}{\param{int
}{ pointSize
},
\param{int
}{ family
},
\param{int
}{ style
},
\param{int
}{ weight
},
132 \param{const bool
}{ underline = false
},
\param{const wxString\&
}{faceName = ""
},
133 \param{wxFontEncoding
}{encoding = wxFONTENCODING
\_DEFAULT}}
135 Creates a font object (see
\helpref{font encoding
136 overview
}{wxfontencodingoverview
} for the meaning of the last parameter).
138 \wxheading{Parameters
}
140 \docparam{pointSize
}{Size in points.
}
142 \docparam{family
}{Font family, a generic way of referring to fonts without specifying actual facename. One of:
145 \begin{twocollist
}\itemsep=
0pt
146 \twocolitem{{\bf wxDEFAULT
}}{Chooses a default font.
}
147 \twocolitem{{\bf wxDECORATIVE
}}{A decorative font.
}
148 \twocolitem{{\bf wxROMAN
}}{A formal, serif font.
}
149 \twocolitem{{\bf wxSCRIPT
}}{A handwriting font.
}
150 \twocolitem{{\bf wxSWISS
}}{A sans-serif font.
}
151 \twocolitem{{\bf wxMODERN
}}{A fixed pitch font.
}
154 \docparam{style
}{One of
{\bf wxNORMAL
},
{\bf wxSLANT
} and
{\bf wxITALIC
}.
}
156 \docparam{weight
}{One of
{\bf wxNORMAL
},
{\bf wxLIGHT
} and
{\bf wxBOLD
}.
}
158 \docparam{underline
}{The value can be true or false. At present this has an effect on Windows only.
}
160 \docparam{faceName
}{An optional string specifying the actual typeface to be used. If the empty string,
161 a default typeface will chosen based on the family.
}
163 \docparam{encoding
}{An encoding which may be one of
165 \begin{twocollist
}\itemsep=
0pt
166 \twocolitem{{\bf wxFONTENCODING
\_SYSTEM}}{Default system encoding.
}
167 \twocolitem{{\bf wxFONTENCODING
\_DEFAULT}}{Default application encoding: this
168 is the encoding set by calls to
169 \helpref{SetDefaultEncoding
}{wxfontsetdefaultencoding
} and which may be set to,
170 say, KOI8 to create all fonts by default with KOI8 encoding. Initially, the
171 default application encoding is the same as default system encoding.
}
172 \twocolitem{{\bf wxFONTENCODING
\_ISO8859\_1..
.15}}{ISO8859 encodings.
}
173 \twocolitem{{\bf wxFONTENCODING
\_KOI8}}{The standard Russian encoding for Internet.
}
174 \twocolitem{{\bf wxFONTENCODING
\_CP1250..
.1252}}{Windows encodings similar to ISO8859 (but not identical).
}
176 If the specified encoding isn't available, no font is created.
181 If the desired font does not exist, the closest match will be chosen.
182 Under Windows, only scalable TrueType fonts are used.
184 See also
\helpref{wxDC::SetFont
}{wxdcsetfont
},
\helpref{wxDC::DrawText
}{wxdcdrawtext
}
185 and
\helpref{wxDC::GetTextExtent
}{wxdcgettextextent
}.
187 \membersection{wxFont::
\destruct{wxFont
}}
189 \func{}{\destruct{wxFont
}}{\void}
195 The destructor may not delete the underlying font object of the native windowing
196 system, since wxFont uses a reference counting system for efficiency.
198 Although all remaining fonts are deleted when the application exits,
199 the application should try to clean up all fonts itself. This is because
200 wxWindows cannot know if a pointer to the font object is stored in an
201 application data structure, and there is a risk of double deletion.
203 \membersection{wxFont::IsFixedWidth
}\label{wxfontisfixedwidth
}
205 \constfunc{bool
}{IsFixedWidth
}{\void}
207 Returns
{\tt true
} if the font is a fixed width (or monospaced) font,
208 {\tt false
} if it is a proportional one or font is invalid.
210 \membersection{wxFont::GetDefaultEncoding
}\label{wxfontgetdefaultencoding
}
212 \func{static wxFontEncoding
}{GetDefaultEncoding
}{\void}
214 Returns the current application's default encoding.
218 \helpref{Font encoding overview
}{wxfontencodingoverview
},
219 \helpref{SetDefaultEncoding
}{wxfontsetdefaultencoding
}
221 \membersection{wxFont::GetFaceName
}\label{wxfontgetfacename
}
223 \constfunc{wxString
}{GetFaceName
}{\void}
225 Returns the typeface name associated with the font, or the empty string if there is no
226 typeface information.
230 \helpref{wxFont::SetFaceName
}{wxfontsetfacename
}
232 \membersection{wxFont::GetFamily
}\label{wxfontgetfamily
}
234 \constfunc{int
}{GetFamily
}{\void}
236 Gets the font family. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
241 \helpref{wxFont::SetFamily
}{wxfontsetfamily
}
243 \membersection{wxFont::GetNativeFontInfoDesc
}\label{wxfontgetnativefontinfodesc
}
245 \constfunc{wxString
}{GetNativeFontInfoDesc
}{\void}
247 Returns the platform-dependent string completely describing this font or an
248 empty string if the font wasn't constructed using the native font description.
252 \helpref{wxFont::SetNativeFontInfo
}{wxfontsetnativefontinfo
}
254 \membersection{wxFont::GetPointSize
}\label{wxfontgetpointsize
}
256 \constfunc{int
}{GetPointSize
}{\void}
262 \helpref{wxFont::SetPointSize
}{wxfontsetpointsize
}
264 \membersection{wxFont::GetStyle
}\label{wxfontgetstyle
}
266 \constfunc{int
}{GetStyle
}{\void}
268 Gets the font style. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
273 \helpref{wxFont::SetStyle
}{wxfontsetstyle
}
275 \membersection{wxFont::GetUnderlined
}\label{wxfontgetunderlined
}
277 \constfunc{bool
}{GetUnderlined
}{\void}
279 Returns true if the font is underlined, false otherwise.
283 \helpref{wxFont::SetUnderlined
}{wxfontsetunderlined
}
285 \membersection{wxFont::GetWeight
}\label{wxfontgetweight
}
287 \constfunc{int
}{GetWeight
}{\void}
289 Gets the font weight. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
294 \helpref{wxFont::SetWeight
}{wxfontsetweight
}
296 \membersection{wxFont::Ok
}\label{wxfontok
}
298 \constfunc{bool
}{Ok
}{\void}
300 Returns
{\tt true
} if this object is a valid font,
{\tt false
} otherwise.
302 \membersection{wxFont::SetDefaultEncoding
}\label{wxfontsetdefaultencoding
}
304 \func{static void
}{SetDefaultEncoding
}{\param{wxFontEncoding
}{encoding
}}
306 Sets the default font encoding.
310 \helpref{Font encoding overview
}{wxfontencodingoverview
},
311 \helpref{GetDefaultEncoding
}{wxfontgetdefaultencoding
}
313 \membersection{wxFont::SetFaceName
}\label{wxfontsetfacename
}
315 \func{void
}{SetFaceName
}{\param{const wxString\&
}{faceName
}}
317 Sets the facename for the font.
319 \wxheading{Parameters
}
321 \docparam{faceName
}{A valid facename, which should be on the end-user's system.
}
325 To avoid portability problems, don't rely on a specific face, but specify the font family
326 instead or as well. A suitable font will be found on the end-user's system. If both the
327 family and the facename are specified, wxWindows will first search for the specific face,
328 and then for a font belonging to the same family.
332 \helpref{wxFont::GetFaceName
}{wxfontgetfacename
},
\helpref{wxFont::SetFamily
}{wxfontsetfamily
}
334 \membersection{wxFont::SetFamily
}\label{wxfontsetfamily
}
336 \func{void
}{SetFamily
}{\param{int
}{ family
}}
338 Sets the font family.
340 \wxheading{Parameters
}
342 \docparam{family
}{One of:
345 \begin{twocollist
}\itemsep=
0pt
346 \twocolitem{{\bf wxDEFAULT
}}{Chooses a default font.
}
347 \twocolitem{{\bf wxDECORATIVE
}}{A decorative font.
}
348 \twocolitem{{\bf wxROMAN
}}{A formal, serif font.
}
349 \twocolitem{{\bf wxSCRIPT
}}{A handwriting font.
}
350 \twocolitem{{\bf wxSWISS
}}{A sans-serif font.
}
351 \twocolitem{{\bf wxMODERN
}}{A fixed pitch font.
}
356 \helpref{wxFont::GetFamily
}{wxfontgetfamily
},
\helpref{wxFont::SetFaceName
}{wxfontsetfacename
}
358 \membersection{wxFont::SetNativeFontInfo
}\label{wxfontsetnativefontinfo
}
360 \func{void
}{SetNativeFontInfo
}{\param{const wxString\&
}{info
}}
362 Creates the font corresponding to the given native font description string
363 which must have been previously returned by
364 \helpref{GetNativeFontInfoDesc
}{wxfontgetnativefontinfodesc
}. If the string is
365 invalid, font is unchanged.
367 \membersection{wxFont::SetPointSize
}\label{wxfontsetpointsize
}
369 \func{void
}{SetPointSize
}{\param{int
}{ pointSize
}}
373 \wxheading{Parameters
}
375 \docparam{pointSize
}{Size in points.
}
379 \helpref{wxFont::GetPointSize
}{wxfontgetpointsize
}
381 \membersection{wxFont::SetStyle
}\label{wxfontsetstyle
}
383 \func{void
}{SetStyle
}{\param{int
}{ style
}}
387 \wxheading{Parameters
}
389 \docparam{style
}{One of
{\bf wxNORMAL
},
{\bf wxSLANT
} and
{\bf wxITALIC
}.
}
393 \helpref{wxFont::GetStyle
}{wxfontgetstyle
}
395 \membersection{wxFont::SetUnderlined
}\label{wxfontsetunderlined
}
397 \func{void
}{SetUnderlined
}{\param{const bool
}{ underlined
}}
401 \wxheading{Parameters
}
403 \docparam{underlining
}{true to underline, false otherwise.
}
407 \helpref{wxFont::GetUnderlined
}{wxfontgetunderlined
}
409 \membersection{wxFont::SetWeight
}\label{wxfontsetweight
}
411 \func{void
}{SetWeight
}{\param{int
}{ weight
}}
413 Sets the font weight.
415 \wxheading{Parameters
}
417 \docparam{weight
}{One of
{\bf wxNORMAL
},
{\bf wxLIGHT
} and
{\bf wxBOLD
}.
}
421 \helpref{wxFont::GetWeight
}{wxfontgetweight
}
423 \membersection{wxFont::operator $=$
}\label{wxfontassignment
}
425 \func{wxFont\&
}{operator $=$
}{\param{const wxFont\&
}{font
}}
427 Assignment operator, using reference counting. Returns a reference
430 \membersection{wxFont::operator $==$
}\label{wxfontequals
}
432 \func{bool
}{operator $==$
}{\param{const wxFont\&
}{font
}}
434 Equality operator. Two fonts are equal if they contain pointers
435 to the same underlying font data. It does not compare each attribute,
436 so two indefontdently-created fonts using the same parameters will
439 \membersection{wxFont::operator $!=$
}\label{wxfontnotequals
}
441 \func{bool
}{operator $!=$
}{\param{const wxFont\&
}{font
}}
443 Inequality operator. Two fonts are not equal if they contain pointers
444 to different underlying font data. It does not compare each attribute.