📄 gsub.htm
字号:
<HTML>
<HEAD>
<TITLE>The 'GSUB' Table</TITLE>
<STYLE>
<!--
BODY {background: #FFFFFF; link: #000080}
H1 {font-size: 24pt; color: #c60029}
H3 {font-size: 18pt; color: black}
H4 {font-size: 16pt; color: black}
H4 {font-size: 14pt; color: black}
CAPTION {font-size: 16pt; font-weight: Bold}
A:link {text-decoration: none}
-->
</STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000080">
<TABLE WIDTH=480 CELLPADDING=8 CELLSPACING=0 BORDER=0>
<TR><TD><IMG WIDTH=100 HEIGHT=1 ALT="" SRC="/truetype/otspec/pixel.gif" BORDER=0></TD>
<TD><H1>Table Formats</H1></TD>
</TR>
<TR><TD></TD><TD ALIGN=TOP>
<H2>The Glyph Substitution Table (GSUB)</H2>
<P>The Glyph Substitution table (GSUB) contains information for substituting glyphs to render the scripts and language systems supported in a font. Many language systems require glyph substitutes. For example, in the Arabic script, the glyph shape that depicts a particular character varies according to its position in a word or text string (see figure 1). In other language systems, glyph substitutes are aesthetic options for the user, such as the use of ligature glyphs in the English language (see Figure 2).<BR>
<IMG WIDTH=254 HEIGHT=61 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/fig3a.gif"><BR>
<STRONG>Figure 1. Isolated, initial, medial, and final forms of the Arabic character HAH</STRONG><BR>
<IMG WIDTH=201 HEIGHT=59 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/fig3b.gif"><BR>
<STRONG>Figure 2. Two Latin glyphs and their associated ligature</STRONG>
<H4>Overview</H4>
<P>Many fonts use limited character encoding standards that map glyphs to characters one-to-one, assigning a glyph to each character code value in a font. Multiple character codes cannot be mapped to a single glyph, as needed for ligature glyphs, and multiple glyphs cannot be mapped to a single character code, as needed to decompose a ligature into its component glyphs.
<P>To supply glyph substitutes, font developers must assign different character codes to the glyphs, or they must create additional fonts or character sets. To access these glyphs, users must bear the burden of switching between character codes, character sets, or fonts.
<H4>Substituting Glyphs with TrueType Open</H4>
<P>The GSUB table in TrueType Open fully supports glyph substitution. To access glyph substitutes, GSUB maps from the glyph index or indices defined in a cmap table to the glyph index or indices of the glyph substitutes. For example, if a font has three alternative forms of an ampersand glyph, the cmap table associates the ampersand's character code with only one of these glyphs. In GSUB, the indices of the other ampersand glyphs are then referenced by this one index.
<P>The text-processing client uses the GSUB data to manage glyph substitution actions. GSUB identifies the glyphs that are input to and output from each glyph substitution action, specifies how and where the client uses glyph substitutes, and regulates the order of glyph substitution operations. Any number of substitutions can be defined for each script or language system represented in a font.
<P>The GSUB table supports five types of glyph substitutions that are widely used in international typography:
<UL>
<LI>A <CITE>single substitution</CITE> replaces a single glyph with another single glyph. This is used to render positional glyph variants in Arabic and vertical text in the Far East (see Figure 3).<BR>
<IMG WIDTH=240 HEIGHT=88 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/fig3c.gif"><BR>
<STRONG>Figure 3. Alternative forms of parentheses used when positioning Kanji vertically</STRONG>
<LI>A <CITE>multiple substitution</CITE> replaces a single glyph with more than one glyph. This is used to specify actions such as ligature decomposition (see Figure 4).<BR>
<IMG WIDTH=144 HEIGHT=52 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/fig3d.gif"><BR>
<STRONG>Figure 4. Decomposing a Latin ligature glyph into its individual glyph components</STRONG>
<LI>An <CITE>alternate substitution</CITE> identifies functionally equivalent but different looking forms of a glyph. These glyphs are often referred to as aesthetic alternatives. For example, a font might have five different glyphs for the ampersand symbol, but one would have a default glyph index in the cmap table. The client could use the default glyph or substitute any of the four alternatives (see Figure 5).<BR>
<IMG WIDTH=246 HEIGHT=49 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/fig3e.gif"><BR>
<STRONG>Figure 5. Alternative ampersand glyphs in a font</STRONG>
<LI>A <CITE>ligature substitution</CITE> replaces several glyph indices with a single glyph index, as when an Arabic ligature glyph replaces a string of separate glyphs (see Figure 6).<BR>
<IMG WIDTH=277 HEIGHT=68 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/fig3f.gif"><BR>
<STRONG>Figure 6. Three Arabic glyphs and their associated ligature glyph</STRONG>
<LI><STRONG>Contextual substitution,</STRONG> the most powerful type, describes glyph substitutions in context-that is, a substitution of one or more glyphs within a certain pattern of glyphs. Each substitution describes one or more input glyph sequences and one or more substitutions to be performed on that sequence. Contextual substitutions can be applied to specific glyph sequences, glyph classes, or sets of glyphs.
</UL>
<H4>Table Organization</H4>
The GSUB table begins with a header that defines offsets to a ScriptList, a FeatureList, and a LookupList (see Figure 3g):
<UL>
<LI>The ScriptList identifies all the scripts and language systems in the font that use glyph substitutes.
<LI>The FeatureList defines all the glyph substitution features required to render these scripts and language systems.
<LI>The LookupList contains all the lookup data needed to implement each glyph substitution feature.
</UL>
<P>For a detailed discussion of ScriptLists, FeatureLists, and LookupLists, see the chapter Common Table Formats.<BR>
<IMG WIDTH=555 HEIGHT=475 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/fig3g.gif"><BR>
<STRONG>Figure 7. High-level organization of GSUB table</STRONG>
<P>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:
<OL>
<LI>Locate the current script in the GSUB ScriptList table.
<LI>If the language system is known, search the script for the correct LangSys table; otherwise, use the script's default language system (DefaultLangSys table).
<LI>The LangSys table provides index numbers into the GSUB FeatureList table to access a required feature and a number of additional features.
<LI>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.
<LI>Assemble all lookups from the set of chosen features, and apply the lookups in the order given in the LookupList table.
</OL>
<P>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:
<BR> <BR><FONT SIZE=5>LookupType Enumeration table for glyph substitution</FONT>
<TABLE BGCOLOR="#F0F0F0" WIDTH=480 BORDER=0 CELLPADDING=3>
<THEAD>
<TR><TH BGCOLOR="#C0C0C0">Value</TH><TH BGCOLOR="#C0C0C0">Type</TH><TH BGCOLOR="#C0C0C0">Description</TH></TR>
</THEAD>
<TBODY>
<TR><TD VALIGN=TOP>1</TD><TD VALIGN=TOP>Single</TD><TD>Replace one glyph with one glyph</TD></TR>
<TR><TD VALIGN=TOP>2</TD><TD VALIGN=TOP>Multiple</TD><TD>Replace one glyph with more than one glyph</TD></TR>
<TR><TD VALIGN=TOP>3</TD><TD VALIGN=TOP>Alternate</TD><TD>Replace one glyph with one of many glyphs</TD></TR>
<TR><TD VALIGN=TOP>4</TD><TD VALIGN=TOP>Ligature</TD><TD>Replace multiple glyphs with one glyph</TD></TR>
<TR><TD VALIGN=TOP>5</TD><TD VALIGN=TOP>Context</TD><TD>Replace one or more glyphs in context</TD></TR>
<TR><TD VALIGN=TOP>6+</TD><TD VALIGN=TOP>Reserved</TD><TD>For future use</TD></TR>
</TABLE>
<P>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.
<P>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.
<P>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.
<P>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.
<P>The rest of this chapter describes the GSUB header and the subtables defined for each GSUB LookupType. Examples at the end of this page illustrate each of the five LookupTypes, including the three formats available for contextual substitutions.
<A NAME=HEADER><H4>GSUB Header</H4></A>
<P>The GSUB table begins with a header that contains a version number for the table (Version) and offsets to a three tables: ScriptList, FeatureList, and LookupList. For descriptions of each of these tables, see the chapter, Common Table Formats.
<A HREF="#EX1">Example 1</A> at the end of this chapter shows a GSUB Header table definition.
<BR> <BR><FONT SIZE=5>GSUB Header</FONT>
<TABLE BGCOLOR="#F0F0F0" WIDTH=480 BORDER=0 CELLPADDING=3>
<THEAD>
<TR><TH BGCOLOR="#C0C0C0">Type</TH><TH BGCOLOR="#C0C0C0">Name</TH><TH BGCOLOR="#C0C0C0">Description</TH></TR>
</THEAD>
<TBODY>
<TR><TD VALIGN=TOP>fixed32</TD><TD VALIGN=TOP>Version</TD><TD>Version of the GSUB table-initially set to 0x00010000</TD></TR>
<TR><TD VALIGN=TOP>Offset</TD><TD VALIGN=TOP>ScriptList</TD><TD>Offset to ScriptList table-from beginning of GSUB table</TD></TR>
<TR><TD VALIGN=TOP>Offset</TD><TD VALIGN=TOP>FeatureList</TD><TD>Offset to FeatureList table-from beginning of GSUB table</TD></TR>
<TR><TD VALIGN=TOP>Offset</TD><TD VALIGN=TOP>LookupList</TD><TD>Offset to LookupList table-from beginning of GSUB table</TD></TR>
</TABLE>
<H4>LookupType 1:<BR>
Single Substitution Subtable</H4>
<P>Single substitution (SingleSubst) subtables tell a client to replace a single glyph with another glyph. The subtables can be either of two formats. Both formats require two distinct sets of glyph indices: one that defines input glyphs (specified in the Coverage table), and one that defines the output glyphs. Format 1 requires less space than Format 2, but it is less flexible.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -