Skip to content

Font

A font.

Parameters:

Name Type Description Default

name

str

Name of the font.

required

glyphs

Dict[str, List[str]]

Glyphs for single chars.

required

ligatures

Glyphs

Glyphs for ligatures. Defaults to None.

None

letter_spacing

int

Spacing between glyphs in number of cells. Defaults to 0.

0

space_width

int

Width of space glyph in number of cells. Defaults to 1.

1

baseline

int

Line index of baseline. Defaults to second to last line.

None

underline

Union[int, LineStyle]

Line index or more complex style of underline. Defaults to line below baseline.

None

underline2

Union[int, LineStyle]

Line index or more complex style of underline2. Defaults to baseline.

None

overline

Union[int, LineStyle]

Line index or more complex style of overline. Defaults to first line.

None

strike

Union[int, LineStyle]

Line index or more complex style of strike. Defaults to middle line.

None

baseline property

baseline

Line index of baseline.

letter_spacing property

letter_spacing

Spacing between glyphs in number of cell

ligatures property

ligatures

All available ligatures.

line_height property

line_height

Number of lines per glyph.

name property

name

Name of the Font.

overline property

overline

Style of overline.

space_width property

space_width

Width of space glyph in number of cells.

strike property

strike

Style of strike.

underline property

underline

Style of underline.

underline2 property

underline2

Style of underline2.

from_file cached classmethod

from_file(path)

Load from glyphs file.

Parameters:

Name Type Description Default

path

Union[Path, str]

Path to .toff file.

required

Returns:

Name Type Description
Font Font

Loaded font.

get

get(char)

Get glyph for char or ligature.

Parameters:

Name Type Description Default

char

str

Char or group of chars (ligature).

required

Returns:

Name Type Description
Glyph Glyph

Glyph for char.

get_font_names classmethod

get_font_names()

Return list of builtin font names. Extended fonts are prefixed with 'extended.'.

placeholder classmethod

placeholder(line_height)

Create placeholder glyph.

Parameters:

Name Type Description Default

line_height

int

Height in number of lines.

required

Returns:

Name Type Description
Glyph Glyph

Placeholder glyph.

space classmethod

Create space glyph.

Parameters:

Name Type Description Default

width

int

Width in number of cells.

required

line_height

int

Height in number of lines.

required

Returns:

Name Type Description
Glyph Glyph

Space glyph.