Next: , Previous: , Up: Fonts and Symbols   [Contents][Index]


5.17.1 Changing Fonts

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

The ft request and the \f escape change the current font to font (one-character name f, two-character name fn).

If font is a style name (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, \F escape, or with the family command in the DESC file).

It is not possible to switch to a font with the name ‘DESC’ (whereas this name could be used as a style name; however, this is not recommended).

With no argument or using ‘P’ as an argument, .ft switches to the previous font. Use \f[] to do this with the escape. The old syntax forms \fP or \f[P] are also supported.

Fonts are generally specified as upper-case strings, which are usually 1 to 4 characters representing an abbreviation or acronym of the font name. This is no limitation, just a convention.

The example below produces two identical lines.

eggs, bacon,
.ft B
spam
.ft
and sausage.

eggs, bacon, \fBspam\fP and sausage.

Note that \f doesn’t produce an input token in gtroff. As a consequence, it can be used in requests like mc (which expects a single character as an argument) to change the font on the fly:

.mc \f[I]x\f[]

The current style name is available in the read-only number register ‘.sty’ (this is a string-valued register); if the current font isn’t a style, the empty string is returned. It is associated with the current environment.

See Font Positions, for an alternative syntax.

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.

Note that it is not possible to chain font translations. Example:

.ftr XXX TR
.ftr XXX YYY
.ft XXX
    ⇒ 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 real font name, not a style.

Note that the magnification of a font is completely transparent to 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 number register ‘.zoom’, in multiples of 1/1000th. It returns zero if there is no magnification.


Next: , Previous: , Up: Fonts and Symbols   [Contents][Index]