Device Tables

Glyphs in a font are defined in design units specified by the font developer. Font scaling increases or decreases a glyph's size and rounds it to the nearest whole pixel. However, precise glyph positioning often requires adjustment of these scaled and rounded values. Hinting, applied to points in the glyph outline, is an effective solution to this problem, but it may require the font developer to redesign or re-hint glyphs.

Another solution—used by the GPOS, BASE, JSTF, and GDEF tables—is to use a Device table to specify correction values to adjust the scaled design units. A Device table applies the correction values to the range of sizes identified by StartSize and EndSize, which specify the smallest and largest pixel-per-em (ppem) sizes needing adjustment.

Because the adjustments often are very small (a pixel or two), the correction can be compressed into a 2-, 4-, or 8-bit representation per size. Two bits can represent a number in the range {-2, -1, 0, or 1}, four bits can represent a number in the range {-8 to 7}, and eight bits can represent a number in the range {-128 to 127}. The Device table identifies one of three data formats—signed 2-, 4,- or 8-bit values—for the adjustment values (DeltaFormat). A single Device table provides delta information for one coordinate at a range of sizes.

Format

Bits

Description

1

2

Signed 2-bit value, 8 values per uint16

2

4

Signed 4-bit value, 4 values per uint16

3

8

Signed 8-bit value, 2 values per uint16


The 2-, 4-, or 8-bit signed values are packed into uint16's most significant bits first. For example, using a DeltaFormat of 2 (4-bit values), an array of values equal to {1, 2, 3, -1} would be represented by the DeltaValue 0x123F.

The DeltaValue array lists the number of pixels to adjust specified points on the glyph, or the entire glyph, at each ppem size in the targeted range. In the array, the first index position specifies the number of pixels to add or subtract from the coordinate at the smallest ppem size that needs correction, the second index position specifies the number of pixels to add or subtract from the coordinate at the next ppem size, and so on for each ppem size in the range.

Example 9 at the end of this chapter uses a Device table to define the minimum extent value for a math script.

Device table

Type

Name

Description

uint16

StartSize

Smallest size to correct

—in ppem

uint16

EndSize

Largest size to correct

—in ppem

uint16

DeltaFormat

Format of DeltaValue array data: 1, 2, or 3

uint16

DeltaValue[ ]

Array of compressed data