Due to the variety of fonts available, gtroff
has added the
concept of font families and font styles. The fonts are
specified as the concatenation of the font family and style. Specifying
a font without the family part causes gtroff
to use that style of
the current family.
Currently, fonts for the devices -Tps, -Tpdf,
-Tdvi, -Tlj4, -Tlbp, and the X11 fonts are
set up to this mechanism. By default, gtroff
uses the Times
family with the four styles ‘R’, ‘I’, ‘B’, and ‘BI’.
This way, it is possible to use the basic four fonts and to select a different font family on the command line (see Options).
.fam
[family] ¶\n[.fam]
¶\F
f
¶\F(
fm
¶\F[
family]
¶\n[.fn]
¶Set the font family to family (one-character name f,
two-character name fm). If no argument is given, switch to the
previous font family, or the default family if there is none. Use
‘\F[]’ to do this with an escape sequence; ‘\FP’ selects font
family ‘P’ instead. The initial font family is ‘T’ (Times),
but can be overridden by the output device description file—See DESC File Format. The current font family is available in the read-only
string-valued register .fam
; it is associated with the
environment (see Environments).
spam, .fam H \" helvetica family spam, \" used font is family H + style R = HR .ft B \" family H + style B = font HB spam, .fam T \" times family spam, \" used font is family T + style B = TB .ft AR \" font AR (not a style) baked beans, .ft R \" family T + style R = font TR and spam.
\F
doesn’t produce an input token in GNU troff
. As a
consequence, it can be used in requests like mc
(which expects
a single character as an argument) to change the font family on the fly.
.mc \F[P]x\F[]
The read-only string-valued register .fn
contains the current
real font name of the current font. If the current font is a
style, the value of \n[.fn]
is the proper concatenation of family
and style name.
.sty
n style ¶Associate style with font position n. A font position
can be associated either with a font or with a style. The current font
is the index of a font position and so is also either a font or a style.
If it is a style, the font that is actually used is the font whose name
is the concatenation of the name of the current family and the name of
the current style. For example, if the current font is 1 and font
position 1 is associated with style ‘R’ and the current font
family is ‘T’, then font ‘TR’ is used. If the current font is
not a style, then the current family is ignored. If the requests
cs
, bd
, tkf
, uf
, or fspecial
are
applied to a style, they are instead applied to the member of the
current family corresponding to that style.
n must be a non-negative integer.
The default family can be set with the -f option (see Options). The styles
command in the DESC file controls
which font positions (if any) are initially associated with styles
rather than fonts. For example, the default setting for PostScript
fonts
styles R I B BI
is equivalent to
.sty 1 R .sty 2 I .sty 3 B .sty 4 BI
fam
and \F
always check whether the current font position
is valid; this can give surprising results if the current font position
is associated with a style.
In the following example, we want to access the PostScript font
FooBar
from the font family Foo
:
.sty \n[.fp] Bar .fam Foo error→ warning: can't find font 'FooR'
The default font position at startup is 1; for the PostScript
device, this is associated with style ‘R’, so gtroff
tries
to open FooR
.
A solution to this problem is to use a dummy font like the following:
.fp 0 dummy TR \" set up dummy font at position 0 .sty \n[.fp] Bar \" register style `Bar' .ft 0 \" switch to font at position 0 .fam Foo \" activate family `Foo' .ft Bar \" switch to font `FooBar'
See Font Positions.