Next: , Up: Using Fonts   [Contents][Index]


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]

Select the typeface font. If font is an integer, the formatter interprets it as a mounting position; the font mounted there is selected. If that position refers to an abstract style, GNU troff combines it with the default family (see fam and \F below) to make a resolved font name. If font is ‘DESC’, if the mounting position is not an abstract style and no font is mounted there, or if the mounting position is negative, the formatter ignores the request.169 If the argument is absent or ‘P’, the formatter selects the previously used typeface and makes the current selection the previous one; if there is no previous font selection, the formatter ignores the request. These data are associated with the environment.170

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. GNU troff supports the syntax form ‘\fP’ for compatibility with AT&T troff, 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 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]

The formatter does not tokenize \f when reading it; it thus can be used in requests that expect a single-character argument. We can assign a font to a margin character as follows.171

.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 expression 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.

Obtain a report of font translations defined by ftr on the standard error stream with the pftr request.172

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

Set magnification of font to factor zoom, a multiplier in thousandths applied to the type size. zoom must be non-negative. fzoom applies to glyphs when they are formatted, altering a font’s apparent size in relation to others. If zoom is missing or equal to zero or 1000, font is not magnified. font must be a resolved font name, not an abstract style or a mounting position.

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 supplemental 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.173

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 ‘.fzoom’. It interpolates zero if there is no magnification.


Next: , Up: Using Fonts   [Contents][Index]