Contents Up Previous Next

wxFont: wxObject

Overview

A font is an object which determines the appearance of text, primarily when drawing text to a canvas or device context.

wxFont::wxFont
wxFont::~wxFont
wxFont::GetFaceName
wxFont::GetFamily
wxFont::GetFontId
wxFont::GetPointSize
wxFont::GetStyle
wxFont::GetUnderlined
wxFont::GetWeight


wxFont::wxFont

void wxFont(void)

void wxFont(int point_size, int family, int style, int weight, Bool underline = FALSE, const char *face_name = NULL)

Creates a font object. These are the arguments:

point_size This is the standard way of referring to text size.
family A 'family' of related font faces, giving a measure of independence from the actual typefaces available on a computer. Supported families are: wxDEFAULT, wxDECORATIVE, wxROMAN, wxSCRIPT, wxSWISS, wxMODERN. wxMODERN is a fixed pitch font; the others are either fixed or variable pitch.
style The value can be wxNORMAL, wxSLANT or wxITALIC.
weight The value can be wxNORMAL, wxLIGHT or wxBOLD.
underlining The value can be TRUE or FALSE (MS Windows only).
face_name An optional string specifying the actual typeface to be used. If NULL, a default typeface will chosen based on the family.

If the desired font does not exist, the closest match will be chosen. Under XView, this may result in a number of XView warnings during the matching process; these should be ignored, and will only occur the first time wxWindows attempts to use an absent font in a given size. wxWindows under Motif does the same thing, but silently. Under MS Windows, only scaleable TrueType fonts are used.

Underlining only works under MS Windows at present.

See also wxDC::SetFont, wxDC::DrawText and wxDC::GetTextExtent.

All fonts are automatically added to the global pointer wxTheFontList. Call wxFontList::FindOrCreateFont to return a previously-created font if possible.


wxFont::~wxFont

void ~wxFont(void)

Destroys a font object. Do not manually destroy a font which has been assigned to a canvas. All GDI objects, including fonts, are automatically destroyed on program exit, so there is no danger of memory leakage as in conventional Windows programming.

If you have to delete the font (for example, you are creating a lot of them), then call wxDC::SetFont with a NULL argument to ensure that the old font is restored, and the current font is selected out of the device context.


wxFont::GetFaceName

char * GetFaceName(void)

Returns the typeface name associated with the font, or NULL if there is no typeface information.


wxFont::GetFamily

int GetFamily(void)

Gets the font family. See wxFont for a list of valid family identifiers.


wxFont::GetFontId

int GetFontId(void)

Returns the font id, if the portable font system is in operation. See Font overview for further details.


wxFont::GetPointSize

int GetPointSize(void)

Gets the point size.


wxFont::GetStyle

int GetStyle(void)

Gets the font style. See wxFont for a list of valid styles.


wxFont::GetUnderlined

Bool GetUnderlined(void)

TRUE if the font is underlined.


wxFont::GetWeight

int GetWeight(void)

Gets the font weight. See wxFont for a list of valid weight identifiers.