mcfonts.serde.yaff

Export to a YAFF font file.

Module Contents

class ToYaffData

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
to_yaff_data() list[str]
Return type:

list[str]

class YaffData
__post_init__() None
Return type:

None

set_notdef() None
Return type:

None

global_properties : dict[str, str]
glyphs : dict[Label, YaffGlyphData]
class YaffGlyphData
glyph : list[str] = []
properties : dict[str, str]
class YaffSaver

Bases: Protocol

Protocol for saving a provider to the Monobit YAFF format.

yaff_save(data: YaffData) None

Save provider into data.

Parameters:
data : YaffData

Current whole YAFF font data.

Return type:

None

save_font(font: mcfonts.font.MinecraftFont) str
Parameters:
font : mcfonts.font.MinecraftFont

Return type:

str

DICT_GLYPH_MAGIC : str = '__glyph__'

The magic constant that is used as a key for glyph data to be stored under.

type Label = str | int
NOTDEF_ASCENT : int = 7
NOTDEF_GLYPH : list[str] = ['@@@@@', '@...@', '@...@', '@...@', '@...@', '@...@', '@@@@@', '.....']
NOTDEF_HEIGHT : int = 8
NOTDEF_NAME : str = '".notdef"'
YAFF_OFF : Final[str] = '.'
YAFF_ON : Final[str] = '@'