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 You can retrieve the current system font settings with
\helpref{wxSystemSettings
}{wxsystemsettings
}.
9 \helpref{wxSystemSettings
}{wxsystemsettings
}
11 \wxheading{Derived from
}
13 \helpref{wxGDIObject
}{wxgdiobject
}\\
14 \helpref{wxObject
}{wxobject
}
16 \wxheading{Include files
}
22 The font flags which can be used during the font creation are:
27 // no special flags: font with default weight/slant/anti-aliasing
28 wxFONTFLAG_DEFAULT =
0,
30 // slant flags (default: no slant)
31 wxFONTFLAG_ITALIC =
1 <<
0,
32 wxFONTFLAG_SLANT =
1 <<
1,
34 // weight flags (default: medium)
35 wxFONTFLAG_LIGHT =
1 <<
2,
36 wxFONTFLAG_BOLD =
1 <<
3,
38 // anti-aliasing flag: force on or off (default: the current system default)
39 wxFONTFLAG_ANTIALIASED =
1 <<
4,
40 wxFONTFLAG_NOT_ANTIALIASED =
1 <<
5,
42 // underlined/strikethrough flags (default: no lines)
43 wxFONTFLAG_UNDERLINED =
1 <<
6,
44 wxFONTFLAG_STRIKETHROUGH =
1 <<
7,
48 The known font encodings are:
53 wxFONTENCODING_SYSTEM = -
1, // system default
54 wxFONTENCODING_DEFAULT, // current default encoding
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,
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
81 // what would we do without Microsoft? They have their own encodings
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
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,
100 wxFONTENCODING_UTF7, // UTF-
7 Unicode encoding
101 wxFONTENCODING_UTF8, // UTF-
8 Unicode encoding
103 wxFONTENCODING_UNICODE, // Unicode - currently used only by
104 // wxEncodingConverter class
110 \wxheading{Predefined objects
}
118 {\bf wxNORMAL
\_FONT\\
125 \helpref{wxFont overview
}{wxfontoverview
},
\helpref{wxDC::SetFont
}{wxdcsetfont
},
\rtfsp
126 \helpref{wxDC::DrawText
}{wxdcdrawtext
},
\helpref{wxDC::GetTextExtent
}{wxdcgettextextent
},
\rtfsp
127 \helpref{wxFontDialog
}{wxfontdialog
},
\helpref{wxSystemSettings
}{wxsystemsettings
}
129 \latexignore{\rtfignore{\wxheading{Members
}}}
131 \membersection{wxFont::wxFont
}\label{wxfontconstr
}
133 \func{}{wxFont
}{\void}
137 \func{}{wxFont
}{\param{int
}{ pointSize
},
\param{int
}{ family
},
\param{int
}{ style
},
\param{int
}{ weight
},
138 \param{const bool
}{ underline = false
},
\param{const wxString\&
}{faceName = ""
},
139 \param{wxFontEncoding
}{encoding = wxFONTENCODING
\_DEFAULT}}
141 Creates a font object (see
\helpref{font encoding
142 overview
}{wxfontencodingoverview
} for the meaning of the last parameter).
144 \wxheading{Parameters
}
146 \docparam{pointSize
}{Size in points.
}
148 \docparam{family
}{Font family, a generic way of referring to fonts without specifying actual facename. One of:
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.
}
160 \docparam{style
}{One of
{\bf wxNORMAL
},
{\bf wxSLANT
} and
{\bf wxITALIC
}.
}
162 \docparam{weight
}{One of
{\bf wxNORMAL
},
{\bf wxLIGHT
} and
{\bf wxBOLD
}.
}
164 \docparam{underline
}{The value can be true or false. At present this has an effect on Windows and Motif
2.x only.
}
166 \docparam{faceName
}{An optional string specifying the actual typeface to be used. If the empty string,
167 a default typeface will chosen based on the family.
}
169 \docparam{encoding
}{An encoding which may be one of
171 \begin{twocollist
}\itemsep=
0pt
172 \twocolitem{{\bf wxFONTENCODING
\_SYSTEM}}{Default system encoding.
}
173 \twocolitem{{\bf wxFONTENCODING
\_DEFAULT}}{Default application encoding: this
174 is the encoding set by calls to
175 \helpref{SetDefaultEncoding
}{wxfontsetdefaultencoding
} and which may be set to,
176 say, KOI8 to create all fonts by default with KOI8 encoding. Initially, the
177 default application encoding is the same as default system encoding.
}
178 \twocolitem{{\bf wxFONTENCODING
\_ISO8859\_1..
.15}}{ISO8859 encodings.
}
179 \twocolitem{{\bf wxFONTENCODING
\_KOI8}}{The standard Russian encoding for Internet.
}
180 \twocolitem{{\bf wxFONTENCODING
\_CP1250..
.1252}}{Windows encodings similar to ISO8859 (but not identical).
}
182 If the specified encoding isn't available, no font is created.
187 If the desired font does not exist, the closest match will be chosen.
188 Under Windows, only scalable TrueType fonts are used.
190 See also
\helpref{wxDC::SetFont
}{wxdcsetfont
},
\helpref{wxDC::DrawText
}{wxdcdrawtext
}
191 and
\helpref{wxDC::GetTextExtent
}{wxdcgettextextent
}.
193 \membersection{wxFont::
\destruct{wxFont
}}
195 \func{}{\destruct{wxFont
}}{\void}
201 The destructor may not delete the underlying font object of the native windowing
202 system, since wxFont uses a reference counting system for efficiency.
204 Although all remaining fonts are deleted when the application exits,
205 the application should try to clean up all fonts itself. This is because
206 wxWidgets cannot know if a pointer to the font object is stored in an
207 application data structure, and there is a risk of double deletion.
209 \membersection{wxFont::IsFixedWidth
}\label{wxfontisfixedwidth
}
211 \constfunc{bool
}{IsFixedWidth
}{\void}
213 Returns
{\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.
216 \membersection{wxFont::GetDefaultEncoding
}\label{wxfontgetdefaultencoding
}
218 \func{static wxFontEncoding
}{GetDefaultEncoding
}{\void}
220 Returns the current application's default encoding.
224 \helpref{Font encoding overview
}{wxfontencodingoverview
},
225 \helpref{SetDefaultEncoding
}{wxfontsetdefaultencoding
}
227 \membersection{wxFont::GetFaceName
}\label{wxfontgetfacename
}
229 \constfunc{wxString
}{GetFaceName
}{\void}
231 Returns the typeface name associated with the font, or the empty string if there is no
232 typeface information.
236 \helpref{wxFont::SetFaceName
}{wxfontsetfacename
}
238 \membersection{wxFont::GetFamily
}\label{wxfontgetfamily
}
240 \constfunc{int
}{GetFamily
}{\void}
242 Gets the font family. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
247 \helpref{wxFont::SetFamily
}{wxfontsetfamily
}
249 \membersection{wxFont::GetNativeFontInfoDesc
}\label{wxfontgetnativefontinfodesc
}
251 \constfunc{wxString
}{GetNativeFontInfoDesc
}{\void}
253 Returns the platform-dependent string completely describing this font or an
254 empty string if the font wasn't constructed using the native font description.
258 \helpref{wxFont::SetNativeFontInfo
}{wxfontsetnativefontinfo
}
260 \membersection{wxFont::GetPointSize
}\label{wxfontgetpointsize
}
262 \constfunc{int
}{GetPointSize
}{\void}
268 \helpref{wxFont::SetPointSize
}{wxfontsetpointsize
}
270 \membersection{wxFont::GetStyle
}\label{wxfontgetstyle
}
272 \constfunc{int
}{GetStyle
}{\void}
274 Gets the font style. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
279 \helpref{wxFont::SetStyle
}{wxfontsetstyle
}
281 \membersection{wxFont::GetUnderlined
}\label{wxfontgetunderlined
}
283 \constfunc{bool
}{GetUnderlined
}{\void}
285 Returns true if the font is underlined, false otherwise.
289 \helpref{wxFont::SetUnderlined
}{wxfontsetunderlined
}
291 \membersection{wxFont::GetWeight
}\label{wxfontgetweight
}
293 \constfunc{int
}{GetWeight
}{\void}
295 Gets the font weight. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
300 \helpref{wxFont::SetWeight
}{wxfontsetweight
}
302 \membersection{wxFont::Ok
}\label{wxfontok
}
304 \constfunc{bool
}{Ok
}{\void}
306 Returns
{\tt true
} if this object is a valid font,
{\tt false
} otherwise.
308 \membersection{wxFont::SetDefaultEncoding
}\label{wxfontsetdefaultencoding
}
310 \func{static void
}{SetDefaultEncoding
}{\param{wxFontEncoding
}{encoding
}}
312 Sets the default font encoding.
316 \helpref{Font encoding overview
}{wxfontencodingoverview
},
317 \helpref{GetDefaultEncoding
}{wxfontgetdefaultencoding
}
319 \membersection{wxFont::SetFaceName
}\label{wxfontsetfacename
}
321 \func{void
}{SetFaceName
}{\param{const wxString\&
}{faceName
}}
323 Sets the facename for the font.
325 \wxheading{Parameters
}
327 \docparam{faceName
}{A valid facename, which should be on the end-user's system.
}
331 To avoid portability problems, don't rely on a specific face, but specify the font family
332 instead or as well. A suitable font will be found on the end-user's system. If both the
333 family and the facename are specified, wxWidgets will first search for the specific face,
334 and then for a font belonging to the same family.
338 \helpref{wxFont::GetFaceName
}{wxfontgetfacename
},
\helpref{wxFont::SetFamily
}{wxfontsetfamily
}
340 \membersection{wxFont::SetFamily
}\label{wxfontsetfamily
}
342 \func{void
}{SetFamily
}{\param{int
}{ family
}}
344 Sets the font family.
346 \wxheading{Parameters
}
348 \docparam{family
}{One of:
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.
}
362 \helpref{wxFont::GetFamily
}{wxfontgetfamily
},
\helpref{wxFont::SetFaceName
}{wxfontsetfacename
}
364 \membersection{wxFont::SetNativeFontInfo
}\label{wxfontsetnativefontinfo
}
366 \func{void
}{SetNativeFontInfo
}{\param{const wxString\&
}{info
}}
368 Creates the font corresponding to the given native font description string
369 which must have been previously returned by
370 \helpref{GetNativeFontInfoDesc
}{wxfontgetnativefontinfodesc
}. If the string is
371 invalid, font is unchanged.
373 \membersection{wxFont::SetPointSize
}\label{wxfontsetpointsize
}
375 \func{void
}{SetPointSize
}{\param{int
}{ pointSize
}}
379 \wxheading{Parameters
}
381 \docparam{pointSize
}{Size in points.
}
385 \helpref{wxFont::GetPointSize
}{wxfontgetpointsize
}
387 \membersection{wxFont::SetStyle
}\label{wxfontsetstyle
}
389 \func{void
}{SetStyle
}{\param{int
}{ style
}}
393 \wxheading{Parameters
}
395 \docparam{style
}{One of
{\bf wxNORMAL
},
{\bf wxSLANT
} and
{\bf wxITALIC
}.
}
399 \helpref{wxFont::GetStyle
}{wxfontgetstyle
}
401 \membersection{wxFont::SetUnderlined
}\label{wxfontsetunderlined
}
403 \func{void
}{SetUnderlined
}{\param{const bool
}{ underlined
}}
407 \wxheading{Parameters
}
409 \docparam{underlining
}{true to underline, false otherwise.
}
413 \helpref{wxFont::GetUnderlined
}{wxfontgetunderlined
}
415 \membersection{wxFont::SetWeight
}\label{wxfontsetweight
}
417 \func{void
}{SetWeight
}{\param{int
}{ weight
}}
419 Sets the font weight.
421 \wxheading{Parameters
}
423 \docparam{weight
}{One of
{\bf wxNORMAL
},
{\bf wxLIGHT
} and
{\bf wxBOLD
}.
}
427 \helpref{wxFont::GetWeight
}{wxfontgetweight
}
429 \membersection{wxFont::operator $=$
}\label{wxfontassignment
}
431 \func{wxFont\&
}{operator $=$
}{\param{const wxFont\&
}{font
}}
433 Assignment operator, using reference counting. Returns a reference
436 \membersection{wxFont::operator $==$
}\label{wxfontequals
}
438 \func{bool
}{operator $==$
}{\param{const wxFont\&
}{font
}}
440 Equality operator. Two fonts are equal if they contain pointers
441 to the same underlying font data. It does not compare each attribute,
442 so two indefontdently-created fonts using the same parameters will
445 \membersection{wxFont::operator $!=$
}\label{wxfontnotequals
}
447 \func{bool
}{operator $!=$
}{\param{const wxFont\&
}{font
}}
449 Inequality operator. Two fonts are not equal if they contain pointers
450 to different underlying font data. It does not compare each attribute.