pyglet.font.group
- class FontGroup
A collection of fonts that can be used like a single font.
Each font can be assigned a range of Unicode values that it is set to handle.
Added in version 3.0.
- __init__(name: str) None
Create a new font group.
- Parameters:
name (
str) – A unique name describing the grouping; must be unique enough to not collide with an existing font.
- add( ) FontGroup
Add a font family responsible for a range of characters.
The first match will be used by layouts.
- Parameters:
family (
str) – The name of the font family for this range.start (
int|str) – The start of the range. This may be a single-character string or an integer corresponding to a Unicode code point.end (
int|str) – The end of the range. This may be a single-character string or an integer corresponding to a Unicode code point.
- Return type:
- Returns:
This existing font group instance.
- class FontGroupInstance
A font instance based off the FontGroup.
- __init__(
- group: FontGroup,
- size: float,
- weight: str | Weight,
- style: str | Style,
- stretch: str | Stretch,
- dpi: int | None,
Initialize a font that can be used with Pyglet.
- Parameters:
name – Font family, for example, “Times New Roman”. If a list of names is provided, the first one matching a known font is used. If no font can be matched to the name(s), a default font is used. The default font will be platform dependent.
size (
float) – Size of the font, in points. The returned font may be an exact match or the closest available.weight (
str|Weight) – If set, a specific weight variant is returned if one exists for the given font family and size. The weight is provided as a string. For example: “bold” or “light”.style (
str|Style) – If True, an italic variant is returned, if one exists for the given family and size. For some Font renderers, italics may have an “oblique” variation which can be specified as a string.stretch (
str|Stretch) – If True, a stretch variant is returned, if one exists for the given family and size. Currently only supported by Windows through theDirectWritefont renderer. For example, “condensed” or “expanded”.dpi (
int|None) – int The assumed resolution of the display device, for the purposes of determining the pixel size of the font. Defaults to 96.