5.19.3 Font Positions

To support typeface indirection through styles, and for compatibility with AT&T troff, the formatter maintains a list of font positions at which fonts required by a document are mounted. An output device’s description file DESC typically configures a set of pre-mounted fonts; see Device and Font Description Files. A font need not be explicitly mounted before it is selected; GNU troff will search GROFF_FONT_PATH for it by name and mount it at the first free mounting position on demand.

Request: .fp pos font [external-name]
Register: \n[.f]
Register: \n[.fp]

Mount the font named font at position pos, a non-negative integer. This numeric index can then be referred to with font selection instructions. When the formatter starts up, it reads the output device’s description to mount an initial set of faces, and selects font position 1. Position 0 is unused by default. Unless the external-name argument is given, the name font should be that of a font description file stored in a directory corresponding to the selected output device.

The position of the currently selected font (or style) is available in the read-only register ‘.f’. It is associated with the environment (see Environments).

The value of .f can be copied to another register to save the current font or style for later recall.

.nr saved-font \n[.f]
.ft B
 text text text 
.ft \n[saved-font]

The index of the next (nonzero) free font position is available in the read-only register ‘.fp’. Fonts not listed in the DESC file are automatically mounted at position ‘\n[.fp]’ when selected. When mounting a font at a position explicitly with the fp request, this same practice should be followed, although GNU troff does not enforce this strictly.

If there is no third argument, the font description is sought in the file system under the name font.

The optional third argument external-name is the name of a font description file in the operating environment. GNU troff refuses to traverse directories to locate the font description. The second argument font is then the internal name of the font, which identifies it to GNU troff once it has been mounted. This feature enables font names to be aliased, which can be necessary in compatibility mode since AT&T troff syntax affords no means of identifying fonts with names longer than two characters, like ‘TBI’ or ‘ZCMI’, in a font selection escape sequence. See Compatibility Mode. You can also alias fonts on mounting for convenience or abstraction.

.ft SC ZCMI \" "script" font
Send a \f(SChand-written\fP thank-you note.
.ft Emph I
.ft Strong B
Are \f[Emph]these names\f[] \f[Strong]comfortable\f[]?

The ft request and \f escape sequence accept mounting positions in the place of font or style names.

Request: .ft nnn
Escape sequence: \fn
Escape sequence: \f(nn
Escape sequence: \f[nnn]

Select font position nnn (one-digit position n, two-digit position nn), which must be a non-negative integer. If nnn is associated with a style (as set with the sty request or with the styles command in the DESC file), use it within the current font family (as set with the fam request, the \F escape sequence, or the family command in the DESC file).

this is font 1
.ft 2
this is font 2
.ft                   \" switch back to font 1
.ft 3
this is font 3
.ft
this is font 1 again

See Changing Fonts, for font selection by name.