Gallant: 12x22 raster font with Unicode glyphs

2 hours ago 1

This is the Gallant font, as used by the Sun Microsystems SPARCstation console, extended with glyphs for many Unicode blocks. It is a raster font with a 22x12 pixel character cell, descent 5 and ascent 17.

The starting point was the gallant.hex file as found on FreeBSD 14, which contained 502 glyphs at the time. This project currently provides more than 4600 glyphs. Major additions:

  • Greek
  • Cyrillic
  • International Phonetic Association Extensions
  • Extended Latin characters
  • Zapf Dingbats
  • Tons of arrows
  • Tons of mathematical symbols
  • Letterlike symbols and enclosed alphanumerics
  • Pixel-perfect box drawing
  • Currency symbols
  • More punctuation
  • Just enough Katakana to say コンニチハ
  • Powerline glyphs in the Private Use Area at U+e0a0

I have tried hard to keep the look of the font for Greek and Cyrillic glyphs, but not for symbols like arrows and mathematical operators where it makes no sense. Please let me know where I messed up (I can only barely read and write Greek, and hardly any Cyrillic and no Japanese at all). I used the documents of The Unicode Standard, Version 16.0 as guidance. See Unicode.org for more on Unicode.

In the following table's Status column, Complete means all glyphs are present, Partial means at least one glyph is present, TODO means none are present.

Codepoints >= U+10000 can be part of a BDF file, but cannot be used by core X11 since it internally restricts glyph encoding numbers to 16 bit. The X server then says BDF Error on line X: char 'U+10000' has encoding too large (65536). This limitation does not apply to Xft rendered fonts.

The FreeBSD vt(4) driver works fine with the full 32 bit codepoint range.

The Images directory contains white-on-black and black-on-white (suffixed -Inverted) PNG image files for the separate blocks and Markus Kuhn's UTF-8-demo.txt, licensed CC BY; no changes were made to the text before rendering it in Gallant.

How do I use this GNUmakefile?

If you just want to use one of the gallant.* font files, you don't need to build anything. See "How do I load/use this font?" below.

If you want to modify or add glyphs, edit gallant.src and then make.

You will obviously need GNU make (FreeBSD: devel/gmake). To build the TrueType gallant.ttf you will need FontForge (print/fontforge). To build images with txttopng the PNG library is required (graphics/png).

How do I load/use this font?

As an X11 Raster Font, e.g. for Xterm(1)

Install the BDF file gallant.bdf or the PCF file gallant.pcf.gz where X11 looks for fonts. You can query the current font path with xset q | sed -n '/^Font/,/^ /p'. If you do not have write permission to any of the font directories, you may create your own under, say, $HOME/.fonts.

The following example uses $HOME/.fonts as the font directory and adds it to the font path. To make the font path addition permanent, you should add the xset lines to your $HOME/.xinitrc or equivalent X11 startup file (common candidates are .xsession and .xprofile).

mkdir -p $HOME/.fonts cp gallant.bfd $HOME/.fonts cd $HOME/.fonts mkfontdir xset fp+ $HOME/.fonts xset fp rehash xterm -fa '' -fn "-sun-gallant-medium-r-normal-*-22-*-*-*-*-80-*-*"
vidcontrol -f /path/to/gallant.fnt

You may also drop the font files into directory /usr/share/vt/fonts and add allscreens_flags="-f gallant" to your /etc/rc.conf. This way all console terminals use the font after boot.

For the full Gallant boot experience, make the loader use 12x22.fnt.gz early:

  • Copy it to /boot/fonts/12x22.fnt.gz.
  • Add screen.font="12x22" (without .fnt.gz) to /boot/loader.conf.
  • Make sure that /boot/fonts/INDEX.fonts contains these lines, preferably after the 11x22.fnt: entries.
    12x22.fnt:en:Gallant BSD Console, size 22 12x22.fnt:da:Gallant BSD-konsol, størrelse 22 12x22.fnt:de:Gallant BSD Console, Größe 22
  • For even more Sun Microsystems reminiscence, switch to black on white. In /boot/loader.conf set teken.fg_color="0" and teken.bg_color="7".
  • To use the FreeBSD logo with inverted colors, edit /boot/lua/drawer.lua. Look for the assignment image = "/boot/images/freebsd-brand-rev.png" and replace it with image = "/boot/images/freebsd-brand.png".

