📄 kern.htm
字号:
<HTML>
<HEAD>
<TITLE>The 'kern' Table</TITLE>
<STYLE>
<!--
BODY {background: #FFFFFF; link: #000080}
H1 {font-size: 24pt; color: #c60029}
H2 {font-size: 18pt; color: black}
H3 {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>kern- Kerning</H2>
<P>
The kerning table contains the values that
control the intercharacter spacing for the glyphs in a font. There
is currently no system level support for kerning (other than returning
the kern pairs and kern values).
<P>
Each subtable varies in format, and can contain information for
vertical or horizontal text, and can contain kerning values or
minimum values. Kerning values are used to adjust inter-character
spacing, and minimum values are used to limit the amount of adjustment
that the scaler applies by the combination of kerning and tracking.
Because the adjustments are additive, the order of the subtables
containing kerning values is not important. However, tables containing
minimum values should usually be placed last, so that they can
be used to limit the total effect of other subtables.
<P>
The kerning table in the TrueType font file has a header, which
contains the format number and the number of subtables present,
and the subtables themselves.
<TABLE WIDTH=480 BGCOLOR="#F0F0F0">
<THEAD>
<TR><TH BGCOLOR="#C0C0C0">Type</TH><TH BGCOLOR="#C0C0C0">Field</TH>
<TH BGCOLOR="#C0C0C0">Description</TH></TR></THEAD>
<TBODY>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>version</TD>
<TD VALIGN=TOP>Table version number (starts at 0)</TD></TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>nTables</TD>
<TD VALIGN=TOP>Number of subtables in the kerning table.</TD></TR>
</TABLE> <P>
<P>
Kerning subtables will share the same header
format. This header is used to identify the format of the subtable
and the kind of information it contains:
<TABLE WIDTH=480 BGCOLOR="#F0F0F0">
<THEAD>
<TR><TH BGCOLOR="#C0C0C0">Type</TH>
<TH BGCOLOR="#C0C0C0">Field</TH><TH BGCOLOR="#C0C0C0">Description</TH></TR></THEAD>
<TBODY>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>version</TD>
<TD VALIGN=TOP>Kern subtable version number</TD></TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>length</TD>
<TD VALIGN=TOP>Length of the subtable, in bytes (including this header).
</TD></TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>coverage</TD>
<TD VALIGN=TOP>What type of information is contained in this table.</TD></TR>
</TABLE> <P>
<BR><BR>
The coverage field is divided into the following
sub-fields, with sizes given in bits:
<TABLE WIDTH=480 BGCOLOR="#F0F0F0">
<THEAD>
<TR>
<TH BGCOLOR="#C0C0C0">Sub-field</TH>
<TH BGCOLOR="#C0C0C0" NOWRAP=NOWRAP>Bits #'s</TH>
<TH BGCOLOR="#C0C0C0">Size</TH>
<TH BGCOLOR="#C0C0C0">Description</TH></TR>
</THEAD><TBODY>
<TR>
<TD VALIGN=TOP>horizontal</TD><TD VALIGN=TOP><CENTER>0</CENTER></TD>
<TD VALIGN=TOP><CENTER>1</CENTER></TD><TD VALIGN=TOP>1 if table has horizontal data, 0 if vertical.</TD></TR>
<TR><TD VALIGN=TOP>minimum</TD><TD VALIGN=TOP><CENTER>1</CENTER></TD>
<TD VALIGN=TOP><CENTER>1</CENTER></TD><TD VALIGN=TOP>If this bit is set to 1, the table has minimum values. If set to 0, the table has kerning values.</TD></TR>
<TR><TD VALIGN=TOP>cross-stream</TD>
<TD VALIGN=TOP><CENTER>2</CENTER></TD><TD VALIGN=TOP><CENTER>1</CENTER></TD>
<TD VALIGN=TOP>If set to 1, kerning is perpendicular to the flow of the text.
<BR><BR>
If the text is normally written horizontally, kerning will be done in the up and down directions. If kerning values are positive, the text will be kerned upwards; if they are negative, the text will be kerned downwards.<BR><BR>
If the text is normally written vertically, kerning will be done in the left and right directions. If kerning values are positive, the text will be kerned to the right; if they are negative, the text will be kerned to the left. <BR><BR>
The value 0x8000 in the kerning data resets the cross-stream kerning back to 0.</TD>
</TR>
<TR><TD VALIGN=TOP>override</TD><TD VALIGN=TOP><CENTER>3</CENTER></TD>
<TD VALIGN=TOP><CENTER>1</CENTER></TD><TD VALIGN=TOP>If this bit is set to 1 the value in this table should replace the value currently being accumulated.</TD></TR>
<TR><TD VALIGN=TOP>reserved1</TD><TD VALIGN=TOP><CENTER>4-7</CENTER></TD>
<TD VALIGN=TOP><CENTER>4</CENTER></TD><TD VALIGN=TOP>Reserved. This should be set to zero.</TD></TR>
<TR><TD VALIGN=TOP>format</TD><TD VALIGN=TOP><CENTER>8-15</CENTER></TD>
<TD VALIGN=TOP><CENTER>8</CENTER></TD><TD VALIGN=TOP>Format of the subtable. Only formats 0 and 2 have been defined. Formats 1 and 3 through 255 are reserved for future use.</TD></TR>
</TABLE> <P>
<P><BR><H4>Format 0</H4>
<P>
This is the only format that will be properly interpreted by Windows
and OS/2.
<P>
This subtable is a sorted list of kerning pairs and values. The
list is preceded by information which makes it possible to make
an efficient binary search of the list:
<TABLE WIDTH=480 BGCOLOR="#F0F0F0">
<THEAD>
<TR><TH BGCOLOR="#C0C0C0">Type</TH><TH BGCOLOR="#C0C0C0">Field</TH><TH BGCOLOR="#C0C0C0">Description</TH></TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>nPairs</TD>
<TD VALIGN=TOP>This gives the number of kerning pairs in the table.</TD></TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>searchRange</TD>
<TD VALIGN=TOP>The largest power of two less than or equal to the value of nPairs, multiplied by the size in bytes of an entry in the table.</TD></TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>entrySelector</TD>
<TD VALIGN=TOP>This is calculated as log2 of the largest power of two less than or equal to the value of nPairs. This value indicates how many iterations of the search loop will have to be made. (For example, in a list of eight items, there would have to be three iterations of the loop).</TD></TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>rangeShift</TD>
<TD VALIGN=TOP>The value of nPairs minus the largest power of two less than or equal to nPairs, and then multiplied by the size in bytes of an entry in the table.</TD></TR>
</TABLE> <P>
<P>
This is followed by the list of kerning pairs
and values. Each has the following format:
<TABLE WIDTH=480 BGCOLOR="#F0F0F0">
<THEAD>
<TR>
<TH BGCOLOR="#C0C0C0">Type</TH>
<TH BGCOLOR="#C0C0C0">Field</TH>
<TH BGCOLOR="#C0C0C0">Description</TH></TR>
</THEAD><TBODY>
<TR>
<TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>left</TD>
<TD VALIGN=TOP>The glyph index for the left-hand glyph in the kerning pair.</TD>
</TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>right</TD>
<TD VALIGN=TOP>The glyph index for the right-hand glyph in the kerning pair.
</TD></TR>
<TR><TD VALIGN=TOP>FWORD</TD><TD VALIGN=TOP>value</TD>
<TD VALIGN=TOP>The kerning value for the above pair, in FUnits. If this value is greater than zero, the characters will be moved apart. If this value is less than zero, the character will be moved closer together.</TD></TR>
</TABLE> <P>
<P>
The left and right halves of the kerning pair
make an unsigned 32-bit number, which is then used to order the
kerning pairs numerically.
<P>
A binary search is most efficiently coded if the search range
is a power of two. The search range can be reduced by half by
shifting instead of dividing. In general, the number of kerning
pairs, nPairs, will not be a power of two. The value of the search
range, searchRange, should be the largest power of two less than
or equal to nPairs. The number of pairs not covered by searchRange
(that is, nPairs - searchRange) is the value rangeShift.
<P>
Windows v3.1 does not make use of the 'kern' data other than to
expose it to applications through the GetFontData() API.Format 2
<P><BR><H4>Format 2</H4>
<P>
This subtable is a two-dimensional array of
kerning values. The glyphs are mapped to classes, using a different
mapping for left- and right-hand glyphs. This allows glyphs that
have similar right- or left-side shapes to be handled together.
Each similar right- or left-hand shape is said to be single class.
<P>
Each row in the kerning array represents one left-hand glyph class,
each column represents one right-hand glyph class, and each cell
contains a kerning value. Row and column 0 always represent glyphs
that do not kern and contain all zeros.
<P>
The values in the right class table are stored pre-multiplied
by the number of bytes in a single kerning value, and the values
in the left class table are stored pre-multiplied by the number
of bytes in one row. This eliminates needing to multiply the row
and column values together to determine the location of the kerning
value. The array can be indexed by doing the right- and left-hand
class mappings, adding the class values to the address of the
array, and fetching the kerning value to which the new address
points.
<P>
The header for the simple array has the following format:
<TABLE WIDTH=480 BGCOLOR="#F0F0F0">
<THEAD>
<TR>
<TH BGCOLOR="#C0C0C0">Type</TH>
<TH BGCOLOR="#C0C0C0">Field</TH>
<TH BGCOLOR="#C0C0C0">Description</TH></TR>
</THEAD><TBODY>
<TR>
<TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>rowWidth</TD>
<TD VALIGN=TOP>The width, in bytes, of a row in the table.</TD>
</TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>leftClassTable</TD>
<TD VALIGN=TOP>Offset from beginning of this subtable to left-hand class table.</TD>
</TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>rightClassTable</TD>
<TD VALIGN=TOP>Offset from beginning of this subtable to right-hand class table.
</TD></TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>array</TD>
<TD VALIGN=TOP>Offset from beginning of this subtable to the start of the kerning array.
</TD></TR>
</TABLE> <P>
<P>
Each class table has the following header:
<TABLE WIDTH=480 BGCOLOR="#F0F0F0">
<THEAD>
<TR>
<TH BGCOLOR="#C0C0C0">Type</TH>
<TH BGCOLOR="#C0C0C0">Field</TH>
<TH BGCOLOR="#C0C0C0">Description</TH></TR>
</THEAD><TBODY>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>firstGlyph</TD>
<TD VALIGN=TOP>First glyph in class range.</TD></TR>
<TR><TD VALIGN=TOP>USHORT</TD><TD VALIGN=TOP>nGlyphs</TD>
<TD VALIGN=TOP>Number of glyph in class range.</TD></TR>
</TABLE> <P>
<P>
This header is followed by nGlyphs number
of class values, which are in USHORT format. Entries for glyphs
that don't participate in kerning should point to the row or column
at position zero.
<P>
The array itself is a left by right array of kerning values, which
are FWords, where left is the number of left-hand classes and
R is the number of right-hand classes. The array is stored by
row.
<P>
Note that this format is the quickest to process since each lookup
requires only a few index operations. The table can be quite large
since it will contain the number of cells equal to the product
of the number of right-hand classes and the number of left-hand
classes, even though many of these classes do not kern with each
other.
<br> <br>
<FONT FACE="Arial, Helvetica" SIZE=1>
Microsoft Typography Web Site <A HREF="/truetype/otspec/CPYRIGHT.htm">© 1996 Microsoft Corporation</A>
<BR>
Comments to the Microsoft Typography group: <A HREF="mailto:ttwsite@microsoft.com">ttwsite@microsoft.com</A>
<BR>
<A HREF="/truetype/default.htm">Home</a> | <a href="/truetype/creators.htm">Information for Developers</a>
<BR>
Last updated 05 September 1996
</FONT>
</TD>
</TABLE>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -