⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gsub.htm

📁 TrueType字库标准文档
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<P>Each context is defined in a SubClassRule table, and all SubClassRules that specify contexts beginning with the same class value are grouped in a SubClassSet table. Consequently, the SubClassSet containing a context identifies a context's first class component.

<P>Each SubClassSet table consists of a count of the SubClassRule tables defined in the SubClassSet (SubClassRuleCnt) and an array of offsets to SubClassRule tables (SubClassRule). The SubClassRule tables are ordered by preference in the SubClassRule array of the SubClassSet.

<BR>&nbsp;<BR><FONT SIZE=5>ContextSubstFormat2 subtable:<BR> Class-based context glyph substitution</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>uint16</TD><TD VALIGN=TOP>SubClassRuleCnt</TD><TD>Number of SubClassRule tables</TD></TR>
<TR><TD VALIGN=TOP>Offset</TD><TD VALIGN=TOP>SubClassRule<BR>[SubClassRuleCount]</TD><TD>Array of offsets to SubClassRule tables-from beginning of SubClassSet-ordered by preference</TD></TR>
</TABLE>&nbsp;&nbsp;&nbsp;&nbsp;
	
<P>For each context, a SubClassRule table contains a count of the glyph classes in the context sequence (GlyphCount), including the first class. A Class array lists the classes, beginning with the second class (array index = 1), that follow the first class in the context.

<BLOCKQUOTE>
<STRONG>Note:</STRONG> Text order depends on the writing direction of the text. For text written from right to left, the right-most class will be first. Conversely, for text written from left to right, the left-most class will be first.
</BLOCKQUOTE>

<P>The values specified in the Class array are the values defined in the ClassDef table. For example, a context consisting of the sequence &quot;Class 2, Class 7, Class 5, Class 0&quot; will produce a Class array of 7,5,0. The first class in the sequence, Class 2, is identified in the ContextSubstFormat2 table by the SubClassSet array index of the corresponding SubClassSet.

<P>A SubClassRule also contains a count of the substitutions to be performed on the context (SubstCount) and an array of SubstLookupRecords (SubstLookupRecord) that supply the substitution data. For each position in the context that requires a substitution, a SubstLookupRecord specifies a LookupList index and a position in the input glyph sequence where the lookup is applied. The SubstLookupRecord array lists SubstLookupRecords in design order-that is, the order in which lookups should be applied to the entire glyph sequence. 



<BR>&nbsp;<BR><FONT SIZE=5>SubClassRule table: Context definition for one class</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>uint16</TD><TD VALIGN=TOP>GlyphCount</TD><TD>Total number of classes specified for the context in the rule-includes the first class</TD></TR>
<TR><TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>SubstCount</TD><TD>Number of SubstLookupRecords</TD></TR>
<TR><TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>Class<BR>[GlyphCount - 1]</TD><TD>Array of classes-beginning with the second class-to be matched to the input glyph class sequence</TD></TR>
<TR><TD VALIGN=TOP>struct</TD><TD VALIGN=TOP>SubstLookupRecord<BR>[SubstCount]</TD><TD VALIGN=TOP>Array of Substitution lookups-in design order</TD></TR>
</TABLE>&nbsp;&nbsp;&nbsp;&nbsp;
	
<A HREF="#EX8"><P>Example 8</A> at the end of this chapter uses Format 2 to substitute Arabic mark glyphs for base glyphs of different heights.

<A NAME=CSF3><H4>Context Substitution Format 3</H4></A>

<P>Format 3, coverage-based context substitution, defines a context rule as a sequence of coverage tables. Each position in the sequence may define a different Coverage table for the set of glyphs that matches the context pattern. With Format 3, the glyph sets defined in the different Coverage tables may intersect, unlike Format 2 which specifies fixed class assignments (identical for each position in the context sequence) and exclusive classes (a glyph cannot be in more than one class at a time).

