2.3.2 Using the ENABLERELATIVEWIDTHS Escape

When the application calls the ENABLERELATIVEWIDTHS escape, the driver expects the application to request a font height in device units, but will return the character width in font units. The application may want to obtain widths in font units to alleviate any error that may result from rounding widths to device units. It

is the responsibility of the driver to correct this error when relative widths are disabled, but the application may choose to enable relative widths and perform its own error correction.

The driver converts the font height (in device units) to font units prior to computing the character width. The resulting formula is:

font height in device units *

character extent in font units

character width in font units = ————————————————————————————————

etmMasterHeight device units

This formula was computed by replacing the “font height” from the first formula for character width with the formula for converting a value from device units to font units, and then simplifying the equation.

Using the same assumptions provided in the previous section, you can now work through some more examples. You know that the width of the character is 25 device units (that is, dots or pixels) or half the height of 50 device units. With relative widths enabled, the character width would be computed using the second width formula:

50 device units * 500 font units

—————————————————————————————————— = 83.333 font units

300 device units

The width of the character is 83.333 font units. The driver will round noninteger results.

To demonstrate that the width in font units is equivalent to the width in device units, it can be converted to device units using the formula provided in the previous section:

83.333 font units * 300 device units

—————————————————————————————————————— = 25 device units

1000 font units

For more information about the restrictions imposed by drivers, see Chapter 3, “The PFM Editor,” and Chapter 4, “PCL/HP LaserJet Printer Driver.”