Scripts and Languages

Three tables and their associated records apply to scripts and languages: the Script List table (ScriptList) and its script record (ScriptRecord), the Script table and its language system record (LangSysRecord), and the Language System table (LangSys).

Script List Table and Script Record

TrueType Open fonts may contain one or more groups of glyphs used to render various scripts, which are enumerated in a ScriptList table. Both the GSUB and GPOS tables define Script List tables (ScriptList):

The GSUB table uses the ScriptList table to access the glyph substitution features that apply to a script. For details, see the chapter, The Glyph Substitution Table (GSUB).

The GPOS table uses the ScriptList table to access the glyph positioning features that apply to a script. For details, see the chapter, The Glyph Positioning Table (GPOS).

A ScriptList table consists of a count of the scripts represented by the glyphs in the font (ScriptCount) and an array of records (ScriptRecord), one for each script for which the font defines script-specific features (a script without script-specific features does not need a ScriptRecord).

The ScriptRecord array stores the records alphabetically by a ScriptTag that identifies the script. Each ScriptRecord consists of a ScriptTag and an offset to a Script table.

Example 1 at the end of this chapter shows a ScriptList table and ScriptRecords for a Japanese font that uses three scripts.

ScriptList table

Type

Name

Description

uint16

ScriptCount

Number of ScriptRecords

struct

ScriptRecord[ScriptCount]

Array of ScriptRecords

—listed alphabetically by ScriptTag


ScriptRecord

Type

Name

Description

Tag

ScriptTag

4-byte ScriptTag identifier

Offset

ð Script

Offset to Script table

—from beginning of ScriptList


Script Table and Language System Record

A Script table identifies each language system that defines how to use the glyphs in a script for a particular language. It also references a default language system that defines how to use the script's glyphs in the absence of language-specific knowledge.

A Script table begins with an offset to the Default Language System table (DefaultLangSys), which defines the set of features that regulate the default behavior of the script. Next, Language System Count (LangSysCount) defines the number of language systems (excluding the DefaultLangSys) that use the script. In addition, an array of Language System Records (LangSysRecord) defines each language system (excluding the default) with an identification tag (LangSysTag) and an offset to a Language System table (LangSys). The LangSysRecord array stores the records alphabetically by LangSysTag.

If no language-specific script behavior is defined, the LangSysCount is set to zero (0), and no LangSysRecords are allocated.

Script table

Type

Name

Description

Offset

ð DefaultLangSys

Offset to DefaultLangSys table

—from beginning of Script table

—may be NULL

uint16

LangSysCount

Number of LangSysRecords for this script

—excluding the DefaultLangSys

struct

LangSysRecord

Array of LangSysRecords

[LangSysCount]

—listed alphabetically by LangSysTag


LangSysRecord

Type

Name

Description

Tag

LangSysTag

4-byte LangSysTag identifier

Offset

ð LangSys

Offset to LangSys table

—from beginning of Script table


Language System Table

The Language System table (LangSys) identifies language-system features used to render the glyphs in a script. (The LookupOrder offset is reserved for future use.)

Optionally, a LangSys table may define a Required Feature Index (ReqFeatureIndex) to specify one feature as required within the context of a particular language system. For example, in the Cyrillic script, the Serbian language system always renders certain glyphs differently than the Russian language system.

Only one feature index value can be tagged as the ReqFeatureIndex. This is not a functional limitation, however, because the feature and lookup definitions in TrueType Open are structured so that one feature table can reference many glyph substitution and positioning lookups. When no required features are defined, then the ReqFeatureIndex is set to 0xFFFF.

All other features are optional. For each optional feature, a zero-based index value references a record (FeatureRecord) in the FeatureRecord array, which is stored in a Feature List table (FeatureList). The feature indices themselves (excluding the ReqFeatureIndex) are stored in arbitrary order in the FeatureIndex array. The FeatureCount specifies the total number of features listed in the FeatureIndex array.

Features are specified in full in the FeatureList table, FeatureRecord, and Feature table, which are described later in this chapter.

Example 2 at the end of this chapter shows a Script table, LangSysRecord, and LangSys table used for contextual positioning in the Arabic script.

LangSys table

Type

Name

Description

Offset

ð LookupOrder

= NULL (reserved for an offset to a reordering table)

uint16

ReqFeatureIndex

Index of a feature required for this language system

— if no required features = 0xFFFF

uint16

FeatureCount

Number of FeatureIndex values for this language system

—excludes the required feature

uint16

FeatureIndex

Array of indices into the FeatureList

[FeatureCount]

—in arbitrary order