fontsrv is a Plan 9 / Inferno-style 9P file server that provides filesystem access to scalable fonts (via FreeType), exposing them in the standard Plan 9 font + subfont format.
By default it mounts a virtual font tree at /mnt/font and posts itself as the font service.
The exported filesystem is a two-level hierarchy:
/mnt/font/<fontname>/<size>directories for monochrome bitmaps (e.g.13)<size>adirectories for anti-aliased greyscale (e.g.13a)font– a Plan 9fontfile describing height/ascent and listing available subfontsx000000.bit,x000100.bit, ... – subfont pages covering Unicode ranges
Sizes can be synthesized on demand: walking to (for example) 19a will generate that size if possible.
fontsrv [-m mtpt] [-s srvname]-m mtptmountpoint (default:/mnt/font)-s srvnameposted service name (default:font)
List available fonts:
% fontsrv
% ls /mnt/font/Run acme using Monaco as fixed-width font:
% acme -F /mnt/font/Monaco/13a/fontRun sam using the same font:
% font=/mnt/font/Monaco/13a/font samfontsrv reads font definitions from:
/sys/lib/fontsrv.map
The file is line-oriented. It supports either:
path/to/fontfile.ttfFontName path/to/fontfile.ttf
Lines may include comments (# ...) when the # is at the start of the line or preceded by whitespace.
This repo includes an example map file at lib/fontsrv, and the top-level mkfile installs it as /sys/lib/fontsrv.map.
This repository is set up for Plan 9's mk build system.
Key files:
mkfile– builds thefontsrvbinary and the bundled FreeType librarylibfreetype/– vendored FreeType sources +mkfile
To build:
% mkTo install the binary, map file, and manpage:
% mk installInstallation copies:
lib/fontsrv→/sys/lib/fontsrv.mapman/4/fontsrv.4→/sys/man/4/fontsrv.4
- The 9P server is implemented in
fontsrv.c(usinglib9p), with a synthetic tree of Qids encoding:- which font
- which point size
- mono vs anti-aliased
- which Unicode "page"
- FreeType rendering is handled in
freetype.c, which:- discovers fonts from
/sys/lib/fontsrv.map - lazily loads faces
- renders glyph pages into
Memsubfontobjects on demand
- discovers fonts from
- Subfont pages are served as
.bitfiles namedx%06x.bit, where the hex value is the start rune for that page.
- Bitmap-only fonts are not supported (the server requires scalable faces).
- Subpixel rendering is not available.
- Hinting heuristics may not always pick the best appearance for every font/size (see the manpage).
man/4/fontsrv.4- Plan 9 font format documentation (
font(7))