Apparatus and method for generating textual lines layouts5416898Abstract A computer system for rendering text is provided. A keyboard is used to enter characters into the computer system. A character code corresponding to each entered character is generated. A particular font is chosen from a font table stored in memory. The font table contains a number of different fonts, with each font having a number of glyph indexes corresponding to a number of different glyphs. A character can have a plurality of different glyph indexes for a particular font. A processor maps the character code to a glyph index according to the selected font and later processes the glyph index. The glyph corresponding to the processed glyph index is then displayed. Claims What is claimed is: Description FIELD OF THE INVENTION
______________________________________
Type Name Description
______________________________________
uint16
unitSize Size of a lookup unit for this search.
uint16
nUnits Number of units of the preceding size to
be searched.
uint16
searchRange
The unitSize times the largest power of
two that is less than or equal to nUnits.
uint16
entrySelector
The log base 2 of the largest power of
two less than or equal to nUnits.
uint16
rangeShift The unitSize times the difference of
nUnits minus the largest power of two
less than or equal to nUnits.
______________________________________
In order to speed up the process of searching even more, a threshold value determines when the binary search should be abandoned and simple serial searching should take over. In order to make sure that this process works most efficiently, it is important to remember to include a special "end of search table" unit after all other units. The value associated with this unit should be 0.times.FFFF. The presence of this special value allows the search logic to be as fast as possible, at a fairly minimal cost in extra space in the font table. Lookup tables Lookup tables provide a way of taking a given glyph index and looking up some information. Some lookup tables involve groupings, allowing many different glyph indices to be treated the same (that is, to look up the same information for them). Others just do a simple array-type lookup given the glyph index. Lookup tables come in five different formats, each with a format number:
______________________________________
Lookup Table Format
Description
______________________________________
0 Simple Array Format. The lookup data is
just an array of 16-bit lookup values,
indexed by glyph index.
2 Segment Single Format. A segment is
defined as a contiguous range of glyph
indices. In this format, each non-
overlapping segment has a single lookup
value which is applicable to all glyphs in
the segment. (Segment mappings are
described below)
4 Segment Array Format. A segment
mapping is performed (as with the
previous format), but instead of a single
lookup result for all the glyphs in the
segment, the lookup result is itself an
array whose base is the starting glyph
index of the segment.
6 Single Table Format. The lookup data is a
sorted list of <glyph index, lookup
result> pairs.
8 Trimmed Array Format. The lookup data
is a simple trimmed array indexed by
glyph index. (Trimmed arrays are
described below)
______________________________________
Given the above format values, the top-level description of a LookupTable is as follows:
______________________________________
Type Name Description
______________________________________
uint16 format Format of this lookup table (one of the
above values).
(variable)
fsHeader Format-specific header (each of these is
described below), followed by the actual
lookup data.
______________________________________
For a format 0 lookup table, the fsHeader is simply an array of 16-bit lookup values. For a format 2 or 4 lookup table, the fsHeader is described as follows:
______________________________________
Type Name Description
______________________________________
BinSrchHeader
binSrchHeader
The units for this binary search
are LookupSegments, which
will always have a minimum
length of 6 (see below for their
format).
LookupSegment
segments[] The actual segments. These
must be in sorted order, based
on the first word in each one
(that is, by the last glyph in
each segment).
______________________________________
A LookupSegment is defined as follows:
______________________________________
Type Name Description
______________________________________
uint16 lastGlyph Last glyph index in this segment.
uint16 firstGlyph First glyph index in this segment.
uint16 value[] The lookup value.
______________________________________
For a format 2 lookup table, the value is applied uniformly to all glyphs in the segment. For a format 4 lookup table, the value will be a single uint16, which is an offset from the start of the lookup table to an array of values; this array is indexed into by taking the given glyph index and subtracting the firstGlyph value (i.e. it is a trimmed array starting at firstGlyph). For a format 6 lookup table, the fsHeader is described as follows:
______________________________________
Type Name Description
______________________________________
BinSrchHeader
binSrchHeader
The units for this binary
search are LookupSingles,
which will always have a
minimum length of 4 (see
below for their format).
LookupSingle
entries[] The actual entries, sorted by
glyph index.
______________________________________
A LookupSingle is defined as follows:
______________________________________
Type Name Description
______________________________________
uint16 glyph The glyph index.
uint16 value[] The lookup value (of arbitrary size).
______________________________________
For a format 8 lookup table, the fsHeader is defined as follows:
______________________________________
Type Name Description
______________________________________
uint16
firstGlyph First glyph index included in the trimmed
array.
uint16
glyphCount Total number of glyphs (will be last glyph
minus firstGlyph plus one).
uint16
valueArray[]
The lookup values (indexed by glyph
index - firstGlyph).
______________________________________
State Tables A state table describes tables used by the finite state machine. It specifies the class mapping, the state array, and the set of actions. The finite state machine reads these tables and applies them to the glyph array. A state table starts with a state table header defined as follows:
______________________________________
Type Name Description
______________________________________
uint16
stateSize Size of a state, in bytes (limited to 8 bits; the
size is 16 bits for alignment purposes).
uint16
classTable
Byte offset from beginning of the state table
to the class table.
uint16
stateArray
Byte offset from beginning of the state table
to the state array.
uint16
entryTable
Byte offset from beginning of the state table
to the entry table.
______________________________________
The class table maps a glyph index into a class. A class is a collection of glyphs which have some property in common. Examples of classes might be arithmetic digits, letters which form a ligature with a preceding "f", and characters which separate words. The mapping is done using a trimmed array to map a range of glyph indices into eight bit class codes:
______________________________________
Type Name Description
______________________________________
uint16
firstGlyph Glyph index of the first glyph in the class
table.
uint16
nGlyphs Number of glyphs in class table.
uint8 classArray[]
The class codes (indexed by glyph index -
firstGlyph).
______________________________________
Class codes are in the range [0 . . . stateSize -1]. Class code 0 is end of text, and should not appear in the class array. Class code 1 is out of bounds; all glyph indices which are less than firstGlyph, or greater than or equal to firstGlyph+nGlyphs will be assigned class code 1. Class code 1 may also appear in the class array. Class code 2 is deleted; sometimes contextual processing will remove a glyph from the glyph array by changing its glyph index to the deleted glyph index, 0.times.FFFF. This glyph code is automatically assigned class deleted, which should not appear in the class array. All other class codes can be assigned. To limit the size of the class table, fonts should be designed so that glyphs which will be processed by a given state table have glyph indices which are in a small range. A state is an array of eight bit entry indices:
______________________________________
Type Name Description
______________________________________
uint8 entry[stateSize]
Index into entry table. (indexed by class
code).
______________________________________
The state array is just an array of states. The first entry in the state array is the initial state. The values in the entry table have the following format:
______________________________________
Type Name Description
______________________________________
uint16
newState Byte offset from beginning of state table
to the new state.
uint16
flags table-specific flags.
uintl6
glyphOffsets[]
Optional offsets to per-glyph tables. See
below.
______________________________________
The newState value is stored as a byte offset for quick access: the address of the entry table index is the sum of the state table address, the newState, and the class code. This means that the maximum number of states will depend on stateSize and the offset of the state array from the beginning of the state table. The contents of the flag field is table specific. See the definitions of the `mort`, `just` and `kern` tables for details. Some actions optionally compute a value by using a glyph index as an index into a per-glyph table. The tables only contain entries for those glyphs which will be used to index into the table. The offset is a signed word offset from the beginning of the state table to where the entry for glyph index 0 would be if it was in the table. This allows the address of a particular entry to be computed as: (glyph index+offset)*2+state table address Notice that this means that the offset can be either negative or positive, depending on the smallest glyph index in the table, and where the table starts relative to the beginning of the state table. State table headers are imbedded in other tables. The class table, state array, and entry tables should follow the imbedding table's header, and can be in any order. The class and entry tables must be word aligned. Any per-glyph tables will follow these and must be word aligned. The Baseline Table--tag `bsln` The baseline table contains information that identifies various baseline positions with respect to the font's fundamental (i.e. em-square) baseline, as well as which glyphs normally take these baselines. For example, a Roman font can contain information about where the drop caps baseline for its glyphs is located. The Baseline Table can also designate default baseline behavior for sets of glyphs. The currently preferred embodiment of the present invention uses the information provided in this table in two ways. First, automatic baseline adjustment to a common line baseline is performed by looking up the baseline class for each glyph, and then adjusting that glyph's position (if needed) to the common baseline. Then client-supplied information is used to specify the position of each baseline in the overall line. For more information on how baselines are manipulated see the documentation on the Line Layout Manager. The following baseline values are defined (a total of 32 different values; this number is referred to in the following documentation as numberOfBaselineClasses):
______________________________________
Baseline value
Description
______________________________________
0 Roman baseline. This defines the alignment used
in most Roman-script languages, where most of
the character is above the baseline, with portions
possibly below it. The baseline appears near the
bottom of the entire line.
1 Ideographic centered baseline. This defines the
behavior used by Chinese, Japanese and Korean
ideographic scripts, which center themselves
halfway through the line height.
2 Ideographic low baseline. This also defines
behavior used in Chinese, Japanese and Korean,
like the previous value, but with the glyphs
lowered slightly so that ideographs that appear
adjacent to Roman characters appear to descend
slightly below the Roman baseline.
3 Hanging baseline. This defines the alignment
used in Devanagari and derived scripts, where
most of the bulk of the glyphs are below the
baseline, with some portions possibly above it,
and where the baseline itself appears near the
top of the line. This value is also used for drop
capitals.
4 Math baseline. This defines the alignment used
for setting mathematics, where operators like the
minus sign need to be centered. It will usually
be set at half the x-height in a font.
5 through 15
These are currently unassigned horizontal
baselines.
16 Centered vertical baseline. This is for vertical
text that is centered on the vertical baseline.
17 OffsetVerticalBaseline. This is for vertical text
that is not centered on the vertical baseline. An
example of this might be Mongolian.
18 through 31
These are currently unassigned vertical
baselines.
______________________________________
Baseline tables can have one of the following formats:
______________________________________
Table Format
Description
______________________________________
0 Distance-based, no mapping. For this kind of table,
shifts are specified in pure FUnit distance units. A
single default baseline is designated for all glyphs
in the font, so there is no mapping table associated
with this format.
1 Distance-based, with mapping. This is the same as
format 0 with the addition of a mapping table,
which allows different glyphs in the font to have
different designated "natural" baselines (glyphs not
covered by the mapping table will get the default
baseline mentioned above).
2 Control point-based, no mapping. For this kind of
table, a particular glyph in the font is designated as
having a set of control points that, after hinting,
will be used to define the baseline positions. As
with format 0, a single default baseline value is
designated for all glyphs in the font, so there is no
mapping table associated with this format.
3 Control point-based, with mapping. This is the
same as format 2 with the addition of the mapping
table; other comments are as for format 1.
______________________________________
Associated with each of these formats is a structure that contains its formatspecific data. For a format 0 table, its format-specific part is called a Format0Part, and has the following format:
______________________________________
Type Name Description
______________________________________
uint16
deltas[]
These are the 32 deltas from the font's intrinsic
(em-square) baseline to the 32 different
baseline classes. See illustration below.
______________________________________
For a format 1 table, the format-specific part is called a Format1Part, and has the following format:
______________________________________
Type Name Description
______________________________________
uint16 deltas[] These are the 32 deltas from the
font's intrinsic (em-square) baseline
to the 32 different baseline classes.
See illustration below.
LookupTable
mappingData
Lookup table (any format) mapping
glyphs to their intrinsic baseline
classes. Any glyphs not covered by
the lookup table will be assigned a
default baseline class.
______________________________________
For a format 2 table, the format-specific part is called a Format2Part, and has the following format:
______________________________________
Type Name Description
______________________________________
uint16
stdGlyph Glyph index of the glyph in this font to be
used to set the baseline values. This glyph
must contain a set of control points (whose
numbers are contained in the following
field) that will, possibly after hinting, be
used to determine baseline distances.
uint16
ctlPoints[]
Array of 32 control point numbers. These
are associated with the stdGlyph. A value of
0xFFFF means there is no corresponding
control point in the stdGlyph.
______________________________________
For a format 3 table, the format-specific part is called a Format3Part, and has the following format:
______________________________________
Type Name Description
______________________________________
uint16 stdGlyph Glyph index of the glyph in this
font to be used to set the baseline
values. This glyph must contain a
set of control points (whose
numbers are contained in the
following field) that will, possibly
after hinting, be used to determine
baseline distances.
uint16 ctlPoints[]
Array of 32 control point numbers.
These are associated with the
stdGlyph. A value of 0xFFFF
means there is no corresponding
control point in the stdGlyph.
LookupTable
mappingData
Lookup table (any format) mapping
glyphs to their intrinsic baseline
classes. Any glyphs not covered by
the lookup table will be assigned a
default baseline class.
______________________________________
Given these format-specific parts, then, the top-level structure of the baseline table is as follows:
______________________________________
Type Name Description
______________________________________
fixed version Version number of the baseline
table (0x00010000 for the initial
version).
uint16 format Format of the baseline table (as per
above values)
uint16 defaultBaseline
Default baseline value to be used
for all glyphs (formats 0 and 2), or
in the absence of mapping data for
a particular glyph (formats 1 and
3).
(Variable)
parts Format-specific data. This will be
either a Format0Part, a
Format1Part, a Format2Part or
a Format3Part, as defined above.
______________________________________
Shown below is an example to illustrate how this all works; for the purposes of this example, we'll consider the distance format. Consider the following outline `D` in a Roman font: ##SPC1## We see here the `D` sitting in the em-square, and the natural baseline here is at y=0 in font coordinates. By doing this, in the absence of layout, different sizes of this glyph will render with this line in common-that is, the pen will always rest on this line. In the following diagram, the designation of two baselines: Roman and hanging are added. The Roman baseline in fact is the same as the font's natural baseline, so its delta would be zero. The hanging baseline is above the natural baseline by some distance; its delta would therefore be a positive number (on the order of 1500 FUnits, perhaps). ##SPC2## This delta information is used during line layout to first bring all the glyphs in the line to a common baseline, and then moving them to a final location, as shown in the following diagram: ##SPC3## Example of a baseline table (non-control point) As an example, a baseline table for a font containing mixed kanji and Roman letters is created. The goal is to give all the Roman letters the Roman baseline value, and all the kanji the ideographic centered baseline value. For purposes of this illustration, assume that the Roman glyphs occupy glyph indices 2 through 270, and the kanji occupy glyph indices 271 through 8200. Furthermore, assume the intrinsic baseline the kanji have is Roman-style (that is, the glyphs sit on the bottom of the em-square). Included is a shift amount of 855 FUnits to align the two. In addition, assume that the cap height for the Roman letters is 1520 (i.e., the hanging baseline distance). A sample table is given below:
______________________________________
Offset/length
Value Comment
______________________________________
0/4 0x00010000
Version number (1.0 in fixed-point
format).
4/2 1 Table format of 1 means this is a
distance table with an associated
lookup table.
6/2 1 The default baseline is the
ideographic centered baseline. By
specifying this value, we need only
include non-kanji glyphs in the
lookup table.
(The Format1Part starts here)
8/2 0 Delta from natural baseline to Roman
baseline is zero.
10/2 855 Delta from natural baseline to
ideographic centered baseline.
12/2 0 Don't bother with ideographic low
baseline.
14/2 1520 Delta from natural baseline to
hanging baseline.
16/56 0 Don't bother including the other
baselines.
(Second part of Format1Part is the lookup table)
72/2 2 Lookup table format 2 (segment
single table format).
(The next five fields are the BinSrchHeader)
74/2 6 Size of a LookupSegment (2 bytes for
the starting glyph index, 2 bytes for
the ending glyph index, and 2 bytes
for the baseline value).
76/2 1 Number of entries in the table.
78/2 6 Search range.
80/2 0 Entry selector.
82/2 0 Range shift.
(The LookupSegment entries start here)
84/2 270 Ending glyph index for kanji.
86/2 2 Starting glyph index for kanji.
88/2 0 Baseline value for glyphs in this
range (i.e. kanji).
90/2 0xFFFF Special value always needed at the
end of segment lookup tables.
92/2 0xFFFF Starting glyph is same as the special
value.
94/2 0 Doesn't matter what this value is.
______________________________________
Example of a baseline table (control point) This example uses the same basic setup as the previous one, with the addition of control point information for more accurate placement of baseline shifts. Glyph 22 is designated as the glyph containing the control point information. That glyph has control point #80 at the Roman baseline, control point #81 at the ideographic centered baseline, and control point #82 at the hanging baseline.
______________________________________
Offset/length
Value Comment
______________________________________
0/4 0x00010000
Version number (1.0 in fixed-point
format).
4/2 3 Table format of 3 means this is a
distance table with an associated
lookup table.
6/2 1 As in the previous example, we're
designating the default baseline to be
ideographic centered.
(The Format3Part starts here)
8/2 22 Glyph index of the glyph containing
the control point info (we'll call this
"the standard glyph" below).
10/2 80 Control point for Roman baseline in
the standard glyph.
12/2 81 Control point for ideographic
centered baseline in the standard
glyph.
14/2 0xFFFF Special value meaning no control
point for this baseline class.
16/2 82 Control point for hanging baseline
in the standard glyph.
18/56 0xFFFF Special value meaning no control
points for these baseline classes.
(Last section of Format3Part is the lookup table)
74/2 2 Lookup table format 2 (segment
single table format).
(The next five fields are the BinSrchHeader)
76/2 6 Size of a LookupSegment (2 bytes for
the starting glyph index, 2 bytes for
the ending glyph index, and 2 bytes
for the baseline value).
78/2 1 Number of entries in the table.
80/2 6 Search range.
82/2 0 Entry selector.
84/2 0 Range shift.
(The LookupSegment entries start here)
86/2 270 Ending glyph index for kanji.
88/2 2 Starting glyph index for kanji.
90/2 0 Baseline value for glyphs in this
range (i.e. kanji).
92/2 0xFFFF Special value always needed at the
end of segment lookup tables.
94/2 0xFFFF Starting glyph is same as the special
value.
96/2 0 Doesn't matter what this value is.
______________________________________
The Ligature Caret Table--tag `lcar` The Ligature Caret Table is used to identify natural division points inside ligatures. These division points are used to allow the illusion of full editing of text, even inside a ligature. Using this data, the currently preferred embodiment of the present invention permits the user to select only the `i` portion of an `fi` ligature, for example, even though the `fi` itself is just a single glyph. A ligature caret table has one of the following formats:
______________________________________
Table Format
Description
______________________________________
0 Linear. In this format the value(s) associated with
a glyph are single FUnit values, representing
positions along the baseline through which the
subdivisions are made orthogonally to the baseline.
1 Control point. This format is similar to format 0,
but instead of the splits being made at specified
distances expressed in FUnits, they are made at the
hinted location of a specified control point. Only
one of the coordinates for this point will be used
(the x-coordinate for horizontal metrics, or the y-
coordinate for vertical metrics).
______________________________________
The overall structure of the ligature caret table is as follows:
______________________________________
Type Name Description
______________________________________
fixed version Version number of the ligature caret
table (0x00010000 for the initial
version).
uint16 format Format of the ligature caret table (one
of the above values).
(variable)
lookup data
Lookup table mapping glyphs to uint16
offsets from the start of the ligature
caret table to the LigCaretClassEntry
value for the specified glyph.
______________________________________
The LigCaretClassEntry structure (whose offset is contained in the single lookup entry in the lookup table) has the following structure:
______________________________________
Type Name Description
______________________________________
uint16
count Number of int16s that follow.
int16 partials[count]
Single values, representing either FUnit
distances for format 0 tables, or control
point numbers for format 1 tables.
______________________________________
Example of a ligature caret table (non-control point) Suppose that the ligature caret data for the `fi` and `fl` ligatures in a Roman font is to be included. First, let the glyph index for `fi` be 192, and the FUnit distance into the `fi` for the split be 556. Similarly, given that the glyph index for `fl` is 193, its FUnit distance is 561. The table would look thusly:
______________________________________
Offset/length
Value Comment
______________________________________
0/4 0x00010000
Version number (1.0 in fixed format).
4/2 0 Table format of 0 means this is a
linear table.
(The lookup data starts here)
6/2 6 Lookup table format 6 (single table
format).
8/2 4 Size of a LookupSingle (2 bytes for
the glyph index, and 2 bytes for the
offset from the start of this ligature
caret table).
10/2 2 Number of entries in the table.
12/2 8 Search range (see section on lookup
tables, above).
14/2 1 Entry selector (see section on lookup
tables, above).
16/2 0 Range shift.
(The LookupSingle entries start here)
18/2 192 Glyphcode for `fi`.
20/2 30 Offset to LigCaretClassEntry for `fi`.
22/2 193 Glyphcode for `fi`.
24/2 34 Offset to LigCaretClassEntry for `fi`.
26/2 0xFFFF Special end value (see discussion in
lookup table section)
28/2 0 Special end value
(The LigCaretClassEntries start here)
30/2 1 `fi` only has 1 internal ligature caret
place.
32/2 556 The FUnit offset.
34/2 1 `fi` only has 1 internal ligature caret
place.
36/2 561 The FUnit offset.
______________________________________
The Optical Bounds Table--tag `opbd` The Optical Bounds table contains information identifying the optical edges of glyphs. This information is used to make the edges of lines of text line up in a more visually pleasing way (note that this information is never used within a line, but only at the edges of a line). For each glyph for which there is optical edge information, there are four numbers in this table, specifying deltas to the left, top, right and bottom optical edges. These deltas are the amounts by which the glyph should be moved in order to align its optical edge. The sign conventions are the same as the sign conventions for the font's coordinate system. For example, a left side delta of -50 FUnits associated with, say, an upper-case `C` would mean that for those lines that start with that uppercase `C`, the glyph is to be shifted by 50 FUnits to the left. One of the formats of this table permits the specification of optical edges via control points instead of FUnit values. In this case, the control point itself designates the position within the glyph that is to be aligned with the edge of the line of text. Optical bounds tables may have one of these formats:
______________________________________
Table Format
Description
______________________________________
0 Distance. In this format the values associated with
a glyph are in FUnits.
1 Control point. In this format the locations of the
glyph's optical edges are specified by control
points. In this format, specify the special value -1
to indicate that no optical edge control point is
specified for a given edge.
______________________________________
The overall structure of the optical bounds table is as follows:
______________________________________
Type Name Description
______________________________________
fixed version Version number of the optical bounds
table (0x00010000 for the initial
version).
uint16 format Format of the optical bounds table (one
of the above values).
(variable)
lookup data
Lookup table mapping glyphs to uint16
offsets from the start of the Optical
Bounds table to record containing the 4
int16 values (interpreted as distances or
control points, depending on the table
format).
______________________________________
Example of an optical bounds table (distance format) An example of a Roman font for which is provided optical edge data for rounded letters is described. Included are optical data for two glyphs, `O` (glyph index 10 for this font) and `A` (glyph index 43). Note that this same approach can be extended to a plurality of glyphs. Included is a top-side amount for the `A`, since its visual appeal for vertical text as well as horizontal is desired.
______________________________________
Offset/length
Value Comment
______________________________________
0/4 0x00010000
Version number (1.0 in fixed format).
4/2 0 Table format of 0 means this is a
distance table.
(The lookup data starts here)
6/2 6 Lookup table format 6 (single table
format).
8/2 4 Size of a LookupSingle (2 bytes for
the glyph index, and 2 bytes for the
offset).
10/2 2 Number of entries in the table.
12/2 8 Search range (see section on lookup
tables, above).
14/2 1 Entry selector (see section on lookup
tables, above).
16/2 0 Range shift.
(The LookupSingle entries start here)
18/2 10 Glyphcode for `O`.
20/2 30 Offset to bounds for `O`.
22/2 43 Glyphcode for `A`.
24/2 38 Offset to bounds for `A`.
26/2 0xFFFF Special format 6 lookup table end
value
28/2 0 This is just an empty offset
corresponding to the special table
end value.
30/2 -50 Left-side delta.
32/2 0 Top-side delta.
34/2 55 Right-side delta.
36/2 0 Bottom-side delta.
38/2 -10 Left-side delta.
40/2 15 Top-side delta (remember positive is
up in the font's coordinate system).
42/2 0 Right-side delta.
44/2 0 Bottom-side delta.
______________________________________
Example of an optical bounds table (control point format) Assuming that the same two glyphs are to be included as in the previous example, this example specifies the optical positions via control points rather than via actual distances. Note the special value of "-1" which means that no optical information is included for the given side.
______________________________________
Offset/length
Value Comment
______________________________________
0/4 0x00010000
Version number (1.0 in fixed format).
4/2 1 Table format of 1 means this is a
control point table.
(The lookup data starts here)
6/2 6 Lookup table format 6 (single table
format).
8/2 4 Size of a LookupSingle (2 bytes for
the glyph index, and 2 bytes for the 4
control point values).
10/2 2 Number of entries in the table.
12/2 8 Search range (see section on lookup
tables, above).
14/2 1 Entry selector (see section on lookup
tables, above).
16/2 0 Range shift.
(The LookupSingle entries start here)
18/2 10 Glyphcode for `O`.
20/2 30 Offset to bounds for `O`.
22/2 43 Glyphcode for `A`.
24/2 38 Offset to bounds for `A`.
26/2 0xFFFF Special format 6 lookup table end
value
28/2 0 This is just an empty offset
corresponding to the special table
end value.
30/2 36 Control point controlling left-side
optical edge.
32/2 -1 No top-side optical effects for the `O`.
34/2 37 Control point controlling right-side
optical edge.
36/2 -1 No bottom-side optical effects for the
`O`.
38/2 32 Control point controlling left-side
optical edge.
40/2 41 Control point controlling top-side
optical edge.
42/2 -1 No right-side optical effects for the
`A`.
44/2 -1 No bottom-side optical effects for the
`A`.
______________________________________
The Glyph Properties Table--tag `prop` The Glyph Properties table contains different properties associated with each glyph in a font. An example of a property is "this glyph can hang off the left/top edge of a line." A single property value is a 16-bit quantity comprising different bits for different properties. These bits are defined as follows:
______________________________________
Mask value
Interpretation
______________________________________
0x8000 The glyph is a floater (i.e. floating accent, vowel
mark, etc.)
0x4000 The glyph can hang off the left edge of a horizontal
line or the top edge of a vertical line.
0x2000 The glyph can hang off the right edge of a horizontal
line or the bottom edge of a vertical line.
0x1000 If this bit is true, two things are true: this glyph is a
bracketing glyph (e.g. parenthesis, bracket, brace,
etc.); and the other glyph corresponding to this one is
right-to-left. If this glyph is not a bracketing glyph,
or if it is but the other glyph is left-to-right, this bit
is false. See below for a further discussion of
bracketing glyphs.
0x0F00 Offset to the corresponding bracketing glyph. Zero if
this is not a bracketing glyph. See below for a
further discussion of bracketing glyphs.
0x00F0 These must be zero in version 1 of this table. They
are reserved for future properties.
0x000F These four bits contain the glyph's directionality
class (see following table). For a discussion of what
these values mean, see the Unicode document.
______________________________________
The directionality class of a glyph is one of the following eleven values (as defined in the Unicode document):
______________________________________
Directionality Class
Description
______________________________________
(The first three values are the strong classes)
0 Strong left-to-right.
1 Strong right-to-left. (non-Arabic)
2 Arabic letters (right-to-left)
(The next five values are the weak classes)
3 European number.
4 European number separator.
5 European number terminator.
6 Arabic number.
7 Common number separator.
(The final four values are the neutral classes)
8 Block separator.
9 Segment Separator.
10 Whitespace.
11 Other neutrals.
12 through 15 These values are not used.
______________________________________
The format of a glyph properties table is as follows:
______________________________________
Type Name Description
______________________________________
fixed version Version number of the baseline
table (0x00010000 for the initial
version).
uint16 format Format of the glyph properties
table, set to 0 if no lookup data is
present; set to 1 if lookup data is
present.
uint16 default properties
Default properties to be applied
to a glyph if that glyph is not
present in the lookup table.
(variable)
lookup data Lookup table for non-defaulted
glyph properties.
______________________________________
Example of a glyph properties table An example of a font containing both Hebrew and Roman characters is given below. Because many glyphs share similar properties, a format 2 (single segment) lookup table is implemented. Other useful choices here might be format 6 (if only a few glyphs differ from the default), or formats 0 or 8 (where the number of segments might otherwise be prohibitive).
______________________________________
Offset/length
Value Comment
______________________________________
0/4 0x00010000
Version number (1.0 in fixed-format).
4/2 1 Format 1: lookup data is present.
6/2 0 Default properties are left-to-right,
cannot hang off either end of a line,
and is not a floater. Note that by
designating this as the default
property, we need only provide data
for those glyphs that differ from this
default.
(The lookup table starts here)
8/2 2 Lookup table format 2 (segment
single table format).
10/2 6 Size of a LookupSegment (2 bytes for
the starting glyph index, 2 bytes for
the ending glyph index, and 2 bytes
for the properties value).
12/2 2 Number of entries in the table.
14/2 12 Search range (see section on lookup
tables, above).
16/2 1 Entry selector (see section on lookup
tables, above).
18/2 0 Range shift.
(The LookupSegment entries start here)
84/2 2 Ending glyph index for space.
86/2 2 Starting glyph index for space.
88/2 10 Properties for space (Whitespace).
90/2 225 Ending glyph index for Hebrew
glyphs.
92/2 150 Starting glyph index for Hebrew
glyphs.
94/2 0x0001 Properties for these glyphs
(right-to-left).
______________________________________
The Glyph Metamorphosis Table--tag `mort`The glyph metamorphosis table specifies a set of text transformations, called text features. Examples of text features are ligature formation, number style, and ornateness. Although a standard set of text features have been defined, font designers are free to define their own. The glyph metamorphosis table consists of a header followed by one or more metamorphosis chains. Each metamorphosis chain contains a specification of the text features it describes, and one or more metamorphosis subtables, specifying a set of atomic transformations which, when applied to the glyph array in the proper order,will result in the text features' text transformations. Within a metamorphosis chain text features are specified by a TextFeature:
______________________________________
Type Name Description
______________________________________
uint16 featureType The type of feature.
uint16 featureSetting
The feature's setting.
______________________________________
The feature type specifies the particular feature.
______________________________________
Feature Type Description
______________________________________
0 Ligature Formation.
1 Contextual Ornateness.
2 Case Substitution.
3 Vertical Substitution.
4 Indic-style rearrangement.
5 Number Style
6 Non-contextual Ornateness
7 Discritic Marks
8 Feature Set
9 Elevation (superiors and inferiors)
10 Fractions
______________________________________
For each text feature, the feature setting specifies a particular variant of the feature. For example, a feature setting for the Ligature Formation feature might be "normal ligatures", and a setting for the Number Style feature might be "columnating numbers".
______________________________________
Feature Setting
Description
______________________________________
0 Normal: form only those ligatures which are
normally used.
1 Suppress: don't form any ligatures.
2 Mandatory: form only those ligatures which are
required for correct rendering.
3 Optional: form all possible ligatures.
______________________________________
The currently preferred defined settings for the Contextual Ornateness feature are:
______________________________________
Feature Setting
Description
______________________________________
0 Normal: use normal ornate glyphs according to
context
1 Suppress: don't use ornate glyphs.
2 Alternate 1: use ornate glyphs from alternate set
1 according to context
3 Alternate 2: use ornate glyphs from alternate set
2 according to context
4 Alternate 3: use ornate glyphs from alternate set
3 according to context
5 Alternate 4: use ornate glyphs from alternate set
4 according to context
______________________________________
The currently defined settings for the Case Substitution feature are:
______________________________________
Feature Setting
Description
______________________________________
0 None: do not perform case substitution.
1 Upper: substitute upper case letters for lower
case letters.
2 Lower: substitute lower case letters for upper
case letters.
3 Small Caps: substitute small caps for lower case
letters.
______________________________________
The currently defined settings for the Vertical Substitution feature are:
______________________________________
Feature Setting
Description
______________________________________
0 Normal: substitute vertical variants in vertical
text.
1 None: do not substitute vertical variants.
2 Always: always substitute vertical variants, even
in horizontal text.
______________________________________
The currently defined settings for the Indic-style rearrangement feature are:
______________________________________
Feature Setting
Description
______________________________________
0 Normal: perform Indic-style rearrangement.
1 Suppress: don't perform Indic-style
rearrangement.
______________________________________
The currently defined settings for the Number Style feature are:
______________________________________
Feature Setting
Description
______________________________________
0 Lining: use the "normal" lining style numbers.
1 Traditional: use the "traditional" style numbers
2 Columnation: use columnating numbers..
______________________________________
The currently defined settings for the Non-contextual Ornateness feature are:
______________________________________
Feature Setting
Description
______________________________________
0 Plain: use plain glyphs.
1 Ornate 1: use glyphs from ornate set 1.
2 Ornate 2: use glyphs from ornate set 2.
3 Ornate 3: use glyphs from ornate set 3.
4 Ornate 4: use glyphs from ornate set 4.
5 Ornate 5: use glyphs from ornate set 5.
______________________________________
The currently defined settings for the Diacritic Marks feature are:
______________________________________
Feature
Setting
Description
______________________________________
0 Show: show diacritic marks in their normal positions.
1 Hide: don't show diacritic marks at all.
2 Serialize: show diacritic marks as separate glyphs.
______________________________________
The currently defined settings for the Feature Set feature are:
______________________________________
Feature
Setting
Description
______________________________________
0 Empty: a set of no features.
1 Plain: a set of features which produces "plain" text.
2 Fancy1: a set of features which produces "fancy" text.
3 Fancy2: a set of features which produces "fancy" text.
4 Fancy3: a set of features which produces "fancy" text.
______________________________________
The currently defined settings for the Elevation feature are:
______________________________________
Feature
Setting Description
______________________________________
0 Normal: no offset from baseline.
1 Superior: a glyph designed to be placed above the
baseline.
2 Inferior: a glyph designed to be placed below the
baseline.
______________________________________
The currently defined settings for the Fraction feature are:
______________________________________
Feature
Setting
Description
______________________________________
0 Normal: form (existing) fraction ligatures normally.
1 Suppress: don't form ligatures normally.
2 Construct: synthesize fractions from superiors and
inferiors.
______________________________________
The glyph metamorphosis table header has the following format:
______________________________________
Type Name Description
______________________________________
fixed version Version number of the glyph metamorphosis
table (0x00010000 for the initial version).
uint32
nChains Number of metamorphosis chains which
follow.
______________________________________
Each metamorphosis chain starts on a longword boundary (i.e. a multiple of 4 bytes), and has a header specifying the chain's features and their relationship to the chain's subtables:
______________________________________
Type Name Description
______________________________________
uint32
defauItFlags
The default sub-feature flags for this
chain (see below).
uint32
chainLength The length of the chain in bytes,
including this header.
uint16
nFeatureEntries
The number of entries in the chain's
feature table (see below).
uint16
nSubtables The number of subtables in the chain.
______________________________________
In general, the text transformation specified by a given combination of feature and setting will be composed of more than one atomic transformation. This relationship is described in the chain's feature table using a set of 32-bit value called sub-feature flags. The bits in the sub-feature flags each represent a particular subset of all the atomic transformations described by the chain's subtables. Although there are no restrictions on how these sub-feature flags are used, usually there will be a single bit for each combination of feature and setting. For example, 0.times.00000001 might mean "mandatory ligatures", 0.times.00000002 might mean "normal ligatures", and 0.times.00000004 might mean "optional ligatures". The chain's header is followed by the feature table, which is an array of feature table entries:
______________________________________
Type Name Description
______________________________________
TextFeature
feature The feature type and setting.
uint32 enableFlags
Flags for sub-features this feature
and setting enables.
uint32 disableFlags
Complement of flags for sub-
features this feature and setting
disables.
______________________________________
The feature table is used to compute the sub-feature flags for a list of requested features and settings. The result is initialized to the chain's defaultFlags. Next, the entries in the feature table are gone through in order, and if the feature and setting is in the requested list, the result is ANDed with the entry's disableFlags and ORed with the entry's enableFlags. When this is finished, the result will contain the sub-feature flags corresponding to the list of requested features. Notice that if the list of requested features is empty, the result will be the chain's defaultFlags--i.e. the defaultFlags specify those subfeatures which are requested "by default". Notice also that the order of entries in the requested feature list is not important, and that the order of the entries in the feature table/s important; entries later in the feature table take precedence over entries earlier in the table. This is necessary because only the font designer knows the relationship between the features and the sub-features. Using the above sub-feature flag examples, the chain's defaultFlags might be 0.times.00000003 (for Normal Ligature Formation) and the feature table entries for the Ligature Formation feature might be:
______________________________________
Feature Setting Enable Flags
DisableFlags
______________________________________
Ligature Formation
Mandatory 0x00000001 0xFFFFFFF9
(complement of 0x00000006)
Ligature Formation
Normal 0x00000003 0XFFFFFFFB
(complement of 0x00000004)
Ligature Formation
Optional 0x00000007 0XFFFFFFFF
(complement of 0X00000000)
Ligature Formation
Suppress 0X00000000 0xFFFFFFF8
(complement of 0x00000007)
______________________________________
This feature table is set up so that the Optional setting will also enable the Normal and Mandatory sub-features, and the Normal setting will also enable the Mandatory sub-feature. The Suppress setting will disable the subfeatures for all other settings. Each feature table ends with an entry for the Feature Set text feature with the Empty setting which turns o! all sub-feature flags for the chain:
______________________________________
Feature Setting Enable Flags
DisableFlags
______________________________________
Feature Set
Empty 0X00000000 0X00000000
(complement of 0XFFFFFFFF)
______________________________________
It is convenient to keep those text features which share sub-features together in a single chain. Although there is no such restriction, a single metamorphosis chain is sufficient unless the font's text features cannot be specified with 32 sub-features. Subtables have lengths that are multiples of 4 bytes. Padding should be added at the end of the subtable to ensure this. The feature table is followed by the subtables, which describe the atomic transformations making up the chain's sub-features. Although each atomic transformation has its own format, the subtables begin with a common header:
______________________________________
Type Name Description
______________________________________
uint16
length Length of subtable, including this
header, in bytes.
uint16
coverage Coverage flags and atomic transfor-
mation type (see below).
uint32
subFeatureFlags
Flags for sub-features this subtable
describes.
______________________________________
The subFeatureFlags field has a bit set for each sub-feature whose transformation requires the atomic transformation specified by the subtable. Subtables are traversed in order and are applied to the glyph array if the result of ANDing their subFeatureFlags with the requested sub-feature flags is non-zero. For example, using the feature table above, there would be three subtables: one with subFeatureFlags set to 0.times.00000001 for the Mandatory ligatures, one with subFeatureFlags set to 0x00000002 for the Normal ligatures which aren't Mandatory, and one with subFeatureFlags set to 0.times.00000004 for Optional ligatures which aren't Mandatory or Normal. Thus, the Mandatory subtable will be applied if the Ligature Formation setting is Mandatory, Normal, or Optional; the Normal subtable will be applied if the Ligature Formation setting is Normal or Optional; and the Optional subtable will be applied if the Ligature Formation setting is Optional. Thereby, the individual subtables simpler since each one deals with a particular subset of all the ligatures. On the other hand, a request for Optional ligatures means that three subtables will be applied. Given the following feature table:
______________________________________
Feature Setting Enable Flags
DisableFlags
______________________________________
Ligature Formation
Mandatory 0x00000001 0xFFFFFFF9
(complement of 0x00000006)
Ligature Formation
Normal 0x00000002 0XFFFFFFFA
(complement of 0x00000005)
Ligature Formation
Optional 0x00000004 0XFFFFFFFC
(complement of 0x00000003)
Ligature Formation
Suppress 0X00000000 0xFFFFFFF8
(complement of 0x00000007)
______________________________________
any Ligature Formation request will result in a single sub-feature flag set for the requested setting with the highest precedence. Again, there would be three subtables: one with subFeature Flags set to 0.times.00000001 for the Mandatory ligatures, one with subFeatureFlags set to 0.times.00000002 for the Mandatory and Normal ligatures, and one with subFeatureFlags set to 0.times.00000004 for Mandatory, Normal, and Optional ligatures. The Normal and Optional subtables would be more complex (since the Normal table would duplicate the ligatures in the Mandatory subtable and the Optional table would duplicate the ligatures in the Optional subtable), but at most one subtable would be applied to the glyph array, which would take less time than applying three subtables. This feature table could be used with the subtables from the first example by changing their subFeatureFlags to 0.times.00000007, 0.times.00000006, and 0.times.00000004 respectively. The bits in the coverage field have the following interpretation:
______________________________________
Mask value
Interpretation
______________________________________
0x8000 If set to 1, this subtable should only be applied to
vertical text. If set to zero, this subtable should only
be applied to horizontal text.
0x4000 If set to 1, this subtable should process the glyph
array in descending order. If set to zero, this
subtable should process the glyph array in ascending
order.
0x3FF8 These bits are reserved and should be set to zero.
0x0007 These bits specify the subtable type. (see below).
______________________________________
The subtable type specifies the type of atomic transformation the subtable describes. The defined values are:
______________________________________
Subtable Type Description
______________________________________
0 Indic rearrangement.
1 Contextual glyph substitution.
2 Ligature substitution.
3 (Not defined)
4 Non-contextual glyph substitution.
______________________________________
The common subtable header is followed by a subheader the format of which depends on the subtable type. The Indic rearrangement subtable is a state table:
______________________________________
Type Name Description
______________________________________
StateHeader
stHeader The Indic rearrangement state table
header
______________________________________
The actions in an Indic rearrangement subtable use no per-glyph tables. The table-specific flags have the following format:
______________________________________
Mask value
Interpretation
______________________________________
0x8000 markFirst: if set, make the current glyph the first
glyph to be rearranged.
0x4000 If set, don't advance to the next glyph before going
to the new state.
0x2000 markLast: if set, make the current glyph the last
glyph to be rearranged.
0x1FF0 These bits are reserved and should be set to zero.
0x000F Rearrangement verb (see below).
______________________________________
An Indic rearrangement action specifies a rearrangement of the order of a contiguous range of glyphs in the glyph array. The markFirst and markLast flags are used to remember the position of this range in the glyph array, and the verb is used to specify the type of rearrangement. The first and last glyph values are set before the verb is applied. The table below shows the possible rearrangements, where A, B, C, and D represent individual glyphs and x represents an arbitrary sequence of glyphs:
______________________________________
Verb Results
______________________________________
00 no change
01 Ax => xA
02 xD => Dx
03 AxD => DxA
04 ABx=> xAB
05 ABx => xBA
06 xCD => CDx
07 xCD => DCx
08 AxCD => CDxA
09 AxCD => DCxA
10 ABxD => DxAB
11 ABxD => DxBA
12 ABxCD => CDxAB
13 ABxCD => CDxBA
14 ABxCD => DCxAB
15 ABxCD => DCxBA
______________________________________
The contextual glyph substitution subtable is also a state table:
______________________________________
Type Name Description
______________________________________
StateHeader
stHeader The contextual glyph substi-
tution state table header
uint16 substitutionTable
Byte offset from the beginning
of the state table to the | ||||||
