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 (see
\helpref{font encoding
48 overview
}{wxfontencodingoverview
} for the meaning of the last parameter).
50 \wxheading{Parameters
}
52 \docparam{pointSize
}{Size in points.
}
54 \docparam{family
}{Font family, a generic way of referring to fonts without specifying actual facename. One of:
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.
}
66 \docparam{style
}{One of
{\bf wxNORMAL
},
{\bf wxSLANT
} and
{\bf wxITALIC
}.
}
68 \docparam{weight
}{One of
{\bf wxNORMAL
},
{\bf wxLIGHT
} and
{\bf wxBOLD
}.
}
70 \docparam{underline
}{The value can be TRUE or FALSE. At present this has an effect on Windows only.
}
72 \docparam{faceName
}{An optional string specifying the actual typeface to be used. If the empty string,
73 a default typeface will chosen based on the family.
}
75 \docparam{encoding
}{An encoding which may be one of
77 \begin{twocollist
}\itemsep=
0pt
78 \twocolitem{{\bf wxFONTENCODING
\_SYSTEM}}{Default system encoding.
}
79 \twocolitem{{\bf wxFONTENCODING
\_DEFAULT}}{Default application encoding: this
80 is the encoding set by calls to
81 \helpref{SetDefaultEncoding
}{wxfontsetdefaultencoding
} and which may be set to,
82 say, KOI8 to create all fonts by default with KOI8 encoding. Initially, the
83 default 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).
}
88 If the specified encoding isn't available, no font is created.
93 If the desired font does not exist, the closest match will be chosen.
94 Under Windows, only scaleable TrueType fonts are used.
96 Underlining only works under Windows at present.
98 See also
\helpref{wxDC::SetFont
}{wxdcsetfont
},
\helpref{wxDC::DrawText
}{wxdcdrawtext
}
99 and
\helpref{wxDC::GetTextExtent
}{wxdcgettextextent
}.
101 \membersection{wxFont::
\destruct{wxFont
}}
103 \func{}{\destruct{wxFont
}}{\void}
109 The destructor may not delete the underlying font object of the native windowing
110 system, since wxFont uses a reference counting system for efficiency.
112 Although all remaining fonts are deleted when the application exits,
113 the application should try to clean up all fonts itself. This is because
114 wxWindows cannot know if a pointer to the font object is stored in an
115 application data structure, and there is a risk of double deletion.
117 \membersection{wxFont::GetDefaultEncoding
}\label{wxfontgetdefaultencoding
}
119 \func{static wxFontEncoding
}{GetDefaultEncoding
}{\void}
121 Returns the current applications default encoding.
125 \helpref{Font encoding overview
}{wxfontencodingoverview
},
126 \helpref{SetDefaultEncoding
}{wxfontsetdefaultencoding
}
128 \membersection{wxFont::GetFaceName
}\label{wxfontgetfacename
}
130 \constfunc{wxString
}{GetFaceName
}{\void}
132 Returns the typeface name associated with the font, or the empty string if there is no
133 typeface information.
137 \helpref{wxFont::SetFaceName
}{wxfontsetfacename
}
139 \membersection{wxFont::GetFamily
}\label{wxfontgetfamily
}
141 \constfunc{int
}{GetFamily
}{\void}
143 Gets the font family. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
148 \helpref{wxFont::SetFamily
}{wxfontsetfamily
}
150 \membersection{wxFont::GetFontId
}\label{wxfontgetfontid
}
152 \constfunc{int
}{GetFontId
}{\void}
154 Returns the font id, if the portable font system is in operation. See
\helpref{Font overview
}{wxfontoverview
} for
157 \membersection{wxFont::GetPointSize
}\label{wxfontgetpointsize
}
159 \constfunc{int
}{GetPointSize
}{\void}
165 \helpref{wxFont::SetPointSize
}{wxfontsetpointsize
}
167 \membersection{wxFont::GetStyle
}\label{wxfontgetstyle
}
169 \constfunc{int
}{GetStyle
}{\void}
171 Gets the font style. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
176 \helpref{wxFont::SetStyle
}{wxfontsetstyle
}
178 \membersection{wxFont::GetUnderlined
}\label{wxfontgetunderlined
}
180 \constfunc{bool
}{GetUnderlined
}{\void}
182 Returns TRUE if the font is underlined, FALSE otherwise.
186 \helpref{wxFont::SetUnderlined
}{wxfontsetunderlined
}
188 \membersection{wxFont::GetWeight
}\label{wxfontgetweight
}
190 \constfunc{int
}{GetWeight
}{\void}
192 Gets the font weight. See
\helpref{wxFont::wxFont
}{wxfontconstr
} for a list of valid
197 \helpref{wxFont::SetWeight
}{wxfontsetweight
}
199 \membersection{wxFont::SetDefaultEncoding
}\label{wxfontsetdefaultencoding
}
201 \func{static void
}{SetDefaultEncoding
}{\param{wxFontEncoding
}{encoding
}}
203 Sets the default font encoding.
207 \helpref{Font encoding overview
}{wxfontencodingoverview
},
208 \helpref{GetDefaultEncoding
}{wxfontgetdefaultencoding
}
210 \membersection{wxFont::SetFaceName
}\label{wxfontsetfacename
}
212 \func{void
}{SetFaceName
}{\param{const wxString\&
}{faceName
}}
214 Sets the facename for the font.
216 \wxheading{Parameters
}
218 \docparam{faceName
}{A valid facename, which should be on the end-user's system.
}
222 To avoid portability problems, don't rely on a specific face, but specify the font family
223 instead or as well. A suitable font will be found on the end-user's system. If both the
224 family and the facename are specified, wxWindows will first search for the specific face,
225 and then for a font belonging to the same family.
229 \helpref{wxFont::GetFaceName
}{wxfontgetfacename
},
\helpref{wxFont::SetFamily
}{wxfontsetfamily
}
231 \membersection{wxFont::SetFamily
}\label{wxfontsetfamily
}
233 \func{void
}{SetFamily
}{\param{int
}{ family
}}
235 Sets the font family.
237 \wxheading{Parameters
}
239 \docparam{family
}{One of:
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.
}
253 \helpref{wxFont::GetFamily
}{wxfontgetfamily
},
\helpref{wxFont::SetFaceName
}{wxfontsetfacename
}
255 \membersection{wxFont::SetPointSize
}\label{wxfontsetpointsize
}
257 \func{void
}{SetPointSize
}{\param{int
}{ pointSize
}}
261 \wxheading{Parameters
}
263 \docparam{pointSize
}{Size in points.
}
267 \helpref{wxFont::GetPointSize
}{wxfontgetpointsize
}
269 \membersection{wxFont::SetStyle
}\label{wxfontsetstyle
}
271 \func{void
}{SetStyle
}{\param{int
}{ style
}}
275 \wxheading{Parameters
}
277 \docparam{style
}{One of
{\bf wxNORMAL
},
{\bf wxSLANT
} and
{\bf wxITALIC
}.
}
281 \helpref{wxFont::GetStyle
}{wxfontgetstyle
}
283 \membersection{wxFont::SetUnderlined
}\label{wxfontsetunderlined
}
285 \func{void
}{SetUnderlined
}{\param{const bool
}{ underlined
}}
289 \wxheading{Parameters
}
291 \docparam{underlining
}{TRUE to underline, FALSE otherwise.
}
295 \helpref{wxFont::GetUnderlined
}{wxfontgetunderlined
}
297 \membersection{wxFont::SetWeight
}\label{wxfontsetweight
}
299 \func{void
}{SetWeight
}{\param{int
}{ weight
}}
301 Sets the font weight.
303 \wxheading{Parameters
}
305 \docparam{weight
}{One of
{\bf wxNORMAL
},
{\bf wxLIGHT
} and
{\bf wxBOLD
}.
}
309 \helpref{wxFont::GetWeight
}{wxfontgetweight
}
311 \membersection{wxFont::operator $=$
}\label{wxfontassignment
}
313 \func{wxFont\&
}{operator $=$
}{\param{const wxFont\&
}{font
}}
315 Assignment operator, using reference counting. Returns a reference
318 \membersection{wxFont::operator $==$
}\label{wxfontequals
}
320 \func{bool
}{operator $==$
}{\param{const wxFont\&
}{font
}}
322 Equality operator. Two fonts are equal if they contain pointers
323 to the same underlying font data. It does not compare each attribute,
324 so two indefontdently-created fonts using the same parameters will
327 \membersection{wxFont::operator $!=$
}\label{wxfontnotequals
}
329 \func{bool
}{operator $!=$
}{\param{const wxFont\&
}{font
}}
331 Inequality operator. Two fonts are not equal if they contain pointers
332 to different underlying font data. It does not compare each attribute.