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

📄 chapter2.htm

📁 TrueType字库标准文档
💻 HTM
📖 第 1 页 / 共 5 页
字号:

<P>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.

<P>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. 

<P>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.

<P>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.

<BR>&nbsp;<BR><FONT SIZE=5>LangSys table</FONT>
<TABLE BGCOLOR="#F0F0F0" WIDTH=530 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>Offset</TD><TD VALIGN=TOP>LookupOrder</TD><TD VALIGN=TOP>= NULL (reserved for an offset to a reordering table)</TD></TR>
<TR>	
<TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>ReqFeatureIndex</TD><TD VALIGN=TOP>Index of a feature required for this language system- if no required features = 0xFFFF</TD></TR>
<TR>	
<TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>FeatureCount</TD><TD VALIGN=TOP>Number of FeatureIndex values for this language system-excludes the required feature</TD></TR>
<TR>	
<TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>FeatureIndex[FeatureCount]</TD><TD VALIGN=TOP>Array of indices into the FeatureList-in arbitrary order</TD></TR>
</TABLE>
&nbsp;&nbsp;	

<H2>Features and Lookups</H2>

<P>Features define the functionality of a TrueType Open font and they are named to convey meaning to the text-processing client. Consider a feature named &quot;liga&quot; to create ligatures. Because of its name, the client knows what the feature does and can decide whether to apply it. A current list of TrueType Open registered features and their are listed in the TrueType Open Registry chapter at the end of this document. Font developers can use these features, as well as create their own.

<P>After choosing which features to use, the client assembles all lookups from the selected features. Multiple lookups may be needed to define the data required for different substitution and positioning actions, as well as to control the sequencing and effects of those actions.
 
<P>To implement features, a client applies the lookups in the order the lookup definitions occur in the LookupList. As a result, within the GSUB or GPOS table, lookups from several different features may be interleaved during text processing. A lookup is completed when the client locates a target glyph or glyph context and substitutes or positions a glyph. 

<P><STRONG>Note:</STRONG> The substitution (GSUB) lookups always occur before the positioning (GPOS) lookups. The lookup sequencing mechanism in TrueType relies on the font to determine the proper order of text-processing operations.

<P>Lookup data is defined in one or more subtables that contain information about specific glyphs and the operations to be performed on them. Each type of lookup has one or more corresponding subtable definitions. The choice of a subtable format depends upon two factors: the precise content of the information being applied to an operation, and the required storage efficiency. (For complete definitions of all lookup types and subtables, see the the GSUB and GPOS chapters of this document.)

<P>TrueType Open features define information that is specific to the layout of the glyphs in a font. They do not encode information that is constant within the conventions of a particular language or the typography of a particular script. Information that would be replicated across all fonts in a given language belongs in the text-processing application for that language, not in the fonts.

<H2>Feature List Table</H2>
<P>The headers of the GSUB and GPOS tables contain offsets to Feature List tables (FeatureList) that enumerate all the features in a font. Features in a particular FeatureList are not limited to any single script. A FeatureList contains the entire list of either the GSUB or GPOS features that are used to render the glyphs in all the scripts in the font.

<P>The FeatureList table enumerates features in an array of records (FeatureRecord) and specifies the total number of features (FeatureCount). Every feature must have a FeatureRecord, which consists of a FeatureTag that identifies the feature and an offset to a Feature table (described next). The FeatureRecord array is arranged alphabetically by FeatureTag names. 

<BLOCKQUOTE>
<STRONG>Note:</STRONG> The values stored in the FeatureIndex array of a LangSys table are used to locate records in the FeatureRecord array of a FeatureList table.
</BLOCKQUOTE>

<BR>&nbsp;<BR><FONT SIZE=5>FeatureList table</FONT>
<TABLE BGCOLOR="#F0F0F0" WIDTH=530 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>FeatureCount</TD><TD VALIGN=TOP>Number of FeatureRecords in this table</TD></TR>
<TR>	
<TD VALIGN=TOP>struct</TD><TD VALIGN=TOP>FeatureRecord[FeatureCount]</TD><TD VALIGN=TOP>Array of FeatureRecords-zero-based (first feature has FeatureIndex = 0)-listed alphabetically by FeatureTag</TD></TR>
</TABLE>
&nbsp;&nbsp;