<P>For example, consider an input context that contains a lowercase glyph (position 0), followed by an uppercase glyph (position 1), either a lowercase or numeral glyph (position 2), and then either a lowercase or uppercase vowel (position 3). This context requires four Coverage tables, one for each position:
<UL>
<LI>In position 0, the Coverage table lists the set of lowercase glyphs. 
<LI>In position 1, the Coverage table lists the set of uppercase glyphs. 
<LI>In position 2, the Coverage table lists the set of lowercase and numeral glyphs, a superset of the glyphs defined in the Coverage table for position 0. 
<LI>In position 3, the Coverage table lists the set of lowercase and uppercase vowels, a subset of the glyphs defined in the Coverage tables for both positions 0 and 1. 
</UL>

<P>Unlike Formats 1 and 2, this format defines only one context rule at a time. It consists of a format identifier (SubstFormat), a count of the glyphs in the sequence to be matched (GlyphCount), and an array of Coverage offsets that describe the input context sequence (Coverage). 

<BLOCKQUOTE>Note: The order of the Coverage tables listed in the Coverage array must follow the writing direction. For text written from right to left, then the right-most glyph will be first. Conversely, for text written from left to right, the left-most glyph will be first. 
</BLOCKQUOTE>

<P>The subtable also contains a count of the substitutions to be performed on the input Coverage sequence (SubstCount) and an array of SubstLookupRecords (SubstLookupRecord) in design order-that is, the order in which lookups should be applied to the entire glyph sequence. (SubstLookupRecords are described next.)

<A HREF="#EX9"><P>Example 9</A> at the end of this chapter substitutes swash glyphs for two out of three glyphs in a sequence. 

<BR>&nbsp;<BR><FONT SIZE=5>ContextSubstFormat3 subtable: Coverage-based context glyph substitution</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>uint16</TD><TD VALIGN=TOP>SubstFormat</TD><TD>Format identifier-format = 3</TD></TR>
<TR><TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>GlyphCount</TD><TD>Number of glyphs in the input glyph sequence</TD></TR>
<TR><TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>SubstCount</TD><TD>Number of SubstLookupRecords</TD></TR>
<TR><TD VALIGN=TOP>Offset</TD><TD VALIGN=TOP>Coverage[GlyphCount]</TD><TD>Array of offsets to Coverage table-from beginning of Substitution table-in glyph sequence order</TD></TR>
<TR><TD VALIGN=TOP>struct</TD><TD VALIGN=TOP>SubstLookupRecord<BR>[SubstCount]</TD><TD VALIGN=TOP>Array of SubstLookupRecords-in design order</TD></TR>
</TABLE>&nbsp;&nbsp;&nbsp;&nbsp;
	
<H4>Substitution Lookup Record</H4>

<P>All contextual substitution subtables specify the substitution data in a Substitution Lookup Record (SubstLookupRecord). Each record contains a SequenceIndex, which indicates the position where the substitution will occur in the glyph sequence. In addition, a LookupListIndex identifies the lookup to be applied at the glyph position specified by the SequenceIndex.

<P>The contextual substitution subtables defined in Examples 7, 8, and 9 at the end of this chapter show SubstLookupRecords.



<BR>&nbsp;<BR><FONT SIZE=5>SubstLookupRecord</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>uint16</TD><TD VALIGN=TOP>SequenceIndex</TD><TD>Index into current glyph sequence-first glyph = 0</TD></TR>
<TR><TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>LookupListIndex</TD><TD>Lookup to apply to that position-zero-based</TD></TR>
</TABLE>&nbsp;&nbsp;&nbsp;&nbsp;
	
<P>The SequenceIndex in a SubstLookupRecord must take into consideration the order in which lookups are applied to the entire glyph sequence. Because multiple substitutions may occur per context, the SequenceIndex and LookupListIndex refer to the glyph sequence after the text-processing client has applied any previous lookups. In other words, the SequenceIndex identifies the location for the substitution at the time that the lookup is to be applied. 
For example, consider an input glyph sequence of four glyphs. The first glyph does not have a substitute, but the middle two glyphs will be replaced with a ligature, and a single glyph will replace the fourth glyph:

<UL>
<LI>The first glyph is in position 0. No lookups will be applied at position 0, so no SubstLookupRecord is defined. 
<LI>The SubstLookupRecord defined for the ligature substitution specifies the SequenceIndex as position 1, which is the position of the first-glyph component in the ligature string. After the ligature replaces the glyphs in positions 1 and 2, however, the input glyph sequence consists of only three glyphs, not the original four. 
<LI>To replace the last glyph in the sequence, the SubstLookupRecord defines the SequenceIndex as position 2 instead of position 3. This position reflects the effect of the ligature substitution applied before this single substitution. 
</UL>

