5.19.8 Ligatures and Kerning

Ligatures are groups of characters that are run together, i.e, producing a single glyph. For example, the letters ‘f’ and ‘i’ can form a ligature ‘fi’ as in the word ‘file’. This produces a cleaner look (albeit subtle) to the printed output. Usually, ligatures are not available in fonts for TTY output devices.

Most PostScript fonts support the fi and fl ligatures. The C/A/T typesetter that was the target of AT&T troff also supported ‘ff’, ‘ffi’, and ‘ffl’ ligatures. Advanced typesetters or ‘expert’ fonts may include ligatures for ‘ft’ and ‘ct’, although GNU troff does not support these (yet).

Only the current font is checked for ligatures and kerns; neither special fonts nor entities defined with the char request (and its siblings) are taken into account.

Request: .lg [flag]
Register: \n[.lg]

Switch the ligature mechanism on or off; if the parameter is non-zero or missing, ligatures are enabled, otherwise disabled. Default is on. The current ligature mode can be found in the read-only register .lg (set to 1 or 2 if ligatures are enabled, 0 otherwise).

Setting the ligature mode to 2 enables the two-character ligatures (fi, fl, and ff) and disables the three-character ligatures (ffi and ffl).

Pairwise kerning is another subtle typesetting mechanism that modifies the distance between a glyph pair to improve readability. In most cases (but not always) the distance is decreased. Typewriter-like fonts and fonts for terminals where all glyphs have the same width don’t use kerning.

Request: .kern [flag]
Register: \n[.kern]

Switch kerning on or off. If the parameter is non-zero or missing, enable pairwise kerning, otherwise disable it. The read-only register .kern is set to 1 if pairwise kerning is enabled, 0 otherwise.

If the font description file contains pairwise kerning information, glyphs from that font are kerned. Kerning between two glyphs can be inhibited by placing \& between them: ‘V\&A’.

See Font Description File Format.

Track kerning expands or reduces the space between glyphs. This can be handy, for example, if you need to squeeze a long word onto a single line or spread some text to fill a narrow column. It must be used with great care since it is usually considered bad typography if the reader notices the effect.

Request: .tkf f s1 n1 s2 n2

Enable track kerning for font f. If the current font is f the width of every glyph is increased by an amount between n1 and n2 (n1, n2 can be negative); if the current type size is less than or equal to s1 the width is increased by n1; if it is greater than or equal to s2 the width is increased by n2; if the type size is greater than or equal to s1 and less than or equal to s2 the increase in width is a linear function of the type size.

The default scaling indicator is ‘z’ for s1 and s2, ‘p’ for n1 and n2.

The track kerning amount is added even to the rightmost glyph in a line; for large values it is thus recommended to increase the line length by the same amount to compensate.

Sometimes, when typesetting letters of different fonts, more or less space at such boundaries is needed. There are two escape sequences to help with this.

Escape sequence: \/

Apply an italic correction: modify the spacing of the preceding glyph so that the distance between it and the following glyph is correct if the latter is of upright shape. For example, if an italic ‘f’ is followed immediately by a roman right parenthesis, then in many fonts the top right portion of the ‘f’ overlaps the top left of the right parenthesis, which is ugly. Use this escape sequence whenever an oblique glyph is immediately followed by an upright glyph without any intervening space.

Escape sequence: \,

Apply a left italic correction: modify the spacing of the following glyph so that the distance between it and the preceding glyph is correct if the latter is of upright shape. For example, if a roman left parenthesis is immediately followed by an italic ‘f’, then in many fonts the bottom left portion of the ‘f’ overlaps the bottom of the left parenthesis, which is ugly. Use this escape sequence whenever an upright glyph is followed immediately by an oblique glyph without any intervening space.

Escape sequence: \&

Insert a non-printing input break, which is invisible. Its intended use is to stop interaction of a character with its surroundings.

  • It prevents the insertion of extra space after an end-of-sentence character.
    Test.
    Test.
        ⇒ Test.  Test.
    Test.\&
    Test.
        ⇒ Test. Test.
    
  • It prevents interpretation of a control character at the beginning of an input line.
    .Test
        error→ warning: macro 'Test' not defined
    \&.Test
        ⇒ .Test
    
  • It prevents kerning between two glyphs.
  • It is needed to map an arbitrary character to nothing in the tr request (see Character Translations).
Escape sequence: \)

This escape is similar to \& except that it behaves like a character declared with the cflags request to be transparent for the purposes of an end-of-sentence character.

Its main usage is in macro definitions to protect against arguments starting with a control character.

.de xxx
\)\\$1
..
.de yyy
\&\\$1
..
This is a test.\c
.xxx '
This is a test.
    ⇒This is a test.'  This is a test.
This is a test.\c
.yyy '
This is a test.
    ⇒This is a test.' This is a test.