Next: , Previous: Font Families, Up: Fonts and Symbols


5.17.3 Font Positions

For the sake of old phototypesetters and compatibility with old versions of troff, gtroff has the concept of font positions, on which various fonts are mounted.

— Request: .fp pos font [external-name]
— Register: \n[.f]
— Register: \n[.fp]

Mount font font at position pos (which must be a non-negative integer). This numeric position can then be referred to with font changing commands. When gtroff starts it is using font position 1 (which must exist; position 0 is unused usually at start-up).

The current font in use, as a font position, is available in the read-only number register ‘.f’. This can be useful to remember the current font for later recall. It is associated with the current environment (see Environments).

          
          .nr save-font \n[.f]
          .ft B
          ... text text text ...
          .ft \n[save-font]

The number of the next free font position is available in the read-only number register ‘.fp’. This is useful when mounting a new font, like so:

          
          .fp \n[.fp] NEATOFONT

Fonts not listed in the DESC file are automatically mounted on the next available font position when they are referenced. If a font is to be mounted explicitly with the fp request on an unused font position, it should be mounted on the first unused font position, which can be found in the .fp register. Although gtroff does not enforce this strictly, it is not allowed to mount a font at a position whose number is much greater (approx. 1000 positions) than that of any currently used position.

The fp request has an optional third argument. This argument gives the external name of the font, which is used for finding the font description file. The second argument gives the internal name of the font which is used to refer to the font in gtroff after it has been mounted. If there is no third argument then the internal name is used as the external name. This feature makes it possible to use fonts with long names in compatibility mode.

Both the ft request and the \f escape have alternative syntax forms to access font positions.

— Request: .ft nnn
— Escape: \fn
— Escape: \f(nn
— Escape: \f[nnn]

Change the current font position to nnn (one-digit position n, two-digit position nn), which must be a non-negative integer.

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

          
          this is font 1
          .ft 2
          this is font 2
          .ft                   \" switch back to font 1
          .ft 3
          this is font 3
          .ft
          this is font 1 again

See Changing Fonts, for the standard syntax form.