Previous: , Up: Manipulating Type Size and Vertical Spacing   [Contents][Index]


5.20.3 Using Fractional Type Sizes

When configuring the type size, AT&T troff ignored scaling units and intepreted all measurements in points. Combined with integer arithmetic, this design choice made it impossible to support, for instance, ten-and-a-half-point type. In GNU troff, an output device can select a scaling factor that subdivides a point into “scaled points”. A type size expressed in scaled points can thus represent a non-integral size in points.

A scaled point, scaling unit s, is equal to 1/sizescale points, where the device description file, DESC, specifies sizescale and otherwise defaults to 1.137 GNU troff also defines the typographical point, scaling unit z, which explicitly specifies a type size of potentially non-integral measure. The program multiplies typographical points by sizescale and converts the value to an integer. Arguments GNU troff interprets in z units by default comprise those to the escape sequences \H and \s, to the request ps, the third argument to the cs request, and the second and fourth arguments to the tkf request.

For example, if sizescale is 1000, then a scaled point is one thousandth of a point. The request ‘.ps 10.5’ is synonymous with ‘.ps 10.5z’; both set the type size to 10,500 scaled points, or 10.5 typographical points.

Register: \n[.ps]

This read-only register interpolates the type size in scaled points. ‘\n[.ps]s’, ‘\n[.s]z’, and ‘1m’ are co-equal by definition.

.tm device=\*[.T]
.tm A: .s=\n[.s]z, .ps=\n[.ps]s
.ps 10.5
.tm B: .s=\n[.s]z, .ps=\n[.ps]s
.ps 12.3p
.tm C: .s=\n[.s]z, .ps=\n[.ps]s
.ps 8.1z
.tm D: .s=\n[.s]z, .ps=\n[.ps]s
.ps 10500s
.tm E: .s=\n[.s]z, .ps=\n[.ps]s
    ⇒ device=ps
    ⇒ A: .s=10z, .ps=10000s
    ⇒ B: .s=10.5z, .ps=10500s
    ⇒ C: .s=12.3z, .ps=12300s
    ⇒ D: .s=8.1z, .ps=8100s
    ⇒ E: .s=10.5z, .ps=10500s

It makes no sense to use the ‘z’ scaling unit in a numeric expression whose default scaling unit is neither ‘u’ nor ‘z’, so GNU troff disallows this. Similarly, it is nonsensical to use scaling units other than ‘p’, ‘s’, ‘z’, or ‘u’ in a numeric expression whose default scaling unit is ‘z’, and so GNU troff disallows those as well.

Register: \n[.psr]
Register: \n[.sr]

Output devices may be limited in the type sizes they can employ. The .s and .ps registers represent the type size selected by the formatter as it understands a device’s capability. The last requested type size is interpolated in scaled points by the read-only register .psr and in points as a decimal fraction by the read-only string-valued register .sr.

For example, if a document requests a type size of 10.95 points, and the nearest size permitted by a sizes request (or by the sizes or sizescale directives in the device’s DESC file) is 11 points, groff uses the latter value.

The \s escape sequence offers the following syntax forms that work with fractional type sizes and accept scaling units. The delimited forms need not use the neutral apostrophe; see Delimiters.

\s[n]
\s'n'

Set the type size to n typographical points; n is a numeric expression with a default scaling unit of ‘z’.

\s[+n]
\s[-n]
\s+[n]
\s-[n]
\s'+n'
\s'-n'
\s+'n'
\s-'n'

Increase or decrease the type size by n typographical points; n is a numeric expression with a default scaling unit of ‘z’. If n is ‘0’, restore the previous size.


Previous: , Up: Manipulating Type Size and Vertical Spacing   [Contents][Index]