5.19.1 Selecting Fonts

We use font to refer to any of several means of identifying a typeface: by its mounting position (‘3’), by its identifier (‘TB’), or by an abstract style (‘B’) to be combined with the default family.

Request: .ft [font]
Escape sequence: \ff
Escape sequence: \f(fn
Escape sequence: \f[font]
Register: \n[.fn]

The ft request selects the typeface font. If the argument is absent or ‘P’, it selects the previously used typeface; if there is none, it ignores the request. If font is a non-negative integer, it is interpreted as a mounting position; the font mounted there is selected. If that position refers to an abstract style, it is combined with the default family (see fam and \F below) to make a resolved font name. If the mounting position is not a style and no font is mounted there, GNU troff emits a warning in category ‘font’ and ignores the request.

If font matches a style name, it is combined with the default family to make a resolved font name. If not, font is assumed to be resolved already.

The resolved font name is subject to translation (see request ftr below). Next, the (possibly translated) font name’s mounting position is looked up; if not mounted, font is sought on the file system as a font description file and, if located, automatically mounted at the next available position (see register .fp below). If the font was mounted using an identifier different from its font description file name (see request fp below), that file name is then sought. If a font description file for the resolved font name is not found, GNU troff emits a warning in category ‘font’ and ignores the request.

The \f escape sequence is similar, accepting names or mounting positions of one character f, two characters fn, or arbitrary length font. \f[]’ selects the previous font. The syntax form ‘\fP’ is supported for backward compatibility, and ‘\f[P]’ for consistency.

eggs, bacon,
.ft I
spam,
.ft
and sausage.
.br
eggs, bacon, \fIspam,\fP and sausage.
    ⇒ eggs, bacon, spam, and sausage.
    ⇒ eggs, bacon, spam, and sausage.

The currently and previously selected fonts are properties of the environment (see Environments).

The read-only string-valued register .fn contains the resolved font name of the selected font. Copy its value to a string to save it for later use.

.ds saved-font \n[.fn]
... text involving many font changes ...
.ft \*[saved-font]

\f is not tokenized when GNU troff reads its input; it instead updates the environment. It thus can be used in requests that expect a single-character argument. We can assign a font to a margin character as follows (see Miscellaneous).

.mc \f[I]x\f[]
Request: .ftr f [g]

Translate font name f to g. Where the \f escape sequence, the F and S conditional operators, and the ft, ul, bd, cs, tkf, special, fspecial, fp, or sty requests refer to f, GNU troff uses g instead. Omit g or repeat f as g to untranslate f. f and g need not be mounted fonts.

Request: .fzoom font [zoom]
Register: \n[.zoom]

Set magnification of mounted font to factor zoom, a multiplier applied to the type size in thousandths. zoom must be non-negative. fzoom applies to glyphs when they are formatted, altering a font’s apparent size in relation to others. A missing or zero zoom is treated as ‘1000’—no magnification. font must be a resolved font name, not an abstract style.

Font magnification is transparent to some aspects of GNU troff. A change of the zoom factor affects scaling of glyph sizes, inter-word and inter-sentence spaces, and kerning adjustments on the output device, but not vertical spacing. It is not reflected in registers that report the requested or current type size, or the minimum inter-word and additional inter-sentence space sizes. It is reflected in measurements of formatted output: the horizontal drawing position register hp, interpolation of the \w escape sequence, and the registers updated by that escape sequence or the formatting of a glyph in the environment. See Environments.

fzoom can harmonize the apparent cap-heights of fonts from different families when formatted on the same baseline at the same type size.

.fzoom HR 900
.fzoom CR 1150
.fzoom PR 950
Times, \F[H]Helvetica\F[], \F[C]Courier\F[],
and \F[P]Palatino\F[].
.sp
M\F[H]M\F[C]M\F[P]M

The zoom factor of the currently selected font is available in the read-only register ‘.zoom’. It interpolates zero if there is no magnification.