Inheritance diagram for wx.Font:
A font is an object which determines the appearance of text. Fonts are used for drawing text to a device context, and setting the appearance of a window’s text.
This class uses reference counting and copy-on-write internally so that assignments between two instances of this class are very cheap. You can therefore use actual objects instead of pointers without efficiency problems. If an instance of this class is changed it will create its own data internally so that other instances, which previously shared the data using the reference counting, are not affected.
You can retrieve the current system font settings with wx.SystemSettings .
The possible values for the family parameter of wx.Font constructor are:
Family Flag | Description |
---|---|
wx.FONTFAMILY_DEFAULT | Chooses a default font. |
wx.FONTFAMILY_DECORATIVE | A decorative font. |
wx.FONTFAMILY_ROMAN | A formal, serif font. |
wx.FONTFAMILY_SCRIPT | A handwriting font. |
wx.FONTFAMILY_SWISS | A sans-serif font. |
wx.FONTFAMILY_MODERN | Usually a fixed pitch font. |
wx.FONTFAMILY_TELETYPE | A teletype font. |
The possible values for the weight parameter are:
Weight Flag | Description |
---|---|
wx.FONTWEIGHT_NORMAL | Normal font. |
wx.FONTWEIGHT_LIGHT | Light font. |
wx.FONTWEIGHT_BOLD | Bold font. |
The known font encodings are:
Encoding Flag | Description |
---|---|
wx.FONTENCODING_SYSTEM | system default |
wx.FONTENCODING_DEFAULT | current default encoding |
wx.FONTENCODING_ISO8859_1 | West European (Latin1) |
wx.FONTENCODING_ISO8859_2 | Central and East European (Latin2) |
wx.FONTENCODING_ISO8859_3 | Esperanto (Latin3) |
wx.FONTENCODING_ISO8859_4 | Baltic (old) (Latin4) |
wx.FONTENCODING_ISO8859_5 | Cyrillic |
wx.FONTENCODING_ISO8859_6 | Arabic |
wx.FONTENCODING_ISO8859_7 | Greek |
wx.FONTENCODING_ISO8859_8 | Hebrew |
wx.FONTENCODING_ISO8859_9 | Turkish (Latin5) |
wx.FONTENCODING_ISO8859_10 | Variation of Latin4 (Latin6) |
wx.FONTENCODING_ISO8859_11 | Thai |
wx.FONTENCODING_ISO8859_12 | doesn’t exist currently, but put it here anyhow to make all ISO8859 consecutive numbers |
wx.FONTENCODING_ISO8859_13 | Baltic (Latin7) |
wx.FONTENCODING_ISO8859_14 | Latin8 |
wx.FONTENCODING_ISO8859_15 | Latin9 (a.k.a. Latin0, includes euro) |
wx.FONTENCODING_KOI8 | Cyrillic charset |
wx.FONTENCODING_ALTERNATIVE | same as MS-DOS CP866 |
wx.FONTENCODING_BULGARIAN | used under Linux in Bulgaria |
wx.FONTENCODING_CP437 | original MS-DOS codepage |
wx.FONTENCODING_CP850 | CP437 merged with Latin1 |
wx.FONTENCODING_CP852 | CP437 merged with Latin2 |
wx.FONTENCODING_CP855 | another cyrillic encoding |
wx.FONTENCODING_CP866 | and another one |
wx.FONTENCODING_CP874 | WinThai |
wx.FONTENCODING_CP1250 | WinLatin2 |
wx.FONTENCODING_CP1251 | WinCyrillic |
wx.FONTENCODING_CP1252 | WinLatin1 |
wx.FONTENCODING_CP1253 | WinGreek (8859-7) |
wx.FONTENCODING_CP1254 | WinTurkish |
wx.FONTENCODING_CP1255 | WinHebrew |
wx.FONTENCODING_CP1256 | WinArabic |
wx.FONTENCODING_CP1257 | WinBaltic (same as Latin 7) |
wx.FONTENCODING_UTF7 | UTF-7 Unicode encoding |
wx.FONTENCODING_UTF8 | UTF-8 Unicode encoding |
Creates a font object with the specified attributes.
Parameters:
Returns:
See also
wx.FFont, wx.FontFromPixelSize, wx.FFontFromPixelSize, wx.FontFromNativeInfoString, wx.FontFromNativeInfo
Returns the current application’s default encoding.
Returns:
int
See also
Get the font’s encoding.
Returns:
int
Returns the typeface name associated with the font, or the empty string if there is no typeface information.
Returns:
string
See also
Gets the font family. See SetFamily for a list of valid family identifiers.
Returns:
int
See also
Returns a string representation of the font family.
Returns:
string
Constructs a wx.NativeFontInfo object from this font.
Returns:
Returns the platform-dependent string completely describing this font. Returned string is always non-empty.
Returns:
string
Note
Note that the returned string is not meant to be shown or edited by the user: a typical use of this function is for serializing in string-form a wx.Font object.
See also
Returns a user-friendly string for this font object. Returned string is always non-empty. Some examples of the formats of returned strings (which are platform-dependent) are in SetNativeFontInfoUserDesc.
Returns:
string
See also
Returns the size in pixels if the font was constructed with a pixel size.
Returns:
Gets the point size.
Returns:
int
See also
Gets the font style.
Returns:
int
See also
Returns a string representation of the font style.
Returns:
string
Returns True if the font is underlined, False otherwise.
Returns:
bool
See also
Gets the font weight.
Returns:
int
See also
Return a string representation of the font weight.
Returns:
string
Returns True if the font is a fixed width (or monospaced) font, False if it is a proportional one or font is invalid.
Returns:
bool
Returns True if this object is a valid font, False otherwise.
Returns:
bool
Returns True if the font is using a pixelSize.
Returns:
bool
Sets the default font encoding.
Parameters:
See also
Set the font encoding.
Parameters:
Sets the facename for the font. Returns True if the given face name exists; False otherwise.
Parameters:
Returns:
bool
Note
To a portability problems, don’t rely on a specific face, but specify the font family instead or as well. A suitable font will be found on the end-user’s system. If both the family and the facename are specified, wxWidgets will first search for the specific face, and then for a font belonging to the same family.
See also
Sets the font family.
Parameters:
family (int): One of:
Font Family Constant |
Description |
---|---|
wx.FONTFAMILY_DEFAULT |
Chooses a default font. |
wx.FONTFAMILY_DECORATIVE |
A decorative font. |
wx.FONTFAMILY_ROMAN |
A formal, serif font. |
wx.FONTFAMILY_SCRIPT |
A handwriting font. |
wx.FONTFAMILY_SWISS |
A sans-serif font. |
wx.FONTFAMILY_MODERN |
A fixed pitch font. |
wx.FONTFAMILY_TELETYPE |
A teletype font. |
See also
Creates the font corresponding to the given native font description string and returns True if the creation was successful. which must have been previously returned by GetNativeFontInfoDesc .
If the string is invalid, font state is undefined (it becomes invalid in 2.8 but this shouldn’t be relied on as the next wxWidgets version leaves it unchanged instead). This function is typically used for de-serializing a wx.Font object previously saved in a string-form.
Parameters:
Returns:
bool
See also
Set the font’s attributes from string representation of a wx.NativeFontInfo object.
Parameters:
Returns:
bool
Creates the font corresponding to the given native font description string and returns True if the creation was successful. Unlike SetNativeFontInfo , this function accepts strings which are user-friendly.
Examples of accepted string formats are:
Generic syntax | Example |
---|---|
On wxGTK2: [FACE-NAME] [bold] [oblique|italic] [POINTSIZE] | Monospace bold 10 |
On wxMSW: [light|bold] [italic] [FACE-NAME] [POINTSIZE] [ENCODING] | Tahoma 10 WINDOWS-1252 |
On wxMac: FIXME | FIXME |
For more detailed information about the allowed syntaxes you can look at the documentation of the native API used for font-rendering.
Parameters:
Returns:
bool
See also
Parameters:
Sets the size in pixels rather than points. If there is platform API support for this then it is used, otherwise a font with the closest size is found using a binary search.
Parameters:
Sets the point size.
Parameters:
See also
Sets the font style.
Parameters:
See also
Sets underlining.
Parameters:
See also
Sets the font weight.
Parameters:
weight (int): One of:
Font Weight Constant |
Description |
---|---|
wx.FONTWEIGHT_NORMAL |
Normal font. |
wx.FONTWEIGHT_LIGHT |
Light font. |
wx.FONTWEIGHT_BOLD |
Bold font. |
See also