mcfonts documentation

mcfonts is a Python library for the manipulation of Minecraft: Java Edition fonts. It supports loading and saving fonts into different formats, and uses a plain object-oriented and interface-centric approach.

mcfonts is designed to support future Minecraft updates with minimal changes. Third-parties may implement their own providers.

Warning

mcfonts is in beta. The API may change at any time; read the changelog carefully.

from mcfonts.provider.import_all import import_all
from mcfonts.glyph import BitmapGlyph
from mcfonts.serde.minecraft import load_font_from_path
from PIL.Image import Image, merge
from pathlib import Path

# Required to load the vanilla providers like bitmap
import_all()

font: MinecraftFont = load_font_from_path(Path("assets/minecraft/font/default.json"))
# Number of providers
print(len(font))
for provider in font.get_providers_by_priority(PrioritySortOrder.DESCENDING):
    for character, glyph in provider.items():
        print(glyph.show())
        if character > 0xFF:
            del provider[character]
        elif isinstance(glyph, BitmapGlyph):
                image: Image = glyph.get_image()
                r, g, b, a = image.split()
                r = r.point(lambda i: i * 1.5)
                g = g.point(lambda i: i * 0.4)
                b = b.point(lambda i: i * 0.3)
                provider[character] = BitmapGlyph(merge("RGBA", (r, g, b, a))))

License

mcfonts is licensed under MIT, with additional conditions regarding LLMs and similar technologies.

In addition to the MIT license, it also stipulates:

1. The Software and any modifications made to it may not be used for the purpose of training or improving machine learning algorithms, including but not limited to artificial intelligence, natural language processing, or data mining. This condition applies to any derivatives, modifications, or updates based on the Software code. Any usage of the Software in an AI-training dataset is considered a breach of this License.

2. The Software may not be included in any dataset used for training or improving machine learning algorithms, including but not limited to artificial intelligence, natural language processing, or data mining.