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

5.17.2 Font Families

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 Groff Options).

Request: .fam [family]
Register: \n[.fam]
Escape: \Ff
Escape: \F(fm
Escape: \F[family]
Register: \n[.fn]

Switch font family to family (one-character name f, two-character name fm). If no argument is given, switch back to the previous font family. Use \F[] to do this with the escape. Note that \FP doesn’t work; it selects font family ‘P’ instead.

The value at start-up is ‘T’. The current font family is available in the read-only number register ‘.fam’ (this is a string-valued register); it is associated with the current environment.

.fam H    \" helvetica family
spam,     \" used font is family H + style R = HR
.ft B     \" family H + style B = font HB
.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.

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 family on the fly:

.mc \F[P]x\F[]

The ‘.fn’ register contains the current real font name of the current font. This is a string-valued register. If the current font is a style, the value of \n[.fn] is the proper concatenation of family and style name.

Request: .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 which 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 value.

The default family can be set with the -f option (see Groff 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
    ⇒ warning: can't find font `FooR'

The default font position at start-up 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.

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