Linux, NetBSD, OpenBSD Console

The Linux console uses PSF fonts. As of 2025 this format can only contain 256 or 512 glyphs.

The NetBSD console (wscons) is also restricted to 512 glyphs. It does not handle double width or combining characters.

OpenBSD's wscons was inherited from NetBSD, so similar restrictions apply.

The glyphs in this Gallant project would have to be severely reduced in number to fit. If someone wants to contribute a stripped down font in the appropriate format, I'm willing to add it to this project.

The gallant.ttf file is a conversion from BDF to TTF using FontForge. (See the GNUmakefile for the scripted command sequence.) A TTF font can contain a raster font at its design size; sometimes this is called a bit strike. On systems supporting TrueType you may be able to use Gallant. The font family name is Gallant12 to disambiguate it from gallant and to indicate that the design size is 12. Usage example with xterm:

xterm -fa Gallant12:size=12

You can use a larger size value, but that will only affect the line spacing, not the glyph size. Visually this is most apparent in the box drawing characters, where there will be vertical gaps. The same applies to all glyphs that connect to glyphs above and below, such as large parentheses, braces, brackets, integrals, etc.

The TrueType gallant.ttf does not work on Windows. What's going on?

The symptom is that Windows displays a popup along "gallant.ttf is not a valid font file" when you want to copy gallant.ttf to C:\Windows\Fonts or install it some other way.

There seem to be at least two issues.

  1. I'm told Windows considers a font invalid if it does not contain a certain set of six Hiragana glyphs. I have added them to the BDF but this is not enough to solve the "gallant.ttf is not a valid font file" popup.
  2. Windows wants a scalable outline font. A bitmap-only TrueType font file is invalid. I have yet to find an automated way, preferably with fontforge script commands, to add an outline font with a square pixel for each pixel.

Is there a gallant.fon for Windows?

No. The fon file format, dated as it is, does not support Unicode and would only contain 256 glyphs.

I'm an ex-Sun Microsystems software engineer who had a stint in the company shortly before Oracle took over (2008/2009). I was nowhere near the OpenBoot PROM files which contained the Gallant font. My first contact with SUN hardware was in the early 90's at university with the 3/60 and the SPARCstations. It was then and there that the Gallant font and the Trinitron CRT raster were burnt in my retina.

How did you edit the glyphs?

With a text editor (vim). I wrote the hextosrc utility which turns gallant.hex into a human readable file named gallant.src with one character cell per pixel, a row count from 22 down to 1 so I know where the baseline (06) is and each pixel row between | characters (12 or 24, space for pixel not set, full block █ for set). My srctohex utility converts in the opposite direction.

This is what the glyph for A looks like in gallant.src:

STARTCHAR U0041 LATIN CAPITAL LETTER A 22 | | 21 | | 20 | | 19 | ██ | 18 | ██ | 17 | █ ██ | 16 | █ ██ | 15 | █ █ | 14 | █ ██ | 13 | █ ██ | 12 | █ █ | 11 | ████████ | 10 | █ ██ | 09 | █ █ | 08 | █ ██ | 07 | █ ██ | 06 |███ ████| 05 | | 04 | | 03 | | 02 | | 01 | | ENDCHAR

The row numbers and Unicode names are ignored by srctohex, and inserted/restored by hextosrc. This allows to freely add and delete pixel rows without tedious row renumbering or knowing the Unicode name.

The utilities are complemented by hextobdf to generate gallant.bdf. From there, other tools can create additional font formats.

The oldest reference to the Gallant font I could find at first was in a Copyright notice in NetBSD's gallant12x22.h which reads:

/* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to the Computer Systems * Engineering Group at Lawrence Berkeley Laboratory and to the University * of California at Berkeley by Jef Poskanzer. * [...] * Derived from: @(#)gallant19.h 8.1 (Berkeley) 6/11/93 */

In private conversation with the author, Jef said he guessed that the Gallant font was designed by someone at Sun Microsystems before it made its way to Berkeley.

Further research examining the Unix history site v6sh.org revealed a list of the 4.4BSD-Alpha src directory contents which contains an rcons directory with these files:

