phoenix_title 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.

New in version 2.9.5.


class_hierarchy Class Hierarchy

Inheritance diagram for class FontInfo:

method_summary Methods Summary

__init__

Default constructor uses the default font size for the current platform.

AllFlags

Set all the font attributes at once.

AntiAliased

Set anti-aliasing flag.

Bold

Use a bold version of the font.

Encoding

Set the font encoding to use.

FaceName

Set the font face name to use.

Family

Set the font family.

GetWeightClosestToNumericValue

Get the symbolic weight closest to the given raw weight value.

Italic

Use an italic version of the font.

Light

Use a lighter version of the font.

Slant

Use a slanted version of the font.

Strikethrough

Use a strike-through version of the font.

Style

Specify the style of the font using one of FontStyle constants.

Underlined

Use an underlined version of the font.

Weight

Specify the weight of the font.


api Class API

class wx.FontInfo(object)

Possible constructors:

FontInfo()

FontInfo(pointSize)

FontInfo(pixelSize)

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)

overload Overloaded Implementations:



__init__ (self)

Default constructor uses the default font size for the current platform.



__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) –

See also

wx.Font.SetPointSize



__init__ (self, pixelSize)

Constructor setting the font size in pixels to use.

Parameters:

pixelSize (wx.Size) –



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 or FONTWEIGHT_BOLD if the corresponding flag is present in flags, or FONTWEIGHT_NORMAL otherwise.

Parameters:

flags (int) –

Return type:

wx.FontInfo



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:

wx.FontInfo



Bold(self, bold=True)

Use a bold version of the font.

This is a wrapper for Weight calling it with FONTWEIGHT_BOLD argument.

Parameters:

bold (bool) –

Return type:

wx.FontInfo



Encoding(self, encoding)

Set the font encoding to use.

This is mostly unneeded in Unicode builds of wxWidgets.

Parameters:

encoding (FontEncoding) –

Return type:

wx.FontInfo



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:

wx.FontInfo



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:

wx.FontInfo



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:

wx.FontWeight

Returns:

A valid element of FontWeight enum.

New 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 with FONTSTYLE_ITALIC argument.

Parameters:

italic (bool) –

Return type:

wx.FontInfo



Light(self, light=True)

Use a lighter version of the font.

This is a wrapper for Weight calling it with FONTWEIGHT_LIGHT argument.

Parameters:

light (bool) –

Return type:

wx.FontInfo



Slant(self, slant=True)

Use a slanted version of the font.

This is a wrapper for Style calling it with FONTSTYLE_SLANT argument.

Parameters:

slant (bool) –

Return type:

wx.FontInfo



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:

wx.FontInfo



Style(self, style)

Specify the style of the font using one of FontStyle constants.

Parameters:

style (FontStyle) –

Return type:

wx.FontInfo

New in version 4.1/wxWidgets-3.1.2.



Underlined(self, underlined=True)

Use an underlined version of the font.

Parameters:

underlined (bool) –

Return type:

wx.FontInfo



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:

wx.FontInfo

New in version 4.1/wxWidgets-3.1.2.