mcfonts.glyph

Glyph module, containing the basic and universal glyph class.

Submodules

Package Contents

class Glyph

Bases: abc.ABC

The Glyph class represents any visible character glyph.

Glyphs are immutable. To change them, create another with different fields and overwrite the previous glyph.

__bool__() bool

Return True if glyph is not empty.

Return type:

bool

abstractmethod bake() PIL.Image.Image

Return a image rendering of this glyph.

This does not include any right padding.

Return type:

PIL.Image.Image

abstractmethod get_metrics() GlyphMetrics

Return the metrics of this glyph.

Returns:

The metrics.

Return type:

GlyphMetrics

is_empty() bool

Return if glyph is entirely empty.

Returns:

True if height and width bearings are height and width, respectively.

Return type:

bool

abstractmethod show() str

Return a pretty visual representation of this glyph.

It is best to pass this into print().

Returns:

String of glyph representation.

Return type:

str

class GlyphMetrics

Series of bearings; essential for bounding box calculations.

Bearings are measured from the bottom-left corner of a glyph. Metrics do not have data on the theoretical top-right canvas bounds.

content_height() int
Return type:

int

content_width() int
Return type:

int

classmethod from_tuple(tup: tuple[int, int, int, int], /) GlyphMetrics
Parameters:
tup : tuple[int, int, int, int]

Return type:

GlyphMetrics

to_tuple() tuple[int, int, int, int]
Return type:

tuple[int, int, int, int]

bottom : int

Spaces from canvas to bottom edge of content.

left : int

Spaces from canvas to left edge of content.

right : int

Spaces from canvas to right edge of content.

top : int

Spaces from canvas to top edge of content.