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


5.19.1 Selecting Fonts

We use font to refer to any of several means of identifying a font: by mounting position (‘3’), by abstract style (‘B’), or by its identifier (‘TB’).

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 chosen font. If font is a non-negative integer, it is interpreted as 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 current family to make a resolved font name. Otherwise, font is assumed to already be a resolved font name.

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 looked up. 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, using one-character name (or mounting position) f, two-character name fn, or a name font of arbitrary length. \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 current 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.

\f doesn’t produce an input token in GNU troff; 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 f to font g. Whenever a font named f is referred to in a \f escape sequence, in the F and S conditional operators, or in the ft, ul, bd, cs, tkf, special, fspecial, fp, or sty requests, font g is used. If g is missing or equal to f the translation is undone.

Font translations cannot be chained.

.ftr XXX TR
.ftr XXX YYY
.ft XXX
    error→ warning: can't find font 'XXX'
Request: .fzoom f [zoom]
Register: \n[.zoom]

Set magnification of font f to factor zoom, which must be a non-negative integer multiple of 1/1000th. This request is useful to adjust the optical size of a font in relation to the others. In the example below, font CR is magnified by 10% (the zoom factor is thus 1.1).

.fam P
.fzoom CR 1100
.ps 12
Palatino and \f[CR]Courier\f[]

A missing or zero value of zoom is the same as a value of 1000, which means no magnification. f must be a resolved font name, not an abstract style.

The magnification of a font is completely transparent to GNU troff; a change of the zoom factor doesn’t cause any effect except that the dimensions of glyphs, (word) spaces, kerns, etc., of the affected font are adjusted accordingly.

The zoom factor of the current font is available in the read-only register ‘.zoom’, in multiples of 1/1000th. It returns zero if there is no magnification.


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