mcfonts


Namemcfonts JSON
Version 0.7 PyPI version JSON
download
home_page
SummaryA module for exporting, manipulating, and working with Minecraft fonts
upload_time2023-11-30 02:00:39
maintainer
docs_urlNone
authorWhoAteMyButter
requires_python>=3.11
licenseMIT
keywords minecraft fonts minecraft fonts font exporting minecraft opentype minecraft font minecraft export font mc font mc fonts mcfonts
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![mcfonts](logo.png)](https://gitlab.com/whoatemybutter/mcfonts)

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Pylint](https://img.shields.io/badge/pylint-10.00/10-ffbf48)](https://pylint.pycqa.org/en/latest/)
[![License](https://img.shields.io/badge/license-MIT-a51931)](https://spdx.org/licenses/MIT.html)
[![PyPI](https://img.shields.io/pypi/v/mcfonts)](https://pypi.org/project/mcfonts/)
[![GitLab Release (latest by SemVer)](https://img.shields.io/gitlab/v/release/38935127?sort=semver)](https://gitlab.com/whoatemybutter/mcfonts/-/releases)

**mcfonts** is a versatile, fast, and extensible package for working with Minecraft fonts.
<br/>
mcfonts works with any font JSON and can export every kind of texture and size, no matter the amount or complexity.
<br/>
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](#-installation)
- [🧮 Features](#-features)
- [🛠 Usage](#-usage)
- [❓ Why?](#-why)
- [📒 Documentation](#-documentation)
    - [Building locally](#building-locally)
- [📰 Changelog](#-changelog)
- [📜 License](#-license)
    - [🚫 Disclaimer](#-disclaimer)
- [📎 Links](#-links)

---

## 📦 Installation

`mcfonts` is available on PyPI.
It requires a Python version of **at least 3.11.0.**

To install `mcfonts` with pip, run:
```shell
python -m pip install mcfonts
```

If you would like the ability to generate documentation alongside it, run:
```shell
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)](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment)
2. Using [pipx](https://github.com/pypa/pipx)

### Dependencies

* [fontTools](https://pypi.org/project/fontTools/): for exporting to OpenType
* [lxml](https://pypi.org/project/lxml/): for fast XML parsing
* [Pillow](https://pypi.org/project/Pillow/): for processing font textures
* [tinyunicodeblock](https://pypi.org/project/tinyunicodeblock/): for font coverage summaries
* [jsonschema](https://pypi.org/project/jsonschema): for the font JSON validation
* [unirange](https://pypi.org/project/unirange/): for special unirange shortcuts

#### Optional dependencies

`docs`: Generating documentation
* [sphinx](https://pypi.org/project/sphinx/): for generating documentation
* [sphinx-autoapi](https://pypi.org/project/sphinx-autoapi/): for generating code documentation
* [sphinxext-opengraph](https://pypi.org/project/sphinxext-opengraph/): for meta tags
* [sphinx-immaterial](https://pypi.org/project/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.

```python
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

```python
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.
<br/>
If you have a font with ~2,000 characters, it exports in ~3.2 seconds.
<br/>
If you have a font with ~13,000 characters, it exports in ~9.9 seconds.
<br/>
If you have a font with ~60,000 characters, you've made a mistake.
<small>(your font exports in about 1 minute, 15 seconds.)</small>

---

## ❓ 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:

```shell
git clone https://gitlab.com/whoatemybutter/mcfonts.git
cd mcfonts/docs
```

The documentation has a few requirements; install them all with:
```shell
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](CHANGELOG.md).

---

## 📜 License

`mcfonts` is licensed under the [MIT license](https://spdx.org/licenses/MIT.html).
<br/>
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.<br/>
*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`.
<br/>

**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](https://minecraft.wiki/w/Font)
* [OpenType specification](https://docs.microsoft.com/en-us/typography/opentype/spec/)
* [FontForge](https://fontforge.org/)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "mcfonts",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "minecraft,fonts,minecraft fonts,font exporting,minecraft opentype,minecraft font,minecraft export font,mc font,mc fonts,mcfonts",
    "author": "WhoAteMyButter",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/e5/fb/14545d19703f1ba907387334cc81130d0a1c5453172b85c13927e035237f/mcfonts-0.7.tar.gz",
    "platform": null,
    "description": "[![mcfonts](logo.png)](https://gitlab.com/whoatemybutter/mcfonts)\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Pylint](https://img.shields.io/badge/pylint-10.00/10-ffbf48)](https://pylint.pycqa.org/en/latest/)\n[![License](https://img.shields.io/badge/license-MIT-a51931)](https://spdx.org/licenses/MIT.html)\n[![PyPI](https://img.shields.io/pypi/v/mcfonts)](https://pypi.org/project/mcfonts/)\n[![GitLab Release (latest by SemVer)](https://img.shields.io/gitlab/v/release/38935127?sort=semver)](https://gitlab.com/whoatemybutter/mcfonts/-/releases)\n\n**mcfonts** is a versatile, fast, and extensible package for working with Minecraft fonts.\n<br/>\nmcfonts works with any font JSON and can export every kind of texture and size, no matter the amount or complexity.\n<br/>\nIt can be used anywhere in places that deal with Minecraft fonts.\n\n> \u26a0\ufe0f mcfonts is in beta. API may change at any time; read the changelog carefully.\n\n---\n\n## Table of contents\n- [\ud83d\udce6 Installation](#-installation)\n- [\ud83e\uddee Features](#-features)\n- [\ud83d\udee0 Usage](#-usage)\n- [\u2753 Why?](#-why)\n- [\ud83d\udcd2 Documentation](#-documentation)\n    - [Building locally](#building-locally)\n- [\ud83d\udcf0 Changelog](#-changelog)\n- [\ud83d\udcdc License](#-license)\n    - [\ud83d\udeab Disclaimer](#-disclaimer)\n- [\ud83d\udcce Links](#-links)\n\n---\n\n## \ud83d\udce6 Installation\n\n`mcfonts` is available on PyPI.\nIt requires a Python version of **at least 3.11.0.**\n\nTo install `mcfonts` with pip, run:\n```shell\npython -m pip install mcfonts\n```\n\nIf you would like the ability to generate documentation alongside it, run:\n```shell\npython -m pip install mcfonts[docs]\n```\n\n### \"externally-managed-environment\"\n\nThis error occurs on some Linux distributions, such as Fedora 38 and Ubuntu 23.04.\nIt can be solved by either:\n\n1. Using a [virtual environment (venv)](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment)\n2. Using [pipx](https://github.com/pypa/pipx)\n\n### Dependencies\n\n* [fontTools](https://pypi.org/project/fontTools/): for exporting to OpenType\n* [lxml](https://pypi.org/project/lxml/): for fast XML parsing\n* [Pillow](https://pypi.org/project/Pillow/): for processing font textures\n* [tinyunicodeblock](https://pypi.org/project/tinyunicodeblock/): for font coverage summaries\n* [jsonschema](https://pypi.org/project/jsonschema): for the font JSON validation\n* [unirange](https://pypi.org/project/unirange/): for special unirange shortcuts\n\n#### Optional dependencies\n\n`docs`: Generating documentation\n* [sphinx](https://pypi.org/project/sphinx/): for generating documentation\n* [sphinx-autoapi](https://pypi.org/project/sphinx-autoapi/): for generating code documentation\n* [sphinxext-opengraph](https://pypi.org/project/sphinxext-opengraph/): for meta tags\n* [sphinx-immaterial](https://pypi.org/project/sphinx-immaterial/): for documentation theme\n\n---\n\n## \ud83e\uddee Features\n\n* handles these providers:\n    * `space`\n    * `bitmap`\n    * `legacy_unicode`\n    * `ttf`\n    * `unihex`\n    * `reference`\n* warns of invalid data\n* finds oversights that the Vanilla client does not notice\n* generates optimized and space-saving glyph paths\n* works with any font, not just Vanilla\n* works on fonts with double, triple, or higher scales\n* generates summaries of fonts\n* allows easy inspection of a font's details\n* contains glyph utilities and compacting functions\n* works on new 1.20+ `unihex` and `reference` providers\n* exports in 3 different formats\n\n---\n\n## \ud83d\udee0 Usage\n\nUsing `mcfonts` is simple.\n\n```python\nimport mcfonts\n\nfont = mcfonts.from_java_font_file(\"path/to/font.json\")\n# Do stuff with `font`...\n```\n\n### Exporting\n\nYou can easily export to other formats.\nCurrently, there are 3 supported:\n\n* OpenType\n* YAFF\n* Unihex\n\n```python\nimport mcfonts\n\nfont = mcfonts.from_java_font_file(\"path/to/font.json\")\nexported = font.export(\n  mcfonts.export_formats.<format name>,\n  {\n    \"name\": \"My cool font\"\n  }\n)\n```\nThat's it. You can write the result of `font.export -> bytes` to any file to save it.\n\nIf you have a font with ~200 characters, it exports in ~0.3 seconds.\n<br/>\nIf you have a font with ~2,000 characters, it exports in ~3.2 seconds.\n<br/>\nIf you have a font with ~13,000 characters, it exports in ~9.9 seconds.\n<br/>\nIf you have a font with ~60,000 characters, you've made a mistake.\n<small>(your font exports in about 1 minute, 15 seconds.)</small>\n\n---\n\n## \u2753 Why?\n### \u23f3 It's fast\n\nIn the time it has taken you to read this sentence,\na font with 1,000 glyphs has already been generated.\n\nA 13,000-glyph font takes 10 seconds.\n\nA simple 100 glyph font? A fraction of a second; it takes 0.1s.\n\n### \u27bf It's versatile\n\n`mcfonts` works on fonts of any height, ascent, and size.\n\nIt correctly compensates and warns about oversized characters,\ntranslucent textures, and invalid data.\n\n### \ud83e\udde0 It makes sense\n\nFonts are organized by a class.\n\nProviders, too, have their own classes.\n\nExporting and compacting are separated into their own functions, which makes debugging and modification easy.\n\n> **`mcfonts` does not fix mistakes in fonts.**\n\nIt will extrapolate missing data, but empty or corrupt textures, invalid numbers,\nor extreme cases will result in an error when trying to create a `MinecraftFont` instance with them.\n\nThis gives you the ability to correct these problems instead of silently making them work\n(sometimes with limited effectiveness) and keeping you in the dark about future issues.\n\n### \ud83d\udcdc It's documented\n\n`mcfonts` has extensive documentation, both externally and in the source code.\nFunctions are carefully written with rST-style docstrings,\nand module variables are given precise descriptions.\n\n---\n\n## \ud83d\udcd2 Documentation\n\nDocumentation for `mcfonts` is available at https://mcfonts.readthedocs.io.\n\n### Building locally\nYou can build the documentation yourself by grabbing a copy of the source code:\n\n```shell\ngit clone https://gitlab.com/whoatemybutter/mcfonts.git\ncd mcfonts/docs\n```\n\nThe documentation has a few requirements; install them all with:\n```shell\npython -m pip install -r requirements.txt\n```\n\nRun `make html` to begin building the documentation.\nIt will be at `_build/html/index.html`.\n\n---\n\n## \ud83d\udcf0 Changelog\n\nThe changelog is at [CHANGELOG.md](CHANGELOG.md).\n\n---\n\n## \ud83d\udcdc License\n\n`mcfonts` is licensed under the [MIT license](https://spdx.org/licenses/MIT.html).\n<br/>\nFonts created with this tool are under **no explicit license**; you can license them in any way you want.\nThis includes under a paid license.<br/>\n*By default, fonts created by this tool are in the public domain.*\n\nAlthough credit is embedded in exported fonts, *removing this credit **is** allowed*,\nand the function parameter `mcfonts.MinecraftFont.export(include_credit)` may be set to `False`.\n<br/>\n\n**Keeping it in is greatly appreciated and helps make `mcfonts` better.\nThere is no disadvantage to leaving the credit in.**\n\n### \ud83d\udeab Disclaimer\n\n> **mcfonts is not affiliated, endorsed, created, supported, or an official product\n> by Mojang Studios, or by Microsoft Corporation, or any of their associates in any way.**\n\n---\n\n## \ud83d\udcce Links\n\n* [Font - Minecraft Wiki](https://minecraft.wiki/w/Font)\n* [OpenType specification](https://docs.microsoft.com/en-us/typography/opentype/spec/)\n* [FontForge](https://fontforge.org/)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A module for exporting, manipulating, and working with Minecraft fonts",
    "version": "0.7",
    "project_urls": {
        "Changelog": "https://gitlab.com/whoatemybutter/mcfonts/-/blob/master/CHANGELOG.md",
        "Documentation": "https://mcfonts.readthedocs.io",
        "Issues": "https://gitlab.com/whoatemybutter/mcfonts/-/issues",
        "Source": "https://gitlab.com/whoatemybutter/mcfonts"
    },
    "split_keywords": [
        "minecraft",
        "fonts",
        "minecraft fonts",
        "font exporting",
        "minecraft opentype",
        "minecraft font",
        "minecraft export font",
        "mc font",
        "mc fonts",
        "mcfonts"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b46d40afc2ebe2b71c1dbc4831e9d2f3bc6f4101efcc398fb6b4dcca317a877",
                "md5": "b912fc08e57dac589f91221034cfef0f",
                "sha256": "1090a37f01e98149c91d697b4bcb0536b33fe944eba4b827ec11e1e86b47d703"
            },
            "downloads": -1,
            "filename": "mcfonts-0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b912fc08e57dac589f91221034cfef0f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 74588,
            "upload_time": "2023-11-30T02:00:37",
            "upload_time_iso_8601": "2023-11-30T02:00:37.855865Z",
            "url": "https://files.pythonhosted.org/packages/0b/46/d40afc2ebe2b71c1dbc4831e9d2f3bc6f4101efcc398fb6b4dcca317a877/mcfonts-0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e5fb14545d19703f1ba907387334cc81130d0a1c5453172b85c13927e035237f",
                "md5": "eb93a6a77abd889d701b15959e4fec4c",
                "sha256": "6c3d7294b47e49d68e492b324ceab968621e4f01b33b56e10f98cc80ead87a6b"
            },
            "downloads": -1,
            "filename": "mcfonts-0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "eb93a6a77abd889d701b15959e4fec4c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 67076,
            "upload_time": "2023-11-30T02:00:39",
            "upload_time_iso_8601": "2023-11-30T02:00:39.659707Z",
            "url": "https://files.pythonhosted.org/packages/e5/fb/14545d19703f1ba907387334cc81130d0a1c5453172b85c13927e035237f/mcfonts-0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-30 02:00:39",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "whoatemybutter",
    "gitlab_project": "mcfonts",
    "lcname": "mcfonts"
}
        
Elapsed time: 0.35266s