Fonts¶
Overview¶
|
A font. |
A font family. |
|
A unique per database face ID. |
|
A CSS font-stretch. |
|
Allows italic or oblique faces to be selected. |
|
Specifies the weight of glyphs in the font, their degree of blackness or stroke thickness. |
|
|
Performs a CSS-like query and returns the best matched font face. |
List loaded system fonts. |
Details¶
- class pyiced.Font(name, data)¶
A font.
The font does not get loaded multiple times, but instead the name is used to tell fonts apart. So you should use the same name for the same data in subsequent Font instance creations.
- Parameters
name (str) – The name of the external font
data (bytes-like) – The bytes of the external font
See also
Warning
The font data gets interned! Even of the module is unloaded / reloaded, some memory is lost until the interpreter is restarted.
- DEFAULT = Font.DEFAULT¶
- class pyiced.FontFamily¶
A font family.
See also
- CURSIVE = FontFamily.CURSIVE¶
- FANTASY = FontFamily.FANTASY¶
- MONOSPACE = FontFamily.MONOSPACE¶
- SANSSERIF = FontFamily.SANSSERIF¶
- SERIF = FontFamily.SERIF¶
- class pyiced.FontId¶
A unique per database face ID.
See also
- family¶
Corresponds to a Font Family in a TrueType font.
- load()¶
Loads the referenced font into memory.
- monospaced¶
Indicates that the font face is monospaced.
- name¶
Corresponds to a PostScript name in a TrueType font.
- stretch¶
A font face stretch.
- style¶
A font face style.
- weight¶
A font face weight.
- class pyiced.FontStretch¶
A CSS font-stretch.
See also
- ULTRACONDENSED¶
50% width
- EXTRACONDENSED¶
62.5% width
- CONDENSED¶
75% width
- SEMICONDENSED¶
87.5% width
- NORMAL¶
100% width
- SEMIEXPANDED¶
112.5% width
- EXPANDED¶
125% width
- EXTRAEXPANDED¶
150% width
- ULTRAEXPANDED¶
200% width
- class pyiced.FontStyle¶
Allows italic or oblique faces to be selected.
See also
- NORMAL¶
A face that is neither italic not obliqued.
- ITALIC¶
A form that is generally cursive in nature.
- OBLIQUE¶
A typically-sloped version of the regular face.
- class pyiced.FontWeight¶
Specifies the weight of glyphs in the font, their degree of blackness or stroke thickness.
See also
- BLACK = FontWeight.BLACK¶
- BOLD = FontWeight.BOLD¶
- EXTRABOLD = FontWeight.EXTRABOLD¶
- EXTRALIGHT = FontWeight.EXTRALIGHT¶
- LIGHT = FontWeight.LIGHT¶
- MEDIUM = FontWeight.MEDIUM¶
- NORMAL = FontWeight.NORMAL¶
- SEMIBOLD = FontWeight.SEMIBOLD¶
- THIN = FontWeight.THIN¶
- value¶
- pyiced.findfont(family=None, weight=None, stretch=None, style=None)¶
Performs a CSS-like query and returns the best matched font face.
Arguments can be given using their constants or using their CSS value, e.g.
>>> from pyiced import * >>> findfont("serif", "extra-light", "normal", "italic") FontId(name="TimesNewRomanPS-ItalicMT", family="Times New Roman", style=Italic, weight=Weight(400), stretch=Normal)
- Parameters
families (Union[FontFamily, str, Iterable[Union[FontFamily, str]], None]) – A prioritized (list of) font family names or generic family name(s). Defaults to
SANSSERIF
.weight (Union[FontWeight, int, str, None]) – Specifies the weight of glyphs in the font, their degree of blackness or stroke thickness. Defaults to
NORMAL
.stretch (Union[FontStretch, str, None]) – Selects a normal, condensed, or expanded face from a font family. Defaults to
NORMAL
.style (Union[FontStyle, str, None]) – Allows italic or oblique faces to be selected. Defaults to
NORMAL
.
- Returns
The best match found, if one was found.
- Return type
Optional[FontId]
See also