Subfonts are cached within the program, so a subfont shared between fonts will be loaded only once. Installsubfont stores subfont f under the given name, typically the file name from which it was read. Uninstallsubfont removes the subfont from the cache. Finally, lookupsubfont searches for a subfont with the given name in the cache and returns it, or nil if no such subfont exists.
Subfontname is used to locate subfonts given their names within the fonts. The default version constructs a name given the cfname, its name within the font, fname, the name of the font, and the maximum depth suitable for this subfont. This interface allows a partially specified name within a font to be resolved at run-time to the name of a file holding a suitable subfont. Although it is principally a routine internal to the library, subfontname may be substituted by the application to provide a less file-oriented subfont naming scheme.
The format of a subfont file is described in font(7). Briefly, it contains a image with all the characters in it, followed by a subfont header, followed by character information. Readsubfont reads a subfont from the file descriptor fd. The name is used to identify the font in the cache. The dolock argument specifies whether the routine should synchronize use of the Display with other processes; for single-threaded applications it may always be zero. Readsubfonti does the same for a subfont whose associated image is already in memory; it is passed as the argument im. In other words, readsubfonti reads only the header and character information from the file descriptor.
Writesubfont writes on fd the part of a subfont file that comes after the image. It should be preceded by a call to writeimage (see allocimage(3)).
Stringsubfont is analogous to string (see draw(3)) for subfonts. Rather than use the underlying font caching primitives, it calls draw for each character. It is intended for stand-alone environments such as operating system kernels. Strsubfontwidth returns the width of the string s in as it would appear if drawn with stringsubfont in Subfont f.
Mkfont takes as argument a Subfont s and returns a pointer to a Font that maps the character images in s into the Runes min to min+s->n-1.
/usr/local/plan9/font bitmap font file tree
All of the functions use the graphics error function (see graphics(3)).