Skip to main content

FontInfo

ClassDataClassSource

FontInfo(names: dict[FontLanguage, FontNameInfo], index: int = 0, path: str)

The basic font information.

Fields​

NameTypeRequired
Description
namesdict[FontLanguage, FontNameInfo]The multi-lingual names of this font. All font names here are "full" names.
indexintThe font index. This value is used only when the font is ttc. Otherwise, this value should be 0.
pathstrThe full path to the font file.

Methods​

get_font​

v_1: FreeTypeFont = self.get_font(size: int = 10)

Load the Pillow FreeTypeFont.

Requires​

NameTypeRequired
Description
sizeintThe font size.

Returns​

NameType
Description
v_1FreeTypeFontThe loaded font.

get_name​

v_1: str = self.get_name(lang: str | FontLanguage = FontLanguage.en)

Get the best name of this font.

Will use the given language to search the font name. If not found, use the English language to search the font name. If still not found, will use the first available language of the font to get the font name.

Requires​

NameTypeRequired
Description
langstr | FontLanguageThe language name or code used for searching he font.

Returns​

NameType
Description
v_1strThe best string name of the font.

Properties​

langs​

langs: list[FontLanguage] = self.langs

List the supported languages.