Table Organization

The GSUB table begins with a header that defines offsets to a ScriptList, a FeatureList, and a LookupList (see Figure 3g):

The ScriptList identifies all the scripts and language systems in the font that use glyph substitutes.

The FeatureList defines all the glyph substitution features required to render these scripts and language systems.

The LookupList contains all the lookup data needed to implement each glyph substitution feature.

For a detailed discussion of ScriptLists, FeatureLists, and LookupLists, see the chapter Common Table Formats.

Figure 3g. High-level organization of GSUB table

This organization helps text-processing clients to easily locate the features and lookups that apply to a particular script or language system. To access GSUB information, clients should use the following procedure:

Locate the current script in the GSUB ScriptList table.

If the language system is known, search the script for the correct LangSys table; otherwise, use the script's default language system (DefaultLangSys table).

The LangSys table provides index numbers into the GSUB FeatureList table to access a required feature and a number of additional features.

Inspect the FeatureTag of each feature, and select the features to apply to an input glyph string. Each feature provides an array of index numbers into the GSUB LookupList table.

Assemble all lookups from the set of chosen features, and apply the lookups in the order given in the LookupList table.

Lookup data is defined in one or more subtables that define the specific conditions, type, and results of a substitution action used to implement a feature. All subtables in a lookup must be of the same LookupType, as listed in the LookupType Enumeration table:

LookupType Enumeration table for glyph substitution

Value

Type

Description

1

Single

Replace one glyph with one glyph

2

Multiple

Replace one glyph with more than one glyph

3

Alternate

Replace one glyph with one of many glyphs

4

Ligature

Replace multiple glyphs with one glyph

5

Context

Replace one or more glyphs in context

6+

Reserved

For future use


Each LookupType subtable has one or more formats. The "best" format depends on the type of substitution and the resulting storage efficiency. When glyph information is best presented in more than one format, a single lookup may define more than one subtable, as long as all the subtables are for the same LookupType. For example, within a given lookup, a glyph index array format may best represent one set of target glyphs, whereas a glyph index range format may be better for another set.

A series of substitution operations on the same glyph or string requires multiple lookups, one for each separate action. Each lookup is given a different array number in the LookupList table and is applied in the LookupList order.

During text processing, a client applies a lookup to each glyph in the string, starting with the first glyph, before moving to the next lookup. To apply a lookup, the client searches the subtables in the order they are defined in the lookup. If the first subtable does not contain data relevant to the glyph, the client searches the next subtable, and so on. If the client finds glyph data, it makes the substitution.

A lookup is finished for a glyph when the client makes a substitution or when the client finds no relevant data in any of the subtables defined in the lookup. The client then advances to the next glyph in the glyph string and begins the lookup process again.

The rest of this chapter describes the GSUB header and the subtables defined for each GSUB LookupType. Examples at the end of this chapter illustrate each of the five LookupTypes, including the three formats available for contextual substitutions.