Fonts

Overview

Font(name, data)

A font.

FontFamily

A font family.

FontId

A unique per database face ID.

FontStretch

A CSS font-stretch.

FontStyle

Allows italic or oblique faces to be selected.

FontWeight

Specifies the weight of glyphs in the font, their degree of blackness or stroke thickness.

findfont([family, weight, stretch, style])

Performs a CSS-like query and returns the best matched font face.

systemfonts()

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

iced::Font

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
data

Bytes data of the font

Returns

  • memoryview – The bytes data of the font.

  • None – For DEFAULT.

name

Name of the font

Returns

  • str – The name of the font.

  • None – For DEFAULT.

class pyiced.FontFamily

A font family.

See also

fontdb::Family

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

fontdb::ID

family

Corresponds to a Font Family in a TrueType font.

load()

Loads the referenced font into memory.

Returns

The Font object to be used in e.g. view().

Return type

Font

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

fontdb::Stretch

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

fontdb::Style

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

fontdb::Weight

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

fontdb::Query

pyiced.systemfonts()

List loaded system fonts.

Returns

An iterator over all system fonts.

Return type

Iterator[FontId]