<BR>&nbsp;<BR><FONT SIZE=5>FeatureRecord</FONT>
<TABLE BGCOLOR="#F0F0F0" WIDTH=530 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>Tag</TD><TD VALIGN=TOP>FeatureTag</TD><TD VALIGN=TOP>4-byte feature identification tag</TD></TR>
<TR>	
<TD VALIGN=TOP>Offset</TD><TD VALIGN=TOP>Feature</TD><TD VALIGN=TOP>Offset to Feature table-from beginning of FeatureList</TD></TR>
</TABLE>
&nbsp;&nbsp;
	
<H2>Feature Table</H2>

<P>A Feature table defines a feature with one or more lookups. The client uses the lookups to substitute or position glyphs. 

<P>Feature tables defined within the GSUB table contain references to glyph substitution lookups, and feature tables defined within the GPOS table contain references to glyph positioning lookups. If a text-processing operation requires both glyph substitution and positioning, then both the GSUB and GPOS tables must each define a Feature table, and the tables must use the same FeatureTags. 

<P>A Feature table consists of an offset to a Feature Parameters (FeatureParams) table (currently reserved for future use and set to NULL), a count of the lookups listed for the feature (LookupCount), and an arbitrarily ordered array of indices into a LookupList (LookupListIndex). The LookupList indices are references into an array of offsets to Lookup tables.

<P>To identify the features in a GSUB or GPOS table, a text-processing client reads the FeatureTag of each FeatureRecord referenced in a given LangSys table. Then the client selects the features it wants to implement and uses the LookupList to retrieve the Lookup indices of the chosen features. Next, the client arranges the indices in the LookupList order. Finally, the client applies the lookup data to substitute or position glyphs.

<P>Example 3 at the end of this chapter shows the FeatureList and Feature tables used to substitute ligatures in two languages.

<BR>&nbsp;<BR><FONT SIZE=5>Feature table</FONT>
<TABLE BGCOLOR="#F0F0F0" WIDTH=530 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>Offset</TD><TD VALIGN=TOP>FeatureParams</TD><TD VALIGN=TOP>= NULL (reserved for offset to FeatureParams)</TD></TR>
<TR>	
<TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>LookupCount</TD><TD VALIGN=TOP>Number of LookupList indices for this feature</TD></TR>
<TR>	
<TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>LookupListIndex<BR>[LookupCount]</TD><TD VALIGN=TOP>Array of LookupList indices for this feature -zero-based (first lookup is LookupListIndex = 0)</TD></TR>
</TABLE>
&nbsp;&nbsp;

	
<H2>Lookup List Table</H2>

<P>The headers of the GSUB and GPOS tables contain offsets to Lookup List tables (LookupList) for glyph substitution (GSUB table) and glyph positioning (GPOS table). The LookupList table contains an array of offsets to Lookup tables (Lookup). The font developer defines the Lookup sequence in the Lookup array to control the order in which a text-processing client applies lookup data to glyph substitution and positioning operations. LookupCount specifies the total number of Lookup table offsets in the array.

<P>Example 4 at the end of this chapter shows three ligature lookups in the LookupList table.

<BR>&nbsp;<BR><FONT SIZE=5>LookupList table</FONT>
<TABLE BGCOLOR="#F0F0F0" WIDTH=530 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>LookupCount</TD><TD VALIGN=TOP>Number of lookups in this table</TD></TR>
<TR>	
<TD VALIGN=TOP>Offset</TD><TD VALIGN=TOP>Lookup[LookupCount]</TD><TD VALIGN=TOP>Array of offsets to Lookup tables-from beginning of LookupList -zero based (first lookup is Lookup index = 0)</TD></TR>
</TABLE>
&nbsp;&nbsp;
	
<H2>Lookup Table</H2>

<P>A Lookup table (Lookup) defines the specific conditions, type, and results of a substitution or positioning action that is used to implement a feature. For example, a substitution operation requires a list of target glyph indices to be replaced, a list of replacement glyph indices, and a description of the type of substitution action.

<P>Each Lookup table may contain only one type of information (LookupType), determined by whether the lookup is part of a GSUB or GPOS table. GSUB supports five LookupTypes, and GPOS supports seven LookupTypes (for details about LookupTypes, see the GSUB and GPOS chapters of the document).
<P>Each LookupType is defined with one or more subtables, and each subtable definition provides a different representation format. The format is determined by the content of the information required for an operation and by required storage efficiency. When glyph information is best presented in more than one format, a single lookup may contain more than one subtable, as long as all the subtables are 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 of target glyphs.

<P>During text processing, a client applies a lookup to each glyph in the string before moving to the next lookup. Once the client finds a target glyph index or context in a subtable and substitutes or positions the glyph, the lookup is completed for that glyph.

