📄 cffspec.htm
字号:
<HTML>
<HEAD>
<TITLE>The Compact Font Format Specification</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="DIAGRAM" SRC="/TRUETYPE/OTSPEC/pixel.gif" BORDER=0></TD>
<TD><H1>Table Formats</H1></TD>
</TR>
<TR><TD></TD><TD ALIGN=TOP>
<FONT SIZE="+2"><P>
<STRONG>
Compact Font Format Specification<br>
Version 1.0<br>
07/31/96</STRONG><BR></p></font>
<H2>1. Introduction</H2>
<P>This document describes the specification of a font format that is suitable for
representing one or more single master, multiple master, synthetic, and CID
PostScript fonts compactly. Unlike previous PostScript font formats, CFF allows
multiple fonts to be stored together in a unit called a FontSet. Principal
space savings are a result of using a compact binary representation for most of
the information, sharing of common data between fonts, and defaulting
frequently occurring data.
<P>The design supports the embedding of PostScript code permitting additional
flexibility and extensibility of the format when used in printer environments.
<H2>2. Data Layout</H2>
<P>Conceptually the binary data is organized as a number of separate data
structures. The overall layout within the binary data is shown below. Since
some of these data structures are reached via offsets the ordering could be
changed although the first five occupy fixed locations.
<BLOCKQUOTE>
Header<BR>
Name INDEX<BR>
Top DICT INDEX<BR>
String INDEX<BR>
Global Subr INDEX<BR>
Encodings<BR>
Charsets<BR>
FDIndex (CIDFonts only<BR>
CharStrings INDEX (per-font<BR>
Font DICT INDEX (per-font, CIDFonts only)<BR>
Private DICT (per-font)<BR>
Local Subr INDEX (per-font)<BR>
Copyright and Trademark Notices<BR>
</BLOCKQUOTE>
<P>Appendix D shows an annotated example of a CFF font.
<H2>3. Data Types</H2>
<P>This section describes data representation and types used by the format.
<P>All multi-byte numeric data and offset fields are stored in big-endian byte
order (high byte low offset) and do NOT honor any alignment restrictions. This
leads to a format that is free from padding bytes.
<P>Data objects are often specified by byte offsets that are relative to some
reference point within the CFF data. These offsets are 1-4 bytes in length.
This document uses the convention of enclosing the reference point in
parentheses and uses a reference point of (0) to indicate an offset relative to
the start of the CFF data and (self) to indicate an offset relative to the data
structure containing the offset.
<P>The following table lists the data types used by the format:<BR>
<TABLE BGCOLOR="#F0F0F0" width=480 CELLPADDING=3>
<THEAD>
<TR>
<TH BGCOLOR="#C0C0C0">Name</TH><TH BGCOLOR="#C0C0C0">Range</TH><TH BGCOLOR="#C0C0C0">Description</TH>
</THEAD><TBODY></TR>
<TR>
<TD valign=top>Card8</TD><TD VALIGN=TOP>0-255</TD><TD VALIGN=TOP>1-byte unsigned number</TD></TR>
<TR>
<TD VALIGN=TOP>Card16</TD><TD VALIGN=TOP>0-65535</TD><TD VALIGN=TOP>2-byte unsigned number</TD></TR>
<TR>
<TD VALIGN=TOP>Offset</TD><TD VALIGN=TOP>varies</TD><TD VALIGN=TOP>1, 2, 3, or 4 byte offset (specified by OffSize field)</TD></TR>
<TR>
<TD VALIGN=TOP>OffSize</TD><TD VALIGN=TOP>1-4</TD><TD VALIGN=TOP>Specifies the size of an Offset field or fields</TD></TR>
<TR>
<TD VALIGN=TOP>SID</TD><TD VALIGN=TOP>0-65535</TD><TD VALIGN=TOP>2-byte string identifier
</TABLE>
<P>This document describes data structures by listing field types, names, and
descriptions. Data structures may be given a type name and subsequently
described. Arrays of objects are indicated by the usual square bracket
convention enclosing the array length.
<P>The majority of CFF data is contained by either of two data structures called
DICT and INDEX which are described in subsequent sections.
<H2>4. DICT Data</H2>
<P>PostScript dictionary data comprising key-value pairs is represented in a
compact tokenized format that is similar to that used to represent Type 1
charstrings. Dictionary keys are encoded as 1- or 2-byte operators and
dictionary values are encoded as variable-size numeric operands that represent
either integer or real values. An operator is preceded by the operand(s) that
specify its value. A DICT is simply a sequence of operand(s)/operator bytes
concatenated together.
<P>A number of integer operand types of varying sizes are defined and are encoded
as follows (first byte of operand is b0, second is b1, and so on)<BR>
<TABLE BGCOLOR="#F0F0F0" width=480 CELLPADDING=3>
<THEAD>
<TR>
<TH BGCOLOR="#C0C0C0">Size</TH><TH BGCOLOR="#C0C0C0">b0 range</TH><TH BGCOLOR="#C0C0C0">Value range</TH><TH BGCOLOR="#C0C0C0">Value calculation
</THEAD><TBODY></TR>
<TR>
<TD VALIGN=TOP>1</TD><TD VALIGN=TOP>32..246</TD><TD VALIGN=TOP>-107..+107</TD><TD VALIGN=TOP>b0 - 139</TD></TR>
<TR>
<TD VALIGN=TOP>2</TD><TD VALIGN=TOP>247..250</TD><TD VALIGN=TOP>+108..+1131</TD><TD VALIGN=TOP>(b0 - 247) * 256 + b1 + 108</TD></TR>
<TR>
<TD VALIGN=TOP>2</TD><TD VALIGN=TOP>251..254</TD><TD VALIGN=TOP>-1131..-108</TD><TD VALIGN=TOP>-(b0 - 251) * 256 - b1 - 108</TD></TR>
<TR>
<TD VALIGN=TOP>3</TD><TD VALIGN=TOP>28</TD><TD VALIGN=TOP>-32768..+32767</TD><TD VALIGN=TOP>b1<<8|b2</TD></TR>
<TR>
<TD VALIGN=TOP>5</TD><TD VALIGN=TOP>29</TD><TD VALIGN=TOP>-(2^31)..+(2^31-1)</TD><TD VALIGN=TOP>b1<<24|b2<<16|b3<<8|b4
</TABLE>
<P>[Note: the 1- and 2-byte integer formats are identical to those used by Type 1
charstrings.]
<P>Examples of the integer format as follows<BR>
<TABLE BGCOLOR="#F0F0F0" width=480 CELLPADDING=3>
<COLGROUP ALIGN=RIGHT>
<COLGROUP ALIGN=LEFT>
<THEAD>
<TR>
<TH BGCOLOR="#C0C0C0">Value</TH><TH BGCOLOR="#C0C0C0">Encoding
</THEAD><TBODY></TR>
<TR>
<TD VALIGN=TOP>0 </TD><TD VALIGN=TOP>8b</TD></TR>
<TR>
<TD VALIGN=TOP>100 </TD><TD VALIGN=TOP>ef</TD></TR>
<TR>
<TD VALIGN=TOP>-100 </TD><TD VALIGN=TOP>27</TD></TR>
<TR>
<TD VALIGN=TOP>1000 </TD><TD VALIGN=TOP>fa 7c</TD></TR>
<TR>
<TD VALIGN=TOP>-1000 </TD><TD VALIGN=TOP>fe 7c</TD></TR>
<TR>
<TD VALIGN=TOP>10000 </TD><TD VALIGN=TOP>1c 27 10</TD></TR>
<TR>
<TD VALIGN=TOP>-10000 </TD><TD VALIGN=TOP>1c d8 f0</TD></TR>
<TR>
<TD VALIGN=TOP>100000 </TD><TD VALIGN=TOP>1d 00 01 86 a0</TD></TR>
<TR>
<TD VALIGN=TOP>-100000 </TD><TD VALIGN=TOP>1d ff fe 79 60
</TABLE>
<P>A real number operand is provided in addition to integer operands. This operand
begins with a byte value of 30 followed by a variable-length sequence of
bytes. Each byte is composed of two 4-bit nibbles with the following
definitions<BR>
<TABLE BGCOLOR="#F0F0F0" width=480 CELLPADDING=3>
<THEAD>
<TR>
<TH BGCOLOR="#C0C0C0">Nibble</TH><TH BGCOLOR="#C0C0C0">Represents
</THEAD><TBODY></TR>
<TR>
<TD VALIGN=TOP>0 - 9 </TD><TD VALIGN=TOP>0 - 9</TD></TR>
<TR>
<TD VALIGN=TOP>a</TD><TD VALIGN=TOP>. (decimal point)</TD></TR>
<TR>
<TD VALIGN=TOP>b</TD><TD VALIGN=TOP>E</TD></TR>
<TR>
<TD VALIGN=TOP>c</TD><TD VALIGN=TOP>E-</TD></TR>
<TR>
<TD VALIGN=TOP>d</TD><TD VALIGN=TOP><reserved></TD></TR>
<TR>
<TD VALIGN=TOP>e</TD><TD VALIGN=TOP>- (minus)</TD></TR>
<TR>
<TD VALIGN=TOP>f</TD><TD VALIGN=TOP>end of number
</TABLE>
<P>A real number is terminated by one (or two) 0xf nibbles so that it is always
padded to a full byte. Thus, the value -2.25 is encoded by the byte sequence
(1e e2 a2 5f) and the value 0.140541E-3 by the sequence (1e 0a 14 05 41 c3 ff).
<P>An operator may have one or more operands that are characterized as follows<BR>
<TABLE BGCOLOR="#F0F0F0" width=480 CELLPADDING=3>
<THEAD>
<TR>
<TH BGCOLOR="#C0C0C0">Type</TH><TH BGCOLOR="#C0C0C0">Description
</THEAD><TBODY></TR>
<TR>
<TD VALIGN=TOP>number</TD><TD VALIGN=TOP>integer or real number</TD></TR>
<TR>
<TD VALIGN=TOP>boolean</TD><TD VALIGN=TOP>integer type with the values 0-false and 1-true</TD></TR>
<TR>
<TD VALIGN=TOP>SID</TD><TD VALIGN=TOP>string id (see section 10.)</TD></TR>
<TR>
<TD VALIGN=TOP>array</TD><TD VALIGN=TOP>one or more numbers</TD></TR>
<TR>
<TD VALIGN=TOP>delta</TD><TD VALIGN=TOP>a number or a delta-encoded array of numbers (see below)
</TABLE>
<P>The second and subsequent numbers in a delta are encoded as the difference
between successive values. For example, an array a0, a1, ..., an would be
encoded as: a0 (a1-a0) (a2-a1) ..., (an-a(n-1)).
<P>Two-byte operators have an initial escape byte of 12.
<P>Further compaction of dictionary data is achieved by establishing default
values for various DICT keys. For those keys that have a default value the
absence of the corresponding operator in a DICT implies a key should take its
default value.
<P>Multiple master fonts specify some of the operands via Type 2 font programs
that compute one or more operand values which are the subjected to the normal
operand interpretation described above. This method is invoked with the T2 (31)
operator and subsequent bytes specify a Type 2 program that terminates with the
endchar operator (see section 20 for a fuller description).
<H2>5. INDEX Data</H2>
<P>An INDEX is an array of variable-sized objects. It comprises a header, an
offset array, and object data. The offset array specifies offsets within the
object data. An object is retrieved by indexing the offset array and fetching
the object at the specified offset. The object's length can be determined by
subtracting its offset from the next offset in the offset array. An additional
offset is added at the end of the offset array so the length of the last object
may be determined.
<P>An INDEX has the following format<BR>
<TABLE BGCOLOR="#F0F0F0" width=480 CELLPADDING=3>
<THEAD>
<TR>
<TH BGCOLOR="#C0C0C0">Type</TH><TH BGCOLOR="#C0C0C0">Name</TH><TH BGCOLOR="#C0C0C0">Description
</THEAD><TBODY></TR>
<TR>
<TD VALIGN=TOP>Card16</TD><TD VALIGN=TOP>count</TD><TD VALIGN=TOP>Number of objects stored in INDEX</TD></TR>
<TR>
<TD VALIGN=TOP>OffSize</TD><TD VALIGN=TOP>offSize</TD><TD VALIGN=TOP>Offset array element size</TD></TR>
<TR>
<TD VALIGN=TOP>Offset</TD><TD VALIGN=TOP>offset[count+1]</TD><TD VALIGN=TOP>Offset array--from byte preceding object data</TD></TR>
<TR>
<TD VALIGN=TOP>Card8</TD><TD VALIGN=TOP>data[<varies>]</TD><TD VALIGN=TOP>Object data</TABLE>
<P>Offsets in the offset array are relative to the byte that precedes the object
data. Therefore the first element of the offset array is always 1. (This
ensures that every object has a corresponding offset which is always non-zero
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -