mcfonts.export_formats
¶
Formats that can be passed into mcfonts.MinecraftFont.export()
.
All functions defined here must have a signature of:
(glyphs: dict[str, mcfonts.glyphs.Glyph], settings: ExportSettings) -> bytes
Module Contents¶
Classes¶
A TypedDict of the options that can be passed to any export format function. |
Functions¶
|
Export to an OpenType font with Type 2 Charstring outlines. |
|
Export to a GNU Unifont .hex format. |
|
Export to a YAFF font file. |
- class mcfonts.export_formats.ExportSettings¶
Bases:
TypedDict
A TypedDict of the options that can be passed to any export format function.
Initialize self. See help(type(self)) for accurate signature.
- author : str | None¶
The author(s) of the font. Optional.
- include_credits : bool | None¶
Whether to include basic copyright information and credits in the font file. Optional.
- license : str | None¶
An instance of
mcfonts.filters.Filter
. If supplied, filter rules will be obeyed. Optional.
- name : str | None¶
The name of the resulting font, not what its filename is. Optional.
- mcfonts.export_formats.opentype(glyphs, settings)¶
Export to an OpenType font with Type 2 Charstring outlines.
The font is crafted through a TTX file (font XML), and characters are added in tables and given self-descriptive name mappings:
("u0954", "u1fae4", "u2605")
.For some fields, the font's name will be "Minecraft <font name>".
The font mustn't contain over 65,535 characters, or else any additional characters won't be added, and the font will be saved prematurely.
- Parameters:¶
- glyphs : dict[str, mcfonts.glyphs.Glyph]¶
A dictionary of
{character: glyph}
.- settings : ExportSettings¶
A dictionary conforming to
ExportSettings
.
- Returns:¶
An OpenType file binary.
- Return type:¶
bytes
- mcfonts.export_formats.unihex(glyphs, settings)¶
Export to a GNU Unifont .hex format.
For details on the Unifont .hex format, see https://en.wikipedia.org/wiki/GNU_Unifont#.hex_format. There is no limit to the number of characters.
- Parameters:¶
- glyphs : dict[str, mcfonts.glyphs.Glyph]¶
A dictionary of
{character: glyph}
.- settings : ExportSettings¶
A dictionary conforming to
ExportSettings
. This is not used.
- Returns:¶
A .hex file encoded in UTF-8 bytes.
- Return type:¶
bytes
- mcfonts.export_formats.yaff(glyphs, settings)¶
Export to a YAFF font file.
For details on the YAFF format, see https://github.com/robhagemans/monobit/blob/master/YAFF.md. There is no limit to the number of characters.
- Parameters:¶
- glyphs : dict[str, mcfonts.glyphs.Glyph]¶
A dictionary of
{character: glyph}
.- settings : ExportSettings¶
A dictionary conforming to
ExportSettings
.
- Returns:¶
A YAFF file encoded in UTF-8 bytes.
- Return type:¶
bytes