pyglet.font.group
- class FontGroup(name: str) None
An ordered set of fallback font families.
Each character is rendered by the first added family that contains it. If no family contains a character, the first family supplies its normal missing-glyph representation.
Added in version 3.0.
- class FontGroupBase(name: str) None
Base class for a collection of fonts used as one font.
Applications normally use
FontGroupfor ordered glyph fallback, orFontRangeGroupwhen they need explicit Unicode-range routing.
- class FontGroupInstance(
- group: FontGroupBase,
- size: float,
- weight: Weight | str,
- style: Style | str,
- stretch: Stretch | str,
- dpi: int | None,
A font instance based on a
FontGroupBase.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 (
Weight|str) – 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 (
Style|str) – Font slant, as a string orStylevalue: “normal”, “italic”, or “oblique”.stretch (
Stretch|str) – 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.
- classmethod add_font_data(
- data: bytes,
- manager: FontManager,
Font groups are composite fonts and cannot register font data.
- Return type:
- classmethod have_font(name: str) bool
Font groups do not represent an installed system font.
- Return type:
- get_glyphs( ) tuple[list[Glyph], list[GlyphPosition]]
Create and return a list of Glyphs for text.
If any characters do not have a known glyph representation in this font, a substitution will be made.
- get_text_size(text: str) tuple[int, int]
Return estimated text width and height in pixels, rounded up to integers.
Uses glyph metrics without rendering and does not take into account any shaping.
- has_character(character: str) bool
Return whether this font face contains a glyph for one character.
This query only considers the selected face. It does not report glyphs that a platform renderer might obtain through system font fallback.
Added in version 3.0.0.
charactermust contain exactly one Unicode character.
- class FontRangeGroup(name: str) None
A collection of fonts selected by explicit Unicode ranges.
The first matching range chooses the family. If no range matches, the first added family is used. Unlike
FontGroup, this class does not probe subsequent families for missing characters.Added in version 3.0.
- add( ) FontRangeGroup
Add a font family responsible for a range of characters.
- Return type: