Common Table Examples

The rest of this chapter describes and illustrates examples of all the common table formats. All the examples reflect unique parameters, but the samples provide a useful reference for building tables specific to other situations.

The examples have three columns showing hex data, source, and comments.

Example 1: ScriptList Table and ScriptRecords

Example 1 illustrates a ScriptList table and ScriptRecord definitions for a Japanese font with multiple scripts: Han Ideographic, Kana, and Latin. Each script has script-specific behavior.

Example 1

Hex Data

Source

Comments



0003



68616E69

0014

6B616E61

0018

6C61746E

001C

ScriptList
TheScriptList
3



"hani"

HanIScriptTable

"kana"

KanaScriptTable

"latn"

LatinScriptTable


;ScriptList table definition
;ScriptCount
;ScriptRecord[0]
; in alphabetical order by
; ScriptTag
;ScriptTag
; Han Ideographic script
;offset to Script table
;ScriptRecord[1]
;ScriptTag
; Hiragana and Katakana scripts
;offset to Script table
;ScriptRecord[2]
;ScriptTag
; Latin script
;offset to Script table


Example 2: Script Table, LangSysRecord, and LangSys Table

Example 2 illustrates the Script table, LangSysRecord, and LangSys table definitions for the Arabic script and the Urdu language system. The default LangSys table defines three default Arabic script features used to replace certain glyphs in words with their proper initial, medial, and final glyph forms. These contextual substitutions are invariant and occur in all language systems that use the Arabic script.

Many alternative glyphs in the Arabic script have language-specific uses. For instance, the Arabic, Farsi, and Urdu language systems use different glyphs for numerals. To maintain character-set compatibility, the Unicode standard includes separate character codes for the Arabic and Farsi numeral glyphs. However, the standard uses the same character codes for Farsi and Urdu numerals, even though three of the Urdu glyphs (4, 6, and 7) differ from the Farsi glyphs. To access and display the proper glyphs for the Urdu numerals, users of the text-processing client must enter the character codes for the Farsi numerals. Then the text-processing client uses a required TrueType Open glyph substitution feature, defined in the Urdu LangSys table, to access the correct Urdu glyphs for the 4, 6, and 7 numerals.

Note that the Urdu LangSys table repeats the default script features. This repetition is necessary because the Urdu language system also uses alternative glyphs in the initial, medial, and final glyph positions in words.

Example 2

Hex Data

Source

Comments

Script

ArabicScriptTable

;Script table definition

000A

DefLangSys

;offset to DefaultLangSys table

0001

1

;LangSysCount

;LangSysRecord[0]

; in alphabetical order by

; LangSysTag

55524420

"URD "

;LangSysTag

; Urdu language

0016

UrduLangSys

;offset to LangSys table for

; Urdu

LangSys

DefLangSys

;default LangSys table

; definition

0000

NULL

;LookupOrder

; reserved, null

FFFF

0xFFFF

;ReqFeatureIndex

; no required features

0003

3

;FeatureCount

0000

0

;FeatureIndex[0]

; in arbitrary order

; "init" feature (initial

; glyph)

0001

1

;FeatureIndex[1]

; "fina" feature (final glyph)

0002

2

;FeatureIndex[2]

; for "medi" feature (medial

; glyph)

LangSys

UrduLangSys

;LangSys table definition

0000

NULL

;LookupOrder

; reserved, null

0003

3

;ReqFeatureIndex

; numeral subsitution in Urdu

0003

3

;FeatureCount

0000

0

;FeatureIndex[0]

; in arbitrary order

; "init" feature (initial

; glyph)

0001

1

;FeatureIndex[1]

; "fina" feature (final glyph)

0002

2

;FeatureIndex[2]

; "medi" feature (medial glyph)


Example 3: FeatureList Table and Feature Table

Example 3 shows the FeatureList and Feature table definitions for ligatures in the Latin script. The FeatureList has three features, all optional and named "liga." One feature, also a default, implements ligatures in Latin if no language-specific feature specifies other ligatures. Two other features implement ligatures in the Turkish and German languages, respectively.

Three lookups define glyph substitutions for rendering ligatures in this font. The first lookup produces the "ffl," "fl," and "ff" ligatures; the second produces the "ffi" and "fi" ligatures; and the third produces the eszet ligature.

The ligatures that begin with an "f" are separated into two sets because Turkish has a dotless "i" glyph and so does not use "ffi" and "fi" ligatures. However, Turkish does use the "ffl," "fl," and "ff" ligatures, and the TurkishLigatures feature table lists this one lookup.

Only the German language system uses the eszet ligature, so the GermanLigatures feature table includes a lookup for rendering that ligature.

Because the Latin script can use both sets of ligatures, the DefaultLigatures feature table defines two LookupList indices: one for the "ffl," "fl," and "ff" ligatures, and one for the "ffi" and "fi" ligatures. If the text-processing client selects this feature, then the font applies both lookups.

Note that the TurkishLigatures and DefaultLigatures feature tables both list a LookupListIndex of zero (0) for the "ffl," "fl," and "ff" ligatures lookup. This is because language-specific lookups override all default language-system lookups, and a language-system feature table must explicitly list all lookups that apply to the language.

Example 3

Hex Data

Source

Comments

FeatureList

TheFeatureList

;FeatureList table definition

0003

3

;FeatureCount

;FeatureRecord[0]

6C696761

"liga"

;FeatureTag

0014

TurkishLigatures

;offset to Feature table

; FflFfFlLiga

;FeatureRecord[1]

6C696761

"liga"

;FeatureTag

001A

DefaultLigatures

;offset to Feature table

; FfiFiLiga, FflFfFlLiga

;FeatureRecord[2]

6C696761

"liga"

;FeatureTag

0022

GermanLigatures

;offset to Feature table

; EszetLiga

Feature

TurkishLigatures

;Feature table definition

0000

NULL

;FeatureParams

; reserved, null

0001

1

;LookupCount

0000

0

;LookupListIndex[0]

; ffl, fl, ff ligature

; substitution Lookup

Feature

DefaultLigatures

;Feature table definition

0000

NULL

;FeatureParams - reserved, null

0002

2

;LookupCount

0000

0

;LookupListIndex[0]

; in arbitrary order

; ffl, fl, ff ligatures

0001

1

;LookupListIndex[1]

; ffi, fi ligature substitution

; Lookup

Feature

GermanLigatures

;Feature table definition

0000

NULL

;FeatureParams - reserved, null

0001

3

;LookupCount

0000

0

;LookupListIndex[0]

; in arbitrary order

; ffl, fl, ff ligatures

0001

1

;LookupListIndex[1]

; ffi, fi ligature substitution

; Lookup

0002

2

;LookupListIndex[0]

; eszet ligature substitution

; Lookup


Example 4: LookupList Table and Lookup Table

A continuation of Example 3, Example 4 shows three ligature lookups in the LookupList table. The first generates the "ffl," "fl," and "ff" ligatures; the second produces the "ffi" and "fi" ligatures; and the third generates the eszet ligature. Each lookup table defines an offset to a subtable that contains data for the ligature substitution.

Example 4

Hex Data

Source

Comments

LookupList

TheLookupList

;LookupList table definition

0003

3

;LookupCount

0008

FflFlFfLookup

;offset to Lookup[0] table

; in design order

0010

FfiFiLookup

;offset to Lookup[1] table

0018

EszetLookup

;offset to Lookup[2] table

Lookup

FflFlFfLookup

;Lookup[0] table definition

0004

4

;LookupType

; ligature subst

000C

0x000C

;LookupFlag

; IgnoreLigatures, IgnoreMarks

0001

1

;SubTableCount

0018

FflFlFfSubtable

;offset to FflFlFf ligature

; substitution subtable

Lookup

FfiFiLookup

;Lookup[1] table definition

0004

4

;LookupType

; ligature subst

000C

0x000C

;LookupFlag

; IgnoreLigatures, IgnoreMarks

0001

1

;SubTableCount

0028

FfiFiSubtable

;offset to FfiFi ligature

; substitution subtable

Lookup

EszetLookup

;Lookup[2] table definition

0004

4

;LookupType

; ligature subst

000C

0x000C

;LookupFlag

; IgnoreLigatures, IgnoreMarks

0001

1

;SubTableCount

0038

EszetSubtable

;offset to Eszet ligature

; substitution subtable


Example 5: CoverageFormat1 Table (GlyphID List)

Example 5 illustrates a Coverage table that lists the GlyphIDs of all lowercase descender glyphs in a font. The table uses the list format instead of the range format because the GlyphIDs for the descender glyphs are not consecutively ordered.

Example 5

Hex Data

Source

Comments

CoverageFormat1

DescenderCoverage

;Coverage table definition

0001

1

;CoverageFormat

; lists

0005

5

;GlyphCount

0038

gGlyphID

;GlyphArray[0]

; in GlyphID order

003B

jGlyphID

;GlyphArray[1]

0041

pGlyphID

;GlyphArray[2]

0042

qGlyphID

;GlyphArray[3]

004A

yGlyphID

;GlyphArray[4]


Example 6: CoverageFormat2 Table (GlyphID Ranges)

Example 6 shows a Coverage table that defines ten numeral glyphs (0 through 9). The table uses the range format instead of the list format because the GlyphIDs are ordered consecutively in the font. The StartCoverageIndex of zero (0) indicates that the first GlyphID, for the zero glyph, returns a Coverage Index of 0. The second GlyphID, for the numeral one (1) glyph, returns a Coverage Index of 1, and so on.

Example 6

Hex Data

Source

Comments

CoverageFormat2

NumeralCoverage

;Coverage table definition

0002

2

;CoverageFormat

; GlyphID ranges

0001

1

;RangeCount

;RangeRecord[0]

004E

0glyphID

;Start GlyphID

0057

9glyphID

;End GlyphID

0000

0

;StartCoverageIndex

; first CoverageIndex = 0


Example 7: ClassDefFormat1 Table (Class Array)

The ClassDef table in Example 7 assigns class values to the lowercase glyphs in a font. The x-height glyphs are in Class 0, the ascender glyphs are in Class 1, and the descender glyphs are in Class 2. The array begins with the index for the lowercase "a" glyph.

Example 7

Hex Data

Source

Comments

ClassDefFormat1

LowercaseClassDef

;ClassDef table definition

0001

1

;ClassFormat

0032

aGlyphID

;StartGlyph

001A

26

;GlyphCount

0000

0

;aGlyph, Xheight Class 0

0001

1

;bGlyph, Ascender Class 1

0000

0

;cGlyph, Xheight Class 0

0001

1

;dGlyph, Ascender Class 1

0000

0

;eGlyph, Xheight Class 0

0001

1

;fGlyph, Ascender Class 1

0002

2

;gGlyph, Descender Class 2

0001

1

;hGlyph, Ascender Class 1

0000

0

;iGlyph, Ascender Class 1

0002

2

;jGlyph, Descender Class 2

0001

1

;kGlyph, Ascender Class 1

0001

1

;lGlyph, Ascender Class 1

0000

0

;mGlyph, Xheight Class 0

0000

0

;nGlyph, Xheight Class 0

0000

0

;oGlyph, Xheight Class 0

0002

2

;pGlyph, Descender Class 2

0002

2

;qGlyph, Descender Class 2

0000

0

;rGlyph, Xheight Class 0

0000

0

;sGlyph, Xheight Class 0

0001

1

;tGlyph, Ascender Class 1

0000

0

;uGlyph, Xheight Class 0

0000

0

;vGlyph, Xheight Class 0

0000

0

;wGlyph, Xheight Class 0

0000

0

;xGlyph, Xheight Class 0

0002

2

;yGlyph, Descender Class 2

0000

0

;zGlyph, Xheight Class 0


Example 8: ClassDefFormat2 Table (Class Ranges)

In Example 8, the ClassDef table assigns class values to four types of glyphs in the Arabic script: medium-height base glyphs, high base glyphs, very high base glyphs, and default mark glyphs. The table lists only Class 1, Class 2, and Class 3; all glyphs not explicitly assigned a class fall into Class 0.

The table uses the range format because the GlyphIDs in each class are ordered consecutively in the font. In the ClassRange array, ClassRange definitions are ordered by the Start glyph index in each range. The indices of the high base glyphs, defined in ClassRange[0], are first in the font and have a class value of 2. ClassRange[1] defines all the very high base glyphs and assigns a class value of 3. ClassRange[2] contains all default mark glyphs; the class value is 1. Class 0 consists of all the medium-height base glyphs, which are not explicitly assigned a class value.

Example 8

Hex Data

Source

Comments

ClassDefFormat2

GlyphHeightClassDef

;Class table definition

0002

2

;Class Format

; ranges

0003

3

;ClassRangeCount

;ClassRange[0]

; ordered by StartGlyphID

0030

tahGlyphID

;Start

; first GlyphID in the range

0031

dhahGlyphID

;End

; Last GlyphID in the range

0002

2

;Class

; high base glyphs

;ClassRange[1]

0040

cafGlyphID

;Start

;first GlyphID in the range

0041

gafGlyphID

;End

; Last GlyphID in the range

0003

3

;Class

; very high base glyphs

;ClassRange[2]

00D2

fathatanDefaultGlyphID

;Start

; first GlyphID in the range

00D3

dammatanDefaultGlyphID

;End

; Last GlyphID in the range

0001

1

;Class

; default marks


Example 9: Device Table

Example 9 defines the minimum extent value for a math script, using a Device table to adjust the value according to the size of the output font. Here, the Device table defines single-pixel adjustments for font sizes from 11 ppem to 15 ppem. The DeltaFormat is 1, which signifies a packed array of signed 2-bit values, eight values per uint16.

Example 9