Package: mcfonts
mcfontsis 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?📒 DocumentationBuilding locally📰 Changelog📜 License🚫 Disclaimer📎 Links📦 Installationmcfontsis available on PyPI.
It requires a Python version ofat least 3.11.0.To installmcfontswith pip, run:python-mpipinstallmcfontsIf you would like the ability to generate documentation alongside it, run:python-mpipinstallmcfonts[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 avirtual environment (venv)UsingpipxDependenciesfontTools: for exporting to OpenTypelxml: for fast XML parsingPillow: for processing font texturestinyunicodeblock: for font coverage summariesjsonschema: for the font JSON validationunirange: for special unirange shortcutsOptional dependenciesdocs: Generating documentationsphinx: for generating documentationsphinx-autoapi: for generating code documentationsphinxext-opengraph: for meta tagssphinx-immaterial: for documentation theme🧮 Featureshandles these providers:spacebitmaplegacy_unicodettfunihexreferencewarns of invalid datafinds oversights that the Vanilla client does not noticegenerates optimized and space-saving glyph pathsworks with any font, not just Vanillaworks on fonts with double, triple, or higher scalesgenerates summaries of fontsallows easy inspection of a font's detailscontains glyph utilities and compacting functionsworks on new 1.20+unihexandreferenceprovidersexports in 3 different formats🛠 UsageUsingmcfontsis simple.importmcfontsfont=mcfonts.from_java_font_file("path/to/font.json")# Do stuff with `font`...ExportingYou can easily export to other formats.
Currently, there are 3 supported:OpenTypeYAFFUniheximportmcfontsfont=mcfonts.from_java_font_file("path/to/font.json")exported=font.export(mcfonts.export_formats.<formatname>,{"name":"My cool font"})That's it. You can write the result offont.export -> bytesto 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 fastIn 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 versatilemcfontsworks on fonts of any height, ascent, and size.It correctly compensates and warns about oversized characters,
translucent textures, and invalid data.🧠 It makes senseFonts 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.mcfontsdoes 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 aMinecraftFontinstance 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 documentedmcfontshas extensive documentation, both externally and in the source code.
Functions are carefully written with rST-style docstrings,
and module variables are given precise descriptions.📒 DocumentationDocumentation formcfontsis available athttps://mcfonts.readthedocs.io.Building locallyYou can build the documentation yourself by grabbing a copy of the source code:gitclonehttps://gitlab.com/whoatemybutter/mcfonts.gitcdmcfonts/docsThe documentation has a few requirements; install them all with:python-mpipinstall-rrequirements.txtRunmake htmlto begin building the documentation.
It will be at_build/html/index.html.📰 ChangelogThe changelog is atCHANGELOG.md.📜 Licensemcfontsis licensed under theMIT license.Fonts created with this tool are underno 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 creditisallowed,
and the function parametermcfonts.MinecraftFont.export(include_credit)may be set toFalse.Keeping it in is greatly appreciated and helps makemcfontsbetter.
There is no disadvantage to leaving the credit in.🚫 Disclaimermcfonts 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.📎 LinksFont - Minecraft WikiOpenType specificationFontForge