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
}
16 \wxheading{Predefined objects
}
31 \helpref{wxFont overview
}{wxfontoverview
},
\helpref{wxDC::SetFont
}{wxdcsetfont
},
\rtfsp
32 \helpref{wxDC::DrawText
}{wxdcdrawtext
},
\helpref{wxDC::GetTextExtent
}{wxdcgettextextent
},
\rtfsp
33 \helpref{wxFontDialog
}{wxfontdialog
}
35 \latexignore{\rtfignore{\wxheading{Members
}}}
37 \membersection{wxFont::wxFont
}\label{wxfontconstr
}
39 \func{}{wxFont
}{\void}
43 \func{}{wxFont
}{\param{int
}{ pointSize
},
\param{int
}{ family
},
\param{int
}{ style
},
\param{int
}{ weight
},
44 \param{const bool
}{ underline = FALSE
},
\param{const wxString\&
}{faceName = ""
},
45 \param{wxFontEncoding
}{encoding = wxFONTENCODING
\_DEFAULT}}
47 Creates a font object.
49 \wxheading{Parameters
}
51 \docparam{pointSize
}{Size in points.
}
53 \docparam{family
}{Font family, a generic way of referring to fonts without specifying actual facename. One of:
56 \begin{twocollist
}\itemsep=
0pt
57 \twocolitem{{\bf wxDEFAULT
}}{Chooses a default font.
}
58 \twocolitem{{\bf wxDECORATIVE
}}{A decorative font.
}
59 \twocolitem{{\bf wxROMAN
}}{A formal, serif font.
}
60 \twocolitem{{\bf wxSCRIPT
}}{A handwriting font.
}
61 \twocolitem{{\bf wxSWISS
}}{A sans-serif font.
}
62 \twocolitem{{\bf wxMODERN
}}{A fixed pitch font.
}
65 \docparam{style
}{One of
{\bf wxNORMAL
},
{\bf wxSLANT
} and
{\bf wxITALIC
}.
}
67 \docparam{weight
}{One of
{\bf wxNORMAL
},
{\bf wxLIGHT
} and
{\bf wxBOLD
}.
}
69 \docparam{underline
}{The value can be TRUE or FALSE. At present this has an effect on Windows only.
}
71 \docparam{faceName
}{An optional string specifying the actual typeface to be used. If the empty string,
72 a default typeface will chosen based on the family.
}
74 \docparam{encoding
}{An encoding which may be one of
76 \begin{twocollist
}\itemsep=
0pt
77 \twocolitem{{\bf wxFONTENCODING
\_SYSTEM}}{Default system encoding.
}
78 \twocolitem{{\bf wxFONTENCODING
\_DEFAULT}}{Default application encoding: this
79 is the encoding set by calls to
80 \helpref{SetDefaultEncoding
}{wxfontsetdefaultencoding
} and which may be set to,
81 say, KOI8 to create all fonts by default with KOI8 encoding. Initially, the
82 default application encoding is the same as default system encoding.
}
83 \twocolitem{{\bf wxFONTENCODING
\_ISO8859\_1..
.15}}{ISO8859 encodings.
}
84 \twocolitem{{\bf wxFONTENCODING
\_KOI8}}{The standard russian encoding for Internet.
}
85 \twocolitem{{\bf wxFONTENCODING
\_CP1250..
.1252}}{Windows encodings similar to ISO8859 (but not identical).
}
87 If the specified encoding isn't available, no font is created.
92 If the desired font does not exist, the closest match will be chosen.
93 Under Windows, only scaleable TrueType fonts are used.
95 Underlining only works under Windows at present.
97 See also
\helpref{wxDC::SetFont
}{wxdcsetfont
},
\helpref{wxDC::DrawText
}{wxdcdrawtext
}
98 and
\helpref{wxDC::GetTextExtent
}{wxdcgettextextent
}.
100 \membersection{wxFont::
\destruct{wxFont
}}
102 \func{}{\destruct{wxFont
}}{\void}
108 The destructor may not delete the underlying font object of the native windowing
109 system, since wxBrush uses a reference counting system for efficiency.
111 Although all remaining fonts are deleted when the application exits,
112 the application should try to clean up all fonts itself. This is because
113 wxWindows cannot know if a pointer to the font object is stored in an
114 application data structure, and there is a risk of double deletion.
116 \membersection{wxFont::GetFaceName
}\label{wxfontgetfacename
}
118 \constfunc{wxString
}{GetFaceName
}{\void}
120 Returns the typeface name associated with the font, or the empty string if there is no
121 typeface information.
125 \helpref{wxFont::SetFaceName
}{wxfontsetfacename
}
127 \membersection{wxFont::GetFamily
}\label{wxfontgetfamily
}
129 \constfunc{int
}{GetFamily
}{\void}
131 Gets the font family. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
136 \helpref{wxFont::SetFamily
}{wxfontsetfamily
}
138 \membersection{wxFont::GetFontId
}\label{wxfontgetfontid
}
140 \constfunc{int
}{GetFontId
}{\void}
142 Returns the font id, if the portable font system is in operation. See
\helpref{Font overview
}{wxfontoverview
} for
145 \membersection{wxFont::GetPointSize
}\label{wxfontgetpointsize
}
147 \constfunc{int
}{GetPointSize
}{\void}
153 \helpref{wxFont::SetPointSize
}{wxfontsetpointsize
}
155 \membersection{wxFont::GetStyle
}\label{wxfontgetstyle
}
157 \constfunc{int
}{GetStyle
}{\void}
159 Gets the font style. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
164 \helpref{wxFont::SetStyle
}{wxfontsetstyle
}
166 \membersection{wxFont::GetUnderlined
}\label{wxfontgetunderlined
}
168 \constfunc{bool
}{GetUnderlined
}{\void}
170 Returns TRUE if the font is underlined, FALSE otherwise.
174 \helpref{wxFont::SetUnderlined
}{wxfontsetunderlined
}
176 \membersection{wxFont::GetWeight
}\label{wxfontgetweight
}
178 \constfunc{int
}{GetWeight
}{\void}
180 Gets the font weight. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
185 \helpref{wxFont::SetWeight
}{wxfontsetweight
}
187 \membersection{wxFont::SetDefaultEncoding
}\label{wxfontsetdefaultencoding
}
189 \func{static void
}{SetDefaultEncoding
}{\param{wxFontEncoding
}{encoding
}}
191 Sets the default font encoding.
193 \membersection{wxFont::SetFaceName
}\label{wxfontsetfacename
}
195 \func{void
}{SetFaceName
}{\param{const wxString\&
}{faceName
}}
197 Sets the facename for the font.
199 \wxheading{Parameters
}
201 \docparam{faceName
}{A valid facename, which should be on the end-user's system.
}
205 To avoid portability problems, don't rely on a specific face, but specify the font family
206 instead or as well. A suitable font will be found on the end-user's system. If both the
207 family and the facename are specified, wxWindows will first search for the specific face,
208 and then for a font belonging to the same family.
212 \helpref{wxFont::GetFaceName
}{wxfontgetfacename
},
\helpref{wxFont::SetFamily
}{wxfontsetfamily
}
214 \membersection{wxFont::SetFamily
}\label{wxfontsetfamily
}
216 \func{void
}{SetFamily
}{\param{int
}{ family
}}
218 Sets the font family.
220 \wxheading{Parameters
}
222 \docparam{family
}{One of:
225 \begin{twocollist
}\itemsep=
0pt
226 \twocolitem{{\bf wxDEFAULT
}}{Chooses a default font.
}
227 \twocolitem{{\bf wxDECORATIVE
}}{A decorative font.
}
228 \twocolitem{{\bf wxROMAN
}}{A formal, serif font.
}
229 \twocolitem{{\bf wxSCRIPT
}}{A handwriting font.
}
230 \twocolitem{{\bf wxSWISS
}}{A sans-serif font.
}
231 \twocolitem{{\bf wxMODERN
}}{A fixed pitch font.
}
236 \helpref{wxFont::GetFamily
}{wxfontgetfamily
},
\helpref{wxFont::SetFaceName
}{wxfontsetfacename
}
238 \membersection{wxFont::SetPointSize
}\label{wxfontsetpointsize
}
240 \func{void
}{SetPointSize
}{\param{int
}{ pointSize
}}
244 \wxheading{Parameters
}
246 \docparam{pointSize
}{Size in points.
}
250 \helpref{wxFont::GetPointSize
}{wxfontgetpointsize
}
252 \membersection{wxFont::SetStyle
}\label{wxfontsetstyle
}
254 \func{void
}{SetStyle
}{\param{int
}{ style
}}
258 \wxheading{Parameters
}
260 \docparam{style
}{One of
{\bf wxNORMAL
},
{\bf wxSLANT
} and
{\bf wxITALIC
}.
}
264 \helpref{wxFont::GetStyle
}{wxfontgetstyle
}
266 \membersection{wxFont::SetUnderlined
}\label{wxfontsetunderlined
}
268 \func{void
}{SetUnderlined
}{\param{const bool
}{ underlined
}}
272 \wxheading{Parameters
}
274 \docparam{underlining
}{TRUE to underline, FALSE otherwise.
}
278 \helpref{wxFont::GetUnderlined
}{wxfontgetunderlined
}
280 \membersection{wxFont::SetWeight
}\label{wxfontsetweight
}
282 \func{void
}{SetWeight
}{\param{int
}{ weight
}}
284 Sets the font weight.
286 \wxheading{Parameters
}
288 \docparam{weight
}{One of
{\bf wxNORMAL
},
{\bf wxLIGHT
} and
{\bf wxBOLD
}.
}
292 \helpref{wxFont::GetWeight
}{wxfontgetweight
}
294 \membersection{wxFont::operator $=$
}\label{wxfontassignment
}
296 \func{wxFont\&
}{operator $=$
}{\param{const wxFont\&
}{font
}}
298 Assignment operator, using reference counting. Returns a reference
301 \membersection{wxFont::operator $==$
}\label{wxfontequals
}
303 \func{bool
}{operator $==$
}{\param{const wxFont\&
}{font
}}
305 Equality operator. Two fonts are equal if they contain pointers
306 to the same underlying font data. It does not compare each attribute,
307 so two indefontdently-created fonts using the same parameters will
310 \membersection{wxFont::operator $!=$
}\label{wxfontnotequals
}
312 \func{bool
}{operator $!=$
}{\param{const wxFont\&
}{font
}}
314 Inequality operator. Two fonts are not equal if they contain pointers
315 to different underlying font data. It does not compare each attribute.