Class: wxFont
A font is an object which determines the appearance of text, primarily when drawing text to a canvas or device context. A font is determined by up to six parameters:
Point size | This is the standard way of referring to text size. |
Family | 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. |
Face name | An optional string specifying the actual typeface to be used. If NULL, a default typeface will chosen based on the family. |
Specifying a family, rather than a specific typeface name, ensures a degree of portability across platforms because a suitable font will be chosen for the given font family.
Under Windows, the face name can be one of the installed fonts on the user's system. Since the choice of fonts differs from system to system, either choose standard Windows fonts, or if allowing the user to specify a face name, store the family id with any file that might be transported to a different Windows machine or other platform.
Under X, the situation is more complicated because X does not support a simple naming scheme that will allow consistent naming of screen and printer fonts. To address this, wxWindows implements a font name directory with a naming convention to support screen and PostScript fonts. Under this scheme, the 'family' parameter can also be used as a font identifier. However, if you wish, you may still use the family parameter in exactly the same way as before without needing to understand the enhanced usage.
Class: wxFontNameDirectory
The font name directory helps implement the portable font scheme used in the X versions of wxWindows, and optionally under Windows.
To draw text, you need a font id, weight, style, size, and underline flag. The combination font id x weight x style maps to a"real" platform-specific font.
Every font id is associated to one of a fixed number of family ids. Each of these family ids can be used as a font id, specifying a default font for that family. When font information is stored in a document that may cross platforms, the family id should be specified so that a reasonable default font can be selected on the new platform.
Each font id is associated to a name (corresponding to the "facename" in Windows). This name should be used to store information about a font on disk, since the font id used for a particular font name can change when a wxWindows application is restarted.
The font constructor:
wxFont(int pointSize, int damilyOrFontId, int style, int weight, Bool underline = FALSE, char *faceName = NULL);has changed if the new scheme is in operation. When faceName is NULL, familyOrFontId (formerly familyId) can be any font id. Recall that a family id can always be used as a font id. When faceName is not NULL, then familyOrFontId must be a family id. If the specified faceName cannot be found, then a default font for the family id (passed as familyOrFontId) will be used.
The mappings:
are managed by a single instance of wxFontNameDirectory.