Tools for working with monochrome bitmap fonts.
Project description
-@@------------------------------------------@@------@@--------------@@-
-@@------------------------------------------@@------@@--@@----------@@-
-@@------------------------------------------@@----------@@----------@@-
-@@------@@@@@@@@@----@@@@---@@@@@----@@@@---@@@@@---@@-@@@@---------@@-
-@@------@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@----------@@-
-@@------@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@----------@@-
-@@------@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@----------@@-
-@@------@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@----------@@-
-@@------@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@--@@------@@-
-@@------@@--@@--@@---@@@@---@@--@@---@@@@---@@@@@---@@---@@-@@------@@-
-@@------------------------------------------------------------------@@-
-@@------------------------------------------------------------------@@-
-@@------------------------------------------------------------------@@-
Tools for working with monochrome bitmap fonts
The monobit tools let you modify bitmap fonts and convert between several formats.
monobit's native format is yaff, a human-friendly, text-based visual format similar to the ones used by
Roman Czyborra's hexdraw, Simon Tatham's mkwinfont and John Elliott's psftools. Details are
given in the yaff font file format specification.
Monobit requires Python 3.8 or above. Install through pip install monobit. Some formats or features require additional packages; see Dependencies below for a list. These
will be installed automatically if you use pip.
monobit can be used as a Python package or as a command-line tool.
Usage examples
Convert utility
Here are some examples of how to use the conversion utility.
monobit-convert --help
Display usage summary and command-line options
monobit-convert --help load --format=raw
Display usage summary and additional format-specific command-line options for conversion from raw binary.
monobit-convert fixedsys.fon
Recognise the source file format from "magic bytes" or suffix (here, a Windows font) and write fonts
to standard output in yaff format.
monobit-convert roman.bdf to --format=hex
Read font from BDF file and write to standard output as Unifont HEX.
monobit-convert fixed.psf to fixed.png
Read font in PSF format and write to disk as image in PNG format.
monobit-convert --format=c to --format=bdf
Read font from standard input as C-source coded binary and write to standard output as BDF.
The converter transparently reads and writes gz, bz2, or xz-compressed font files and can read
and write zip and tar archives. Some font formats contain multiple fonts whereas others can
contain only one; the converter will write multiple files to a directory or archive if needed.
It is also possible to apply various transformations on the font before saving it. Check
monobit-convert --help for usage.
Banner utility
The banner utility renders text to standard output in a given font. This is similar to the ancient
banner commands included in System-V and BSD Unixes.
For example, the banner at the top of this README was made with
me@bandit:~$ monobit-banner '| monobit. |' --font=VGASYS.FON
monobit-banner has a number of rendering options - you can choose fonts, change the "ink" and "paper"
characters, set a margin, scale text, and rotate by quarter turns.
Check monobit-banner --help for usage.
Supported formats
| Format | Short Name | Version | Typical Extension | Native OS | Read | Write |
|---|---|---|---|---|---|---|
| monobit yaff | yaff |
.yaff |
✔ | ✔ | ||
| Amiga Font Contents | amiga-fc |
.font |
Amiga OS | ✔ | ||
| Amiga font | amiga |
Amiga OS | ✔ | |||
| BBC soft font | bbc |
BBC Micro | ✔ | ✔ | ||
| X11/Adobe BDF | bdf |
.bdf |
Unix | ✔ | ✔ | |
| AngelCode BMFont [P] | bmfont |
text binary XML JSON | .fnt .xml .json + images |
✔ | ✔ (text, JSON) | |
| Raw binary | raw |
.fnt .rom [*] |
✔ | ✔ | ||
| C or C++ coded binary | c |
.c .cpp .cc .h |
✔ | ✔ | ||
| Codepage Information | cpi |
FONT FONT.NT DRFONT | .cpi |
MS-DOS, Windows NT, DR-DOS | ✔ | ✔ |
| Daisy-Dot | daisy |
II III Magnified | .nlq .nl2 .nl3 .nl4 |
Atari | ✔ | |
| DEC DRCS soft font | dec-drcs |
DEC VT | ✔ | ✔ | ||
| DosStart! | dosstart |
.dsf |
DOS | ✔ | ||
| FZX font | fzx |
.fzx |
ZX Spectrum | ✔ | ✔ | |
| Figlet font | figlet |
.flf |
Unix | ✔ | ✔ | |
| FONTX2 | fontx |
.fnt |
DOS/V | ✔ | ✔ | |
| FONTEDIT | fontedit |
.com |
DOS | ✔ | ||
| Fontraption | frapt |
.com |
DOS | ✔ | ||
| Fontraption TSR | frapt-tsr |
.com |
DOS | ✔ | ||
| Hanzi Bitmap Font | hbf |
.hbf + raw binary |
Unix | ✔ | ✔ | |
| Atari GDOS / GEM | gdos |
.fnt .gft .vga |
Atari ST, GEM | ✔ | ✔ | |
| C64 GEOS ConVerT | geos |
.cvt |
Commodore 64 | ✔ | ||
| Bare GEOS resource | vlir |
Commodore 64 | ✔ | |||
| GNU Unifont | hex |
.hex |
✔ | ✔ | ||
| Extended Hex | hext |
.hex |
✔ | ✔ | ||
| hexdraw | hexdraw |
.draw |
✔ | ✔ | ||
| Bitmap image [P] | image |
.png .gif .bmp |
✔ | ✔ | ||
| JSON coded binary | json |
.json |
✔ | ✔ | ||
Bare codepage (kbd) |
kbd-cp |
.cp |
DOS, Linux | ✔ | ✔ | |
| REXXCOM Font Mania | mania |
.com |
DOS | ✔ | ||
| MacOS font | mac |
FONT NFNT SFNT | .dfont .suit |
Classic MacOS | ✔ | |
| Bare NFNT resource | nfnt |
Classic MacOS, PalmOS | ✔ | |||
| Palm OS font | palm |
1 (NFNT) | .pdb |
Palm OS | ✔ | |
| Optiks PCR Font | pcr |
.pcr |
DOS | ✔ | ||
| PCPaint, GRASP, ChiWriter | pcpaint |
old 3 4 | .set .fnt .sft .pft .eft ... |
DOS | ✔ | |
| PDF chart [R] | pdf |
.pdf |
✔ | |||
| TeX PKFONT | pkfont |
.pk |
✔ | |||
| The Print Shop | printshop |
.pnf |
DOS | ✔ | ||
| PC Screen Font | psf |
1 2 | .psf .psfu |
MS-DOS, Linux | ✔ | ✔ (version 2) |
| PSF2AMS PSFCOM | psfcom |
.com |
Z80 CP/M | ✔ | ||
| Python coded binary | python |
.py |
✔ | ✔ | ||
| SFNT embedded bitmap | sfnt |
.otb .ttf .otf [F] [**] |
✔ | |||
| Signum! 2 | signum-* |
editor 9-pin 24-pin laser | .e24 .p9 .p24 .l30 |
Atari ST | ✔ | |
| vfont | vfont |
BSD, SunOS | ✔ | ✔ | ||
| Windows resource | win-fnt |
1.0 2.0 3.0 | .fnt |
Windows 1.x 2.x 3.x | ✔ | ✔ (2.0, 3.0) |
| Windows font | win-fon |
1.0 2.0 3.0 NE PE | .fon |
Windows 1.x 2.x 3.x | ✔ | ✔ (2.0 NE, 3.0 NE) |
| XBIN font section | xbin |
.xb |
DOS | ✔ |
[P] - requires PIL
[R] - requires reportlab
[F] - requires fontTools
[*] Identifying raw binary files
This is the most common format used on old platforms, often with the unhelpful suffix .fnt. As there is no metadata, it's up to you to specify the character-cell size. The most common, and default, size is 8x8 (CGA and many 8-bit platforms), followed by 8x16 (VGA) and 8x14 (EGA).
- 8x8 raw files are also known as
.f08,.ch8,.64c,.chr,.udg, and many others. - 8x14 raw files are also known as
.f14or CHET.814. - 8x16 raw files are also known as
.f16, Warp 9.fntor Degas Elite.fnt - Genecar
.carfiles are 16x16 raw files. - Harlekin III
.fntfiles are raw binaries with a 4096x8 pixel bitmap strike hosting 512 8x8 glyphs side by side. Extract with-strike-width=512.
It is also useful to check the file size. Raw files commonly hold 96 (ASCII excluding controls), 128 (ASCII), 256, or multiples thereof. Common file sizes therefore are:
| 8x8 | 8x14 | 8x16 | |
|---|---|---|---|
| 96 | 768 | 1344 | 1536 |
| 128 | 1024 | 1792 | 2048 |
| 256 | 2048 | 3584 | 4096 |
| 512 | 4096 | 7168 | 8192 |
If your unidentified font file has one of these sizes, chances are it is a raw binary file.
[**] TrueType / OpenType embedded bitmaps
monobit can extract bitmaps embedded in TrueType and OpenType font files. It
should be kept in mind that these are primarily intended as scalable formats,
and only exceptionally embed bitmaps to improve rendering on low-resolution displays.
The vast majority of .ttf, .otf, .dfont etc. files do not contain bitmaps at all.
This is true even for fonts with a pixelised look.
To convert these you first need to rasterise them, which monobit does not do.
Some of the other font tools linked below do have rasterising features.
Font format features
Here is a comparison of what you can and cannot store in selected formats supported by monobit.
| Format | Unicode | Unicode sequences | Encoding | MBCS | Multiple fonts | Cell size | Proportional | Kerning | Colour/antialiasing | Glyph representation |
|---|---|---|---|---|---|---|---|---|---|---|
yaff |
✔ | ✔ | ✔ | ✔ | ✔ | any | ✔ | ✔ | visual text | |
bmfont |
✔ | ✔ | ✔ | any | ✔ | ✔ | ✔ | image | ||
bdf |
✔ | ✔ | ✔ | any | ✔ | hex | ||||
mac-* |
✔ | ✔ | ✔ | any | ✔ | ✔ | ✔ | binary | ||
win-fon |
✔ | ✔ | ✔ | any | ✔ | binary | ||||
hexdraw |
✔ | any | ✔ | visual text | ||||||
amiga-* |
✔ | any | ✔ | ✔ | binary | |||||
gdos |
any | ✔ | binary | |||||||
fzx |
any | ✔ | binary | |||||||
figlet |
✔ | any | ✔ | ✔ | visual text | |||||
vfont |
any | ✔ | binary | |||||||
hext |
✔ | ✔ | 8xN | multi-cell | hex | |||||
hex |
✔ | 8x16 | multi-cell | hex | ||||||
hbf |
✔ | ✔ | any | binary | ||||||
psf.2 |
✔ | ✔ | any | binary | ||||||
psf.1 |
✔ | 8xN | binary | |||||||
fontx |
✔ | any | binary | |||||||
cpi |
✔ | ✔ | 8xN | binary | ||||||
dec-drcs |
>4xN | binary | ||||||||
bbc |
8x8 | binary |
Container formats
monobit will recurse and extract font files from a number of common container,
archive and compression formats:
| Format | Typical Extension | Read | Write |
|---|---|---|---|
| PKZip/WinZip | .zip |
✔ | ✔ |
| GNU tar | .tar .tgz |
✔ | ✔ |
| GZip | .gz |
✔ | ✔ |
| BZip2 | .bz2 |
✔ | ✔ |
| XZ/LZMA | .xz .lzma |
✔ | ✔ |
| AppleSingle | .as |
✔ | |
| AppleDouble | .adf .rsrc |
✔ | |
| MacBinary | .bin |
✔ | |
| BinHex 4.0 | .hqx |
✔ |
Dependencies
Some formats require
- PIL (
Pillow) - reportlab
- fontTools
The renderer additionally employs
- uniseg
- python-bidi
- arabic-reshaper
All can be installed through Pip:
pip install Pillow reportlab fonttools uniseg python-bidi arabic-reshaper
Without these packages, some functionality may not be available.
Licence
monobit and the yaff specification are released under the
Expat MIT licence.
The font files in tests/fonts may be subject to more restrictive
licences. These files are not included in the packaged
distribution. Please check tests/fonts/README.md.
Acknowledgements
monobit would not exist without those documenting,
reverse-engineering, implementing and preserving font formats and files:
- The Internet Archive
- Archive Team
- Jason Scott's textfiles.com
- John Elliott's homepage
- Simon Tatham's fonts page:
monobitcontains code frommkwinfontanddewinfont - Aivosto's character set documentation
- Rebecca Bettencourt's character set documentation
- Xiphoseer's Signum Document Toolbox
- ... and many others
Other software
Other bitmap font tools you could use in conjunction with (or instead of) monobit include:
- FontForge
- Rebecca Bettencourt's Bits'n'Picas
- John Elliott's PSFTools
- Mark Leisher's
gbdfed - Simon Tatham's
mkwinfont/dewinfont - RECOIL
- John Zaitseff's console font utilities
- George Williams's Fondu
- VileR's Fontraption
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file monobit-0.33.0.tar.gz.
File metadata
- Download URL: monobit-0.33.0.tar.gz
- Upload date:
- Size: 2.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1fb6379edbbaaab3ddebff187de3717832126583c631d5c7ae0fb724f717745
|
|
| MD5 |
8b416007e191d393d9989d51ec676e12
|
|
| BLAKE2b-256 |
4178344bc2d69adc070a768c4465a4e97ae82bdde6fbecabf463000a00380688
|
File details
Details for the file monobit-0.33.0-py3-none-any.whl.
File metadata
- Download URL: monobit-0.33.0-py3-none-any.whl
- Upload date:
- Size: 3.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ebc6b042c6d4adffb40dca7febe53ae5593b62f4c0c16e264ef4b6ba769973f
|
|
| MD5 |
ca69cbd82831f8cb93245dae7fad9005
|
|
| BLAKE2b-256 |
6b6568ebbe5426ef3f7711d540010c257445fc4b1f93c02c9973119665fc25d2
|