<P>A Lookup table contains a LookupType, specified as an integer, that defines the type of information stored in the lookup. The LookupFlag specifies lookup qualifiers that assist a text-processing client in substituting or positioning glyphs. The SubTableCount specifies the total number of SubTables. The SubTable array specifies offsets, measured from the beginning of the Lookup table, to each SubTable enumerated in the SubTable array.

<BR>&nbsp;<BR><FONT SIZE=5>Lookup table</FONT>
<TABLE BGCOLOR="#F0F0F0" WIDTH=530 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>LookupType</TD><TD VALIGN=TOP>Different enumerations for GSUB and GPOS</TD></TR>
<TR>	
<TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>LookupFlag</TD><TD VALIGN=TOP>Lookup qualifiers</TD></TR>
<TR>	
<TD VALIGN=TOP>uint16</TD><TD VALIGN=TOP>SubTableCount</TD><TD VALIGN=TOP>Number of SubTables for this lookup</TD></TR>
<TR>	
<TD VALIGN=TOP>Offset</TD><TD VALIGN=TOP>SubTable<BR>[SubTableCount]</TD><TD VALIGN=TOP>Array of offsets to SubTables-from beginning of Lookup table
</TD></TR>
</TABLE>
&nbsp;&nbsp;	

<P>The LookupFlag uses four bits: 

<UL>
<LI>The first bit, RightToLeft, is set when the text is written from right to left. This bit defines the order in which lookups specify glyph sequences.
<LI>The next three bits-IgnoreBaseGlyphs, IgnoreLigatures, and IgnoreMarks-are set to specify additional instructions for applying a lookup to a glyph string. 
</UL>

<BR>&nbsp;<BR><FONT SIZE=5>LookupFlag bit enumeration</FONT>
<TABLE BGCOLOR="#F0F0F0" WIDTH=530 BORDER=0 CELLPADDING=3>
<THEAD>
<TR>
<TH BGCOLOR="#C0C0C0">Mask</TH><TH BGCOLOR="#C0C0C0">Name</TH><TH BGCOLOR="#C0C0C0">Description</TH></TR>
</THEAD><TBODY>
<TR>	
<TD VALIGN=TOP>0x0001</TD><TD VALIGN=TOP>RightToLeft</TD><TD VALIGN=TOP>If set, implied glyph order is right to left-otherwise, glyph order is left to right</TD></TR>
<TR>	
<TD VALIGN=TOP>0x0002</TD><TD VALIGN=TOP>IgnoreBaseGlyphs</TD><TD VALIGN=TOP>If set, skips over base glyphs</TD></TR>
<TR>	
<TD VALIGN=TOP>0x0004</TD><TD VALIGN=TOP>IgnoreLigatures</TD><TD VALIGN=TOP>If set, skips over ligatures</TD></TR>
<TR>	
<TD VALIGN=TOP>0x0008</TD><TD VALIGN=TOP>IgnoreMarks</TD><TD VALIGN=TOP>If set, skips over combining marks</TD></TR>
<TR>	
<TD VALIGN=TOP>0xFFF0</TD><TD VALIGN=TOP>Reserved</TD><TD VALIGN=TOP>For future use</TD></TR>
</TABLE>
&nbsp;&nbsp;
	
<P>For example, in Arabic text, a character string might have the pattern &lt;base character - mark character - base character&gt;. That string could be converted into a ligature composed of two components, one for each base character, with the combining mark glyph over the first component. To produce this ligature, the font developer would set the IgnoreMarks bit to tell the client to ignore the mark, substitute the ligature glyph first, and then position the mark glyph over the ligature. Alternatively, a lookup which did not set the IgnoreMarks bit could be used to describe a three-component ligature glyph, composed of the first base glyph, the mark glyph, and the second base glyph.

<H2>Coverage Table</H2>

Each subtable in a lookup references a Coverage table (Coverage), which specifies all the glyphs affected by a substitution or positioning operation described in the subtable. The GSUB, GPOS, and GDEF tables rely on this notion of coverage. If a glyph does not appear in a Coverage table, the client can skip that subtable and move immediately to the next subtable.

<P>A Coverage table identifies glyphs by glyph indices (GlyphIDs) either of two ways:

<UL>
<LI>As a list of individual glyph indices in the glyph set.
<LI>As ranges of consecutive indices. The range format gives a number of start-glyph and end-glyph index pairs to denote the consecutive glyphs covered by the table. 

⌨️ 快捷键说明

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