gasp - Grid-fitting And Scan-conversion Procedure (OpenType 1.7)

This table contains information which describes the preferred rasterization techniques for the typeface when it is rendered on grayscale-capable devices. This table also has some use for monochrome devices, which may use the table to turn off hinting at very large or small sizes, to improve performance.

At very small sizes, the best appearance on grayscale devices can usually be achieved by rendering the glyphs in grayscale without using hints. At intermediate sizes, hinting and monochrome rendering will usually produce the best appearance. At large sizes, the combination of hinting and grayscale rendering will typically produce the best appearance.

If the 'gasp' table is not present in a typeface, the rasterizer may apply default rules to decide how to render the glyphs on grayscale devices.

The 'gasp' table consists of a header followed by groupings of 'gasp' records:

gasp Table

Type Name Description
USHORT version Version number (set to 1)
USHORT numRanges Number of records to follow
GASPRANGE gaspRange[numRanges] Sorted by ppem

Each GASPRANGE record looks like this:

Type Name Description
USHORT rangeMaxPPEM Upper limit of range, in PPEM
USHORT rangeGaspBehavior Flags describing desired rasterizer behavior.

There are four flags for the rangeGaspBehavior flags:

Flag Meaning
GASP_DOGRAY Use grayscale rendering
GASP_GRIDFIT Use gridfitting
GASP_SYMMETRIC_SMOOTHING Use smoothing along multiple axes with ClearType®
Only supported in version 1 gasp
GASP_SYMMETRIC_GRIDFIT Use gridfitting with ClearType symmetric smoothing
Only supported in version 1 gasp

The set of bit flags may be extended in the future. The first two bit flags operate independently of the following two bit flags. If font smoothing is enabled, then the first two bit flags are used. If ClearType is enabled, then the following two bit flags are used. The seven currently defined values of rangeGaspBehavior would have the following uses:

Flag Value Meaning
GASP_DOGRAY 0x0002 small sizes, typically ppem<9
GASP_GRIDFIT 0x0001 medium sizes, typically 9<=ppem<=16
GASP_DOGRAY|GASP_GRIDFIT 0x0003 large sizes, typically ppem>16
(neither) 0x0000 optional for very large sizes, typically ppem>2048
GASP_SYMMETRIC_GRIDFIT 0x0004 typically always enabled
GASP_SYMMETRIC_SMOOTHING 0x0008 larger screen sizes, typically ppem>15, most commonly used with the gridfit flag.
GASP_SYMMETRIC_SMOOTHING| GASP_SYMMETRIC_GRIDFIT 0x000C larger screen sizes, typically ppem>15
neither 0x0000 optional for very large sizes, typically ppem>2048

The records in the gaspRange[] array must be sorted in order of increasing rangeMaxPPEM value. The last record should use 0xFFFF as a sentinel value for rangeMaxPPEM and should describe the behavior desired at all sizes larger than the previous record’s upper limit. If the only entry in 'gasp' is the 0xFFFF sentinel value, the behavior described will be used for all sizes.

Sample 'gasp' table

Flag Value Font Smoothing Meaning ClearType with Symmetric Smoothing Meaning
version 0x0001  
numRanges 0x0004  
Range[0], Flag 0x0008
0x000A
ppem<=8, grayscale only ppem<=8, symmetric ClearType only
Range[1], Flag 0x0010
0x0005
9<=ppem<=16, gridfit only 9<=ppem<=16, symmetric gridfit only
Range[2], Flag 0x0013
0x0007
17<=ppem<=19, gridfit and grayscale 17<=ppem<=19, symmetric gridfit
Range[3], Flag 0xFFFF
0x000F
20<=ppem, gridfit and grayscale 20<=ppem, symmetric gridfit and symmetric smoothing