Linux Console Font Utilities

The Linux Console Font Utilities package contains various applications to manipulate Linux console fonts. In particular, programs are included to convert standard PSF font files to a text representation and vice versa, allowing easy font editing using any text editor.

Download

There has not been an official release to date of the Linux Console Font Utilities. You can use Git to download the current development snapshot:

git clone git://git.zap.org.au/data/git/console-fonts-utils.git

You may look at the source code of this package, download a read-only copy of the Git repository or browse the source code history.

About the utilities

The following programs, written in the Python programming language, are included in the Linux Console Font Utilities package:

The following Python modules are included:

Conversion utilities

The utility programs psf2psftx, psftx2psf, freebsdvfnt2psftx, psftx2freebsdvfnt and rawfnt2psftx convert binary fonts to and from a text representation that can be edited using any text editor. This text representation is intended to be minimally simple. For example, a typical glyph for the letter A would contain a series of lines with X’s and ’s marking up the on and off pixels, as well as Unicode mappings:

GLYPH 0x41

    U+0041		# LATIN CAPITAL LETTER A

	..........
	..........
	..........
	....XX....
	...XXXX...
	..XX..XX..
	..XX..XX..
	.XX....XX.
	.XX....XX.
	.XX....XX.
	.XXXXXXXX.
	.XX....XX.
	.XX....XX.
	.XX....XX.
	.XX....XX.
	.XX....XX.
	..........
	..........
	..........
	..........

ENDGLYPH

The PSFTX text representation format is fully documented in the source file psftxio.py.

Other utilities

psftx-codechart

The psftx-codechart utility program takes a PSFTX text representation of a font and generates a PDF font coverage codechart, similar to Unicode codecharts.

For example, running psftx-codechart on the console font zap-ext-light24.psftx from the Linux Console Fonts from The ZAP Group package:

psftx-codechart zap-ext-light24.psftx zap-ext-light24.pdf

generates the PDF file zap-ext-light24.pdf:

[PDF output, page 1, for zap-ext-light24.psftx] [PDF output, page 2, for zap-ext-light24.psftx] [PDF output, page 3, for zap-ext-light24.psftx] [PDF output, page 4, for zap-ext-light24.psftx]

By default, psftx-codechart generates glyph charts with 16×16 glyphs per page. Charts with 8×8 or 4×4 glyphs per page can also be generated by specifying an appropriate ––size parameter:

psftx-codechart --size large zap-ext-light24.psftx zap-ext-light24--large.pdf
psftx-codechart --size huge  zap-ext-light24.psftx zap-ext-light24--huge.pdf

The psftx-codechart utility program requires the excellent ReportLab Python package.

psftx-encodings

The psftx-encodings utility program checks a PSFTX text representation of a font for coverage of various single-byte encodings. It is useful during the design of a font to ensure that all characters you want to cover are in fact covered. It lists any characters that are not covered by a font. For example, running this program on the font zap-ext-light24.psftx:

psftx-encodings zap-ext-light24.psftx

gives, amongst many other lines:

Filename:     zap-ext-light24.psftx
PSF version:  2
Glyph size:   10 x 24 pixels
Glyph count:  512
Unicode font: Yes (mapping table present)
Mappings:     707

Encoding ascii (US English):
    Characters in encoding: 95
    Characters matched:     95
    Characters missing:     0

Encoding iso-8859-1 (Latin-1 Western European):
    Characters in encoding: 191
    Characters matched:     191
    Characters missing:     0

[…]

Encoding cp850 (DOS Latin-1 Western European):
    Characters in encoding: 223
    Characters matched:     219
    Characters missing:     4
    Missing characters:
        U+2017 DOUBLE LOW LINE
        U+2580 UPPER HALF BLOCK
        U+2584 LOWER HALF BLOCK
        U+2593 DARK SHADE

[…]

Additional characters:
    Characters present: 127
    Characters:
        U+0182 LATIN CAPITAL LETTER B WITH TOPBAR

[…]

psftx-sampler

The psftx-sampler utility program generates sample text strings that can be displayed on a Linux console to test the glyphs in a font. For example, if you download and unpack the Linux Console Fonts from The ZAP Group package into the current directory, then run the following lines from a Linux console:

make
setfont zap-ext-light18.psf
clear; ./utils/psftx-sampler zap-ext-light18.psftx

it would display the following text:

[Sample text for zap-ext-light18.psftx]

psftx-screenshot

The psftx-screenshot utility program takes a PSFTX text representation of a font, as well as text from the standard input or a file, and generates a simulated screenshot of that text as a PNG image. For example, running psftx-screenshot on the zap-ext-light18.psftx font in the following way (adjusting the path of zap-ext-light18.psftx as appropriate):

psftx-sampler .../zap-ext-light18.psftx | psftx-screenshot .../zap-ext-light18.psftx - zap-ext-light18.png

gives the PNG image displayed above.

The psftx-screenshot utility program requires the very useful Pillow PIL Python package.

psftx-template

The psftx-template utility program creates a blank template PSFTX file for a given font size. For example, running:

psftx-template --output newfont.psftx 8x16 256

generates the file newfont.psftx that contains 256 glyphs of size 8×16 pixels:

# PSFTX font file template
#
# Name:   newfont.psftx
# Size:   8 x 16 pixels
# Glyphs: 256


PSFTX FONT VERSION 1


GLYPH 0x00

        ........
        ........
        ........
        ........
        ........
        ........
        ........
        ........
        ........
        ........
        ........
        ........
        ........
        ........
        ........
        ........

ENDGLYPH

[…]

Feedback

Your comments, suggestions, corrections and enhancements are always warmly welcomed! Please send these to:

Postal: John Zaitseff,
The ZAP Group,
Unit 6, 116 Woodburn Road,
Berala, NSW, 2141,
Australia
E-mail: J.Zaitseff@zap.org.au
Web: http://www.zap.org.au/software/fonts/console-fonts-utils/
FTP: ftp://ftp.zap.org.au/pub/fonts/console-fonts-utils/

Copyright © 2004–17, John Zaitseff.

The Linux Console Font Utilities package is free software that is distributed under the terms of the GNU General Public License. You can redistribute it and/or modify it under the terms of that License as published by the Free Software Foundation, either version 3 or (at your option) any later version.

This software 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.