rwxrwxr-x 3/9 0 Jul 25 07:58 1992 usr/src/sys/sparc/rcons/ rwxrwxr-x 3/9 0 Jul 25 07:58 1992 usr/src/sys/sparc/rcons/tags symbolic link to /var/db/sys_tags r--r--r-- 3/9 46247 Jul 22 09:49 1992 usr/src/sys/sparc/rcons/gallant19.h r--r--r-- 3/9 9548 Jul 22 09:50 1992 usr/src/sys/sparc/rcons/raster.h r--r--r-- 3/9 29785 Jul 22 09:50 1992 usr/src/sys/sparc/rcons/raster_op.c r--r--r-- 3/9 6870 Jul 22 09:50 1992 usr/src/sys/sparc/rcons/raster_text.c r--r--r-- 3/9 2840 Jul 22 09:50 1992 usr/src/sys/sparc/rcons/rcons_font.c r--r--r-- 3/9 7756 Jul 22 09:50 1992 usr/src/sys/sparc/rcons/rcons_kern.c r--r--r-- 3/9 15437 Jul 22 09:50 1992 usr/src/sys/sparc/rcons/rcons_subr.c

Gallant's relevant C language header file is in History/rcons/gallant19.h.

The 4.3BSD src and src/sys tape archives do not contain gallant19.h, which makes it likely it was acquired between 4.3BSD and 4.4BSD.

After asking in the Usenet newsgroup comp.sys.sun.hardware—16 years after Sun was acquired by Oracle people do lurk there—some helpful soul reached out to me with links to the OpenBoot gallant font and a PDF titled From the Valley of Heart's Delight to the Silicon Valley: A Study of Stanford University's Role in the Transformation by Carolyn Tajnai which in Appendix A reveals as the designer of the Gallant font no one less than Stanford professor Vaughan Pratt, who also designed the iconic Sun logo.

Sun Microsystems Logo

In an article in comp.sys.sun.hardware (Oct 11 1995) Vaughan Pratt provides this anecdote how Gallant came to be:

[...] That big font in the PROM monitor, I did that in April 1982 too, started out doing it by hand on graph paper until I realized I'd finish a lot sooner if I wrote a font editor first (pretty trivial editor, involved about three hours work but it saved several days of messing with graph paper). I called the font Gallant because it sounded like a font name.

Codepoints 0 through 31 contain glyphs of the VT100 line-drawing character set otherwise known as the DEC Special Character and Line Drawing Set. They were left unmodified to not change their intended use by applications that expect them there. Each of the special characters also has an "official" Unicode codepoint. Contemporary applications should never need to render them. This is the mapping:

Special Official Name
U+0000 U+25AE black vertical rectangle
U+0001 U+25C6 black diamond
U+0002 U+2592 medium shade
U+0003 U+2409 symbol for horizontal tabulation
U+0004 U+240C symbol for form feed
U+0005 U+240D symbol for carriage return
U+0006 U+240A symbol for line feed
U+0007 U+00B0 degree sign
U+0008 U+00B1 plus-minus sign
U+0009 U+2424 symbol for newline
U+000a U+240B symbol for vertical tabulation
U+000b U+2518 box drawings light up and left
U+000c U+2510 box drawings light down and left
U+000d U+250C box drawings light down and right
U+000e U+2514 box drawings light up and right
U+000f U+253C box drawings light vertical and horizontal
U+0010 U+23BA box drawings scan 1
U+0011 U+23BB box drawings scan 3
U+0012 U+2500 box drawings light horizontal
U+0013 U+23BC box drawings scan 7
U+0014 U+23BD box drawings scan 9
U+0015 U+251C box drawings light vertical and right
U+0016 U+2524 box drawings light vertical and left
U+0017 U+2534 box drawings light up and horizontal
U+0018 U+252C box drawings light down and horizontal
U+0019 U+2502 box drawings light vertical
U+001a U+2264 less-than or equal to
U+001b U+2265 greater-than or equal to
U+001c U+03C0 greek small letter pi
U+001d U+2260 not equal to
U+001e U+00A3 pound sign
U+001f U+00B7 middle dot
  • Describe how to contribute.
  • Commit 12x22 for loader use to FreeBSD once code slush is over.
Read Entire Article