Skip to content

About

Unifont Utilities, but rewritten in Python.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

Unifont Utils

License: GPL v3

CI PyPI - Version GitHub Release

This project provides a set of tools for working with the GNU Unifont.

See the documentation at Read the Docs for more information.

Installation

Install the package from PyPI using the following command:

pip install unifont-utils

Quick start

Load a GNU Unifont .hex file, edit a glyph and save the file:

from unifont_utils import Glyph, GlyphSet, print_glyph

glyphs = GlyphSet.load_hex_file("unifont.hex")
glyph = glyphs["0041"]
print(glyph.hex_str, glyph.width, glyph.unicode_name)
print_glyph(glyph)

glyphs.set_glyph(Glyph("E000", "00" * 16))
glyphs.save_hex_file("edited.hex")

The package is organized in layers:

Module Contents
unifont_utils Core model: Glyph, GlyphSet, ColorScheme, patterns, print_glyph, print_diff
unifont_utils.operations Merging, range and Hangul selection, statistics, diffs, rotation, combining circles
unifont_utils.generators Code point boxes, Braille and Kinya glyphs, matching the GNU Unifont programs
unifont_utils.formats Glyph and page images, BDF, GNU hexdraw text, TrueType/CFF OpenType, .hex checks
unifont_utils.downloader Downloading official Unifont releases
unifont_utils.cli The unifont-utils command
from unifont_utils.formats import save_opentype, save_page_image
from unifont_utils.operations import select_range

latin = select_range(glyphs, "0020", "007E")
save_page_image(glyphs, "4E", "page.png")
save_opentype(latin, "latin.otf", font_format="otf")

Interactive terminal editing lives in the independent UniPie (unipie) project.

Command line

unifont-utils --help
unifont-utils download  # The latest official release
unifont-utils hex query --path unifont.hex --code_point 0041 --pure
unifont-utils hex merge base.hex overrides.hex --output merged.hex
unifont-utils hex subset --path merged.hex --start 0020 --end 007E --output latin.hex
unifont-utils convert page hex2img --path unifont.hex --page 4E --output page.png
unifont-utils convert font export --path latin.hex --format otf --output latin.otf
unifont-utils generate filler --range E000 E0FF --output filler.hex

The hex group queries, edits, checks and processes .hex files. The convert group handles images, unihex2bmp pages, BDF, hexdraw text and OpenType fonts. The generate group creates glyphs by algorithm.

Development

The repository uses uv for locked environments and Ruff for linting and formatting:

uv sync --locked
uv run --locked pytest
uv run --locked ruff check .
uv run --locked ruff format --check .

The documentation lives in docs/, with Chinese pages in docs/zh and English pages in docs/en. Preview both languages with:

uv sync --locked --group docs
uv run --locked mkdocs serve

License

The project is released under the GPL v3 License.

    Unifont Utils
    Copyright (C) 2024-2026 SkyEye_FAST

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Feedback

Please feel free to raise issues for any problems encountered or feature suggestions.

Pull requests are welcome.

About

Unifont Utilities, but rewritten in Python.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages