wx.FontEnumerator¶
wx.FontEnumerator enumerates either all available fonts on the system or only the ones with given attributes - either only fixed-width (suited for use in programs such as terminal emulators and the like) or the fonts available in the given encoding).
To do this, you just have to call one of EnumerateXXX() functions - either wx.FontEnumerator.EnumerateFacenames
or wx.FontEnumerator.EnumerateEncodings
and the corresponding callback ( wx.FontEnumerator.OnFacename
or wx.FontEnumerator.OnFontEncoding
) will be called repeatedly until either all fonts satisfying the specified criteria are exhausted or the callback returns False
.
Virtual functions to override¶
Either OnFacename or OnFontEncoding should be overridden depending on whether you plan to call EnumerateFacenames or EnumerateEncodings. Of course, if you call both of them, you should override both functions.
See also
Font Encodings, Font Sample, wx.Font, wx.FontMapper
Class Hierarchy¶
Methods Summary¶
Call |
|
Call |
|
Return array of strings containing all encodings found by |
|
Return array of strings containing all facenames found by |
|
Invalidate cache used by some of the methods of this class internally. |
|
Returns |
|
Called by |
|
Called by |
Class API¶
- class wx.FontEnumerator(object)¶
Possible constructors:
FontEnumerator() -> None
FontEnumerator enumerates either all available fonts on the system or only the ones with given attributes - either only fixed-width (suited for use in programs such as terminal emulators and the like) or the fonts available in the given encoding).
Methods¶
- __init__(self)¶
- Return type:
None
- EnumerateEncodings(self, font='')¶
Call
OnFontEncoding
for each encoding supported by the given font - or for each encoding supported by at least some font if font is not specified.- Parameters:
font (string)
- Return type:
bool
- EnumerateFacenames(self, encoding=FONTENCODING_SYSTEM, fixedWidthOnly=False)¶
Call
OnFacename
for each font which supports given encoding (only if it is notFONTENCODING_SYSTEM
) and is of fixed width (if fixedWidthOnly isTrue
).Calling this function with default arguments will result in enumerating all fonts available on the system.
- Parameters:
encoding (FontEncoding)
fixedWidthOnly (bool)
- Return type:
bool
- static GetEncodings(facename='')¶
Return array of strings containing all encodings found by
EnumerateEncodings
.- Parameters:
facename (string)
- Return type:
List[str]
- static GetFacenames(encoding=FONTENCODING_SYSTEM, fixedWidthOnly=False)¶
Return array of strings containing all facenames found by
EnumerateFacenames
.- Parameters:
encoding (FontEncoding)
fixedWidthOnly (bool)
- Return type:
List[str]
- static InvalidateCache()¶
Invalidate cache used by some of the methods of this class internally.
This method should be called if the list of the fonts available on the system changes, for whatever reason. In particular, it is called automatically by
wx.Font.AddPrivateFont
.- Return type:
None
Added in version 4.1/wxWidgets-3.1.1.
- static IsValidFacename(facename)¶
Returns
True
if the given string is valid face name, i.e.it’s the face name of an installed font and it can safely be used with
wx.Font.SetFaceName
.- Parameters:
facename (string)
- Return type:
bool
- OnFacename(self, font)¶
Called by
EnumerateFacenames
for each match.Return
True
to continue enumeration orFalse
to stop it.- Parameters:
font (string)
- Return type:
bool
- OnFontEncoding(self, font, encoding)¶
Called by
EnumerateEncodings
for each match.Return
True
to continue enumeration orFalse
to stop it.- Parameters:
font (string)
encoding (string)
- Return type:
bool