mcfonts.glyph.bitmap

A bitmap glyph contains an image.

Module Contents

class BitmapGlyph(image: PIL.Image.Image)

Bases: mcfonts.glyph.Glyph, mcfonts.serde.opentype.ToTrueTypeGlyph, mcfonts.serde.yaff.ToYaffData, mcfonts.serde.unihex.ToUnihexData

The bitmap glyph contains an image. Image stored is always in RGBA mode.

Parameters:
image : PIL.Image.Image

__deepcopy__(memodict: collections.abc.Mapping[Any, Any] | None = None) BitmapGlyph

Return a deep copy; image is implicitly copied.

Parameters:
memodict : collections.abc.Mapping[Any, Any] | None

Return type:

BitmapGlyph

__repr__() str

Return BitmapGlyph(width x, height x).

Return type:

str

bake() PIL.Image.Image

Return a image rendering of this glyph.

This does not include any right padding.

Return type:

PIL.Image.Image

get_image() PIL.Image.Image

Return image.

Return type:

PIL.Image.Image

get_metrics() mcfonts.glyph.GlyphMetrics

Return the metrics of this glyph.

Returns:

The metrics.

Return type:

mcfonts.glyph.GlyphMetrics

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

to_truetype_glyph() fontTools.ttLib.tables._g_l_y_f.Glyph

Process and convert this glyph into rectangle shapes.

Returns:

Generator yielding rectangles.

Return type:

fontTools.ttLib.tables._g_l_y_f.Glyph

to_unihex_data() str

Process and convert this glyph into GNU Unihex data.

Returns:

String of the data.

Return type:

str

to_yaff_data() list[str]
Return type:

list[str]

maximum_dimension : ClassVar[int] = 256
pixel_alpha_threshold : ClassVar[int] = 180
calculate_metrics(image: PIL.Image.Image) mcfonts.glyph.GlyphMetrics

Calculate left, right, bottom, and top metrics.

Parameters:
image : PIL.Image.Image

Return type:

mcfonts.glyph.GlyphMetrics