wx.FontInfo¶
This class is a helper used for wx.Font creation using named parameter idiom: it allows specifying various wx.Font attributes using the chained calls to its clearly named methods instead of passing them in the fixed order to wx.Font constructors.
For example, to create an italic font with the given face name and size you could use:
font = wx.Font(wx.FontInfo(12).FaceName("Helvetica").Italic())
Notice that all of the methods of this object return a reference to the object itself, allowing the calls to them to be chained as in the example above.
All methods taking boolean parameters can be used to turn the specified font attribute on or off and turn it on by default.
Added in version 2.9.5.
Class Hierarchy¶
Methods Summary¶
Default constructor uses the default font size for the current platform. |
|
Set all the font attributes at once. |
|
Set anti-aliasing flag. |
|
Use a bold version of the font. |
|
Set the font encoding to use. |
|
Set the font face name to use. |
|
Set the font family. |
|
Get the symbolic weight closest to the given raw weight value. |
|
Use an italic version of the font. |
|
Use a lighter version of the font. |
|
Use a slanted version of the font. |
|
Use a strike-through version of the font. |
|
Specify the style of the font using one of FontStyle constants. |
|
Use an underlined version of the font. |
|
Specify the weight of the font. |
Class API¶
- class wx.FontInfo(object)¶
Possible constructors:
FontInfo() -> None FontInfo(pointSize) -> None FontInfo(pixelSize) -> None
This class is a helper used for Font creation using named parameter idiom: it allows specifying various Font attributes using the chained calls to its clearly named methods instead of passing them in the fixed order to Font constructors.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
Default constructor uses the default font size for the current platform.
- Return type:
None
__init__ (self, pointSize)
Constructor setting the font size in points to use.
Note that until wxWidgets 3.1.2 fractional point sizes were not supported, and the type of pointSize was
int
.- Parameters:
pointSize (float)
- Return type:
None
See also
__init__ (self, pixelSize)
Constructor setting the font size in pixels to use.
- Parameters:
pixelSize (wx.Size)
- Return type:
None
See also
- AllFlags(self, flags)¶
Set all the font attributes at once.
See wx.FontFlag for the various flags that can be used.
Note that calling this method affects the font weight stored in this object: it is set to
FONTWEIGHT_LIGHT
orFONTWEIGHT_BOLD
if the corresponding flag is present in flags, orFONTWEIGHT_NORMAL
otherwise.- Parameters:
flags (int)
- Return type:
- AntiAliased(self, antiAliased=True)¶
Set anti-aliasing flag.
Force the use of anti-aliasing on or off.
Currently this is not implemented, i.e. using this method doesn’t do anything.
- Parameters:
antiAliased (bool)
- Return type:
- Bold(self, bold=True)¶
Use a bold version of the font.
This is a wrapper for
Weight
calling it withFONTWEIGHT_BOLD
argument.- Parameters:
bold (bool)
- Return type:
See also
- Encoding(self, encoding)¶
Set the font encoding to use.
This is mostly unneeded in Unicode builds of wxWidgets.
- Parameters:
encoding (FontEncoding)
- Return type:
See also
- FaceName(self, faceName)¶
Set the font face name to use.
Face names are not portable, so prefer to use
Family
in portable code.- Parameters:
faceName (string)
- Return type:
See also
- Family(self, family)¶
Set the font family.
The family is a generic portable way of referring to fonts without specifying a precise face name. This parameter must be one of the wx.FontFamily enumeration values.
If the
FaceName
is used, then it overrides the font family.- Parameters:
family (FontFamily)
- Return type:
See also
- static GetWeightClosestToNumericValue(numWeight)¶
Get the symbolic weight closest to the given raw weight value.
- Parameters:
numWeight (int) – A valid raw weight value, i.e. a value in the range 1 to 1000, inclusive.
- Return type:
- Returns:
A valid element of FontWeight enum.
Added in version 4.1/wxWidgets-3.1.2.
- Italic(self, italic=True)¶
Use an italic version of the font.
This is a wrapper for
Style
calling it withFONTSTYLE_ITALIC
argument.- Parameters:
italic (bool)
- Return type:
See also
- Light(self, light=True)¶
Use a lighter version of the font.
This is a wrapper for
Weight
calling it withFONTWEIGHT_LIGHT
argument.- Parameters:
light (bool)
- Return type:
See also
- Slant(self, slant=True)¶
Use a slanted version of the font.
This is a wrapper for
Style
calling it withFONTSTYLE_SLANT
argument.- Parameters:
slant (bool)
- Return type:
See also
- Strikethrough(self, strikethrough=True)¶
Use a strike-through version of the font.
Currently this is only implemented in wxMSW, wxGTK, and wxOSX.
- Parameters:
strikethrough (bool)
- Return type:
- Style(self, style)¶
Specify the style of the font using one of FontStyle constants.
- Parameters:
style (FontStyle)
- Return type:
Added in version 4.1/wxWidgets-3.1.2.
- Underlined(self, underlined=True)¶
Use an underlined version of the font.
- Parameters:
underlined (bool)
- Return type:
- Weight(self, weight)¶
Specify the weight of the font.
- Parameters:
weight (int) – A font weight in the range from 1 to 1000, inclusive, with 1 being the thinnest and 1000 the heaviest possible font variant.
FONTWEIGHT_XXX
values from FontWeight enum can be used here.- Return type:
Added in version 4.1/wxWidgets-3.1.2.