Skip to main content

A module for exporting, manipulating, and working with Minecraft fonts

Project description

mcfonts

Code style: black Pylint License PyPi GitLab Release (latest by SemVer)

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 & 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

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:

  1. Using a virtual environment (venv)
  2. Using pipx

Dependencies

Optional dependencies

docs: Generating documentation


🧮 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 quadruple 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

🛠 Usage

Using mcfonts is simple.

import mcfonts

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

Exporting

To export to OpenType:

import mcfonts

font = mcfonts.from_java_font_file("path/to/font.json")
font.export("My cool font").save("My cool font.otf")

That's it. Your font is at ./My cool font.otf.

If you have a font with ~200 characters, it generated in ~0.3 seconds.
If you have a font with ~2,000 characters, it generated in ~3.2 seconds.
If you have a font with ~13,000 characters, it generated in ~9.9 seconds.
If you have a font with ~60,000 characters, you've made a mistake. (your font generated in ~1 minute, 14 seconds.)

❗ Note: Only OpenType fonts are supported for exporting.
Use other utilities such as FontForge to convert between formats.


❓ 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 & warns about oversized characters, translucent textures, and invalid data.

🧠 It makes sense

Fonts are organized by a class, instead of using individual functions.

Providers, too, have their own classes.

Exporting and compacting are separated into their own functions, which makes debugging & modification easy.

mcfonts does not fix mistakes in fonts.

It will extrapolate missing data, but empty/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 documenation 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 under 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 by any of their associates in any way.


📎 Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcfonts-0.6.tar.gz (67.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcfonts-0.6-py3-none-any.whl (76.7 kB view details)

Uploaded Python 3

File details

Details for the file mcfonts-0.6.tar.gz.

File metadata

  • Download URL: mcfonts-0.6.tar.gz
  • Upload date:
  • Size: 67.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mcfonts-0.6.tar.gz
Algorithm Hash digest
SHA256 bf6459623e7e5327f0736df87b6359406bd71de97dd2e80232c1773a014a69e6
MD5 5980c8cec453433adaf0c00ecf08e836
BLAKE2b-256 796c8eff7a841beefcc2b93fc27a4b7f336a94299994cb701e5b6d7e8bd9c0c5

See more details on using hashes here.

File details

Details for the file mcfonts-0.6-py3-none-any.whl.

File metadata

  • Download URL: mcfonts-0.6-py3-none-any.whl
  • Upload date:
  • Size: 76.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mcfonts-0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 49d161383a3816895d5171b94569a6c4b9ae3cf2c603ffd6dd8de8b90475ebf2
MD5 4728e84edf0abeabd0cfd14ea6fae33b
BLAKE2b-256 32715eade73c54773053d5ecaa61f2976e36cfc86905c65a490d5b1fac3d3316

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page