<BLOCKQUOTE>
Note: This example assumes that the LookupList specifies the ligature substitution lookup before the single substitution lookup.
</BLOCKQUOTE>

<H4>GSUB Subtable Examples</H4>

<P>The rest of this chapter describes and illustrates examples of all the GSUB subtables, including each of the three formats available for contextual substitutions. All the examples reflect unique parameters described below, but the samples provide a useful reference for building subtables specific to other situations.

<P>All the examples have three columns showing hex data, source, and comments.

<A NAME=EX1><H4>Example 1: GSUB Header Table </H4></A>
<P>Example 1 shows a typical <A HREF="#HEADER">GSUB Header table</A> definition.


<BR>&nbsp;<BR><FONT SIZE=5>Example 1</FONT>

<TABLE BGCOLOR="#F0F0F0" WIDTH=480 BORDER=0 CELLPADDING=3>
<THEAD>
<TR><TH BGCOLOR="#C0C0C0">Hex Data</TH><TH BGCOLOR="#C0C0C0">Source</TH><TH BGCOLOR="#C0C0C0">Comments</TH></TR>
</THEAD>
<TBODY>
<TR><TD VALIGN=TOP>&nbsp;</TD><TD VALIGN=TOP><STRONG>GSUBHeader</STRONG><BR>TheGSUBHeader</TD><TD VALIGN=BOTTOM>GSUBHeader table definition</TD></TR>
<TR><TD VALIGN=TOP>00010000</TD><TD VALIGN=TOP>0x00010000</TD><TD>version</TD></TR>
<TR><TD VALIGN=TOP>000A</TD><TD VALIGN=TOP>TheScriptList</TD><TD>offset to ScriptList table</TD></TR>
<TR><TD VALIGN=TOP>001E</TD><TD VALIGN=TOP>TheFeatureList</TD><TD>offset to FeatureList table</TD></TR>
<TR><TD VALIGN=TOP>002C</TD><TD VALIGN=TOP>TheLookupList</TD><TD>offset to LookupList table</TD></TR>
</TABLE>&nbsp;&nbsp;&nbsp;&nbsp;

<A NAME=EX2><H4>Example 2: SingleSubstFormat1 Subtable</H4></A>
<P>Example 2 illustrates the <A HREF="#SSF1">SingleSubstFormat1 subtable</A>, which uses ranges to replace single input glyphs with their corresponding output glyphs. The indices of the output glyphs are calculated by adding a constant delta value to the indices of the input glyphs.
In this example, the Coverage table has a format identifier of 1 to indicate the range format, which is used because the input glyph indices are in consecutive order in the font. The Coverage table specifies one range that contains a StartGlyphID for the &quot;0&quot; (zero) glyph and an EndGlyphID for the &quot;9&quot; glyph.


<BR>&nbsp;<BR><FONT SIZE=5>Example 2</FONT>

<TABLE BGCOLOR="#F0F0F0" WIDTH=480 BORDER=0 CELLPADDING=3>
<THEAD>
<TR><TH BGCOLOR="#C0C0C0">Hex Data</TH><TH BGCOLOR="#C0C0C0">Source</TH><TH BGCOLOR="#C0C0C0">Comments</TH></TR>
</THEAD>
<TBODY>
<TR><TD VALIGN=TOP>&nbsp;</TD><TD VALIGN=TOP><STRONG>SingleSubstFormat1</STRONG><BR>LiningNumeralSubtable</TD><TD  VALIGN=BOTTOM>SingleSubst subtable definition</TD></TR>
<TR><TD VALIGN=TOP>0001</TD><TD VALIGN=TOP>1</TD><TD>SubstFormat, ranges</TD></TR>
<TR><TD VALIGN=TOP>0006</TD><TD VALIGN=TOP>LiningNumeralCoverage</TD><TD>offset to Coverage table for input glyphs</TD></TR>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -