mcfonts 0.7

Creator: bradpython12

Last updated:

Add to Cart

Description:

mcfonts 0.7

mcfonts is a versatile, fast, and extensible package for working with Minecraft fonts.

mcfonts works with any font JSON and can export every kind of texture and size, no matter the amount or complexity.

It can be used anywhere in places that deal with Minecraft fonts.

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


Table of contents

📦 Installation
🧮 Features
🛠 Usage
❓ Why?
📒 Documentation

Building locally


📰 Changelog
📜 License

🚫 Disclaimer


📎 Links


📦 Installation
mcfonts is available on PyPI.
It requires a Python version of at least 3.11.0.
To install mcfonts with pip, run:
python -m pip install mcfonts

If you would like the ability to generate documentation alongside it, run:
python -m pip install mcfonts[docs]

"externally-managed-environment"
This error occurs on some Linux distributions, such as Fedora 38 and Ubuntu 23.04.
It can be solved by either:

Using a virtual environment (venv)
Using pipx

Dependencies

fontTools: for exporting to OpenType
lxml: for fast XML parsing
Pillow: for processing font textures
tinyunicodeblock: for font coverage summaries
jsonschema: for the font JSON validation
unirange: for special unirange shortcuts

Optional dependencies
docs: Generating documentation

sphinx: for generating documentation
sphinx-autoapi: for generating code documentation
sphinxext-opengraph: for meta tags
sphinx-immaterial: for documentation theme


🧮 Features

handles these providers:

space
bitmap
legacy_unicode
ttf
unihex
reference


warns of invalid data
finds oversights that the Vanilla client does not notice
generates optimized and space-saving glyph paths
works with any font, not just Vanilla
works on fonts with double, triple, or higher scales
generates summaries of fonts
allows easy inspection of a font's details
contains glyph utilities and compacting functions
works on new 1.20+ unihex and reference providers
exports in 3 different formats


🛠 Usage
Using mcfonts is simple.
import mcfonts

font = mcfonts.from_java_font_file("path/to/font.json")
# Do stuff with `font`...

Exporting
You can easily export to other formats.
Currently, there are 3 supported:

OpenType
YAFF
Unihex

import mcfonts

font = mcfonts.from_java_font_file("path/to/font.json")
exported = font.export(
mcfonts.export_formats.<format name>,
{
"name": "My cool font"
}
)

That's it. You can write the result of font.export -> bytes to any file to save it.
If you have a font with ~200 characters, it exports in ~0.3 seconds.

If you have a font with ~2,000 characters, it exports in ~3.2 seconds.

If you have a font with ~13,000 characters, it exports in ~9.9 seconds.

If you have a font with ~60,000 characters, you've made a mistake.
(your font exports in about 1 minute, 15 seconds.)

❓ Why?
⏳ It's fast
In the time it has taken you to read this sentence,
a font with 1,000 glyphs has already been generated.
A 13,000-glyph font takes 10 seconds.
A simple 100 glyph font? A fraction of a second; it takes 0.1s.
➿ It's versatile
mcfonts works on fonts of any height, ascent, and size.
It correctly compensates and warns about oversized characters,
translucent textures, and invalid data.
🧠 It makes sense
Fonts are organized by a class.
Providers, too, have their own classes.
Exporting and compacting are separated into their own functions, which makes debugging and modification easy.

mcfonts does not fix mistakes in fonts.

It will extrapolate missing data, but empty or corrupt textures, invalid numbers,
or extreme cases will result in an error when trying to create a MinecraftFont instance with them.
This gives you the ability to correct these problems instead of silently making them work
(sometimes with limited effectiveness) and keeping you in the dark about future issues.
📜 It's documented
mcfonts has extensive documentation, both externally and in the source code.
Functions are carefully written with rST-style docstrings,
and module variables are given precise descriptions.

📒 Documentation
Documentation for mcfonts is available at https://mcfonts.readthedocs.io.
Building locally
You can build the documentation yourself by grabbing a copy of the source code:
git clone https://gitlab.com/whoatemybutter/mcfonts.git
cd mcfonts/docs

The documentation has a few requirements; install them all with:
python -m pip install -r requirements.txt

Run make html to begin building the documentation.
It will be at _build/html/index.html.

📰 Changelog
The changelog is at CHANGELOG.md.

📜 License
mcfonts is licensed under the MIT license.

Fonts created with this tool are under no explicit license; you can license them in any way you want.
This includes under a paid license.
By default, fonts created by this tool are in the public domain.
Although credit is embedded in exported fonts, removing this credit is allowed,
and the function parameter mcfonts.MinecraftFont.export(include_credit) may be set to False.

Keeping it in is greatly appreciated and helps make mcfonts better.
There is no disadvantage to leaving the credit in.
🚫 Disclaimer

mcfonts is not affiliated, endorsed, created, supported, or an official product
by Mojang Studios, or by Microsoft Corporation, or any of their associates in any way.


📎 Links

Font - Minecraft Wiki
OpenType specification
FontForge

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.