Jaa


EBLC — Embedded Bitmap Location Table (OpenType 1.8.3)

The EBLC provides embedded bitmap locators. It is used together with the EBDT table, which provides embedded, monochrome or grayscale bitmap glyph data, and the EBSC table, which provided embedded bitmap scaling information.

OpenType embedded bitmaps are called “sbits” (for “scaler bitmaps”). A set of bitmaps for a face at a given size is called a strike.

The EBLC table identifies the sizes and glyph ranges of the sbits, and keeps offsets to glyph bitmap data in IndexSubTables. The EBDT table then stores the glyph bitmap data, also in a number of different possible formats. Glyph metrics information may be stored in either the EBLC or EBDT table, depending upon the IndexSubTable and glyph bitmap formats. The EBSC table identifies sizes that will be handled by scaling up or scaling down other sbit sizes.

The EBLC table uses the same format as the Apple Apple Advanced Typography (AAT) 'bloc' table.

The EBLC table begins with a header containing the table version and number of strikes. An OpenType font may have one or more strikes embedded in the EBDT table.

EBLC Header

Type Name Description
uint16 majorVersion Major version of the EBLC table, = 2.
uint16 minorVersion Minor version of the EBLC table, = 0.
uint32 numSizes Number of BitmapSize tables.

Note that the first version of the EBLC table is 2.0.

The EblcHeader is followed immediately by the BitmapSize table array(s). The numSizes field in the EblcHeader indicates the number of BitmapSize tables in the array. Each strike is defined by one BitmapSize table.

BitmapSize Table

Type Name Description
Offset32 indexSubTableArrayOffset Offset to IndexSubtableArray, from beginning of EBLC.
uint32 indexTablesSize Number of bytes in corresponding index subtables and array.
uint32 numberOfIndexSubTables There is an IndexSubtable for each range or format change.
uint32 colorRef Not used; set to 0.
SbitLineMetrics hori Line metrics for text rendered horizontally.
SbitLineMetrics vert Line metrics for text rendered vertically.
uint16 startGlyphIndex Lowest glyph index for this size.
uint16 endGlyphIndex Highest glyph index for this size.
uint8 ppemX Horizontal pixels per em.
uint8 ppemY Vertical pixels per em.
uint8 bitDepth The Microsoft rasterizer v.1.7 or greater supports the following bitDepth values, as described below: 1, 2, 4, and 8.
int8 flags Vertical or horizontal (see Bitmap Flags, below).

The indexSubTableArrayOffset is the offset from the beginning of the EBLC table to the IndexSubTableArray. Each strike has one of these arrays to support various formats and discontiguous ranges of bitmaps. The indexTablesSize is the total number of bytes in the IndexSubTableArray and the associated IndexSubTables. The numberOfIndexSubTables is a count of the IndexSubTables for this strike.

The horizontal and vertical line metrics contain the ascender, descender, linegap, and advance information for the strike. The line metrics format is described in the following table:

SbitLineMetrics

Type Name
int8 ascender
int8 descender
uint8 widthMax
int8 caretSlopeNumerator
int8 caretSlopeDenominator
int8 caretOffset
int8 minOriginSB
int8 minAdvanceSB
int8 maxBeforeBL
int8 minAfterBL
int8 pad1
int8 pad2

The caret slope determines the angle at which the caret is drawn, and the offset is the number of pixels (+ or -) to move the caret. This is a signed integer since we are dealing with integer metrics. The minOriginSB, minAdvanceSB , maxBeforeBL, and minAfterBL are described in the diagrams below. The main need for these numbers is for scalers that may need to pre-allocate memory and/or need more metric information to position glyphs. All of the line metrics are one byte in length. The line metrics are not used directly by the rasterizer, but are available to clients who want to parse the EBLC table.

The startGlyphIndex and endGlyphIndex describe the minimum and maximum glyph IDs in the strike, but a strike does not necessarily contain bitmaps for all glyph IDs in this range. The IndexSubTables determine which glyphs are actually present in the EBDT table.

The ppemX and ppemY fields describe the size of the strike in pixels per Em. The ppem measurement is equivalent to point size on a 72 dots per inch device. Typically, ppemX will be equal to ppemY for devices with “square” pixels. To accommodate devices with rectangular pixels, and to allow for bitmaps with other aspect ratios, ppemX and ppemY may differ.

Bit Depth

The bitDepth field of the BitmapSize table is used to specify the number of levels of gray used in the embedded bitmaps. The Microsoft rasterizer v.1.7 or greater support the following values.

Value Description
1 black/white
2 4 levels of gray
4 16 levels of gray
8 256 levels of gray

The flags byte contains two bits to indicate the direction of small glyph metrics: horizontal or vertical. The remaining bits are reserved.

Bitmap Flags

Mask Name Description
0x01 HORIZONTAL_METRICS Horizontal
0x02 VERTICAL_METRICS Vertical
0xFC Reserved For future use — set to 0.

The colorRef and bitDepth fields are reserved for future enhancements. For monochrome bitmaps they should have the values colorRef=0 and bitDepth=1.

Glyph line-direction and cross-stream metrics for horizontal text
Horizontal Text
Glyph line-direction and cross-stream metrics for vertical text
Vertical Text

Associated with the image data for every glyph in a strike is a set of glyph metrics. These glyph metrics describe bounding box height and width, as well as side bearing and advance width information. The glyph metrics can be found in one of two places. For ranges of glyphs (not necessarily the whole strike) whose metrics may be different for each glyph, the glyph metrics are stored along with the glyph image data in the EBDT table. Details of how this is done is described in the EBDT section of this document. For ranges of glyphs whose metrics are identical for every glyph, we save significant space by storing a single copy of the glyph metrics in the IndexSubTable in the EBLC.

There are also two different formats for glyph metrics: big glyph metrics and small glyph metrics. Big glyph metrics define metrics information for both horizontal and vertical layouts. This is important in fonts (such as Kanji) where both types of layout may be used. Small glyph metrics define metrics information for one layout direction only. Which direction applies, horizontal or vertical, is determined by the flags field in the BitmapSize table.

BigGlyphMetrics

Type Name
uint8 height
uint8 width
int8 horiBearingX
int8 horiBearingY
uint8 horiAdvance
int8 vertBearingX
int8 vertBearingY
uint8 vertAdvance

SmallGlyphMetrics

Type Name
uint8 height
uint8 width
int8 bearingX
int8 bearingY
uint8 advance

The following diagram illustrates the meaning of the glyph metrics.

Details of glyph position, bearing, and advance in relation to the pen position

The BitmapSize table for each strike contains the offset to an array of IndexSubTableArray elements. Each element describes a glyph ID range and an offset to the IndexSubTable for that range. This allows a strike to contain multiple glyph ID ranges and to be represented in multiple index formats if desirable.

IndexSubTableArray

Type Name Description
uint16 firstGlyphIndex First glyph ID of this range.
uint16 lastGlyphIndex Last glyph ID of this range (inclusive).
Offset32 additionalOffsetToIndexSubtable Add to indexSubTableArrayOffset to get offset from beginning of EBLC.

After determining the strike, the rasterizer searches this array for the range containing the given glyph ID. When the range is found, the additionalOffsetToIndexSubtable is added to the indexSubTableArrayOffset to get the offset of the IndexSubTable in the EBLC.

The first indexSubTableArray is located after the last bitmapSizeSubTable entry. Then the IndexSubTables for the strike follow. Another IndexSubTableArray (if more than one strike) and its IndexSubTableArray are next. The EBLC continues with an array and IndexSubTables for each strike.

We now have the offset to the IndexSubTable. All IndexSubTable formats begin with an IndexSubHeader which identifies the IndexSubTable format, the format of the EBDT image data, and the offset from the beginning of the EBDT table to the beginning of the image data for this range.

IndexSubHeader

Type Name Description
uint16 indexFormat Format of this IndexSubTable.
uint16 imageFormat Format of EBDT image data.
Offset32 imageDataOffset Offset to image data in EBDT table.

IndexSubtables

There are currently five different formats used for the IndexSubTable, depending upon the size and type of bitmap data in the glyph ID range. Apple 'bloc' tables support only formats 1 through 3.

The choice of which IndexSubTable format to use is up to the font manufacturer, but should be made with the aim of minimizing the size of the font file. Ranges of glyphs with variable metrics — that is, where glyphs may differ from each other in bounding box height, width, side bearings or advance — must use format 1, 3 or 4. Ranges of glyphs with constant metrics can save space by using format 2 or 5, which keep a single copy of the metrics information in the IndexSubTable rather than a copy per glyph in the EBDT table. In some monospaced fonts it makes sense to store extra white space around some of the glyphs to keep all metrics identical, thus permitting the use of format 2 or 5.

Structures for each IndexSubTable format are listed below.

IndexSubTable1: variable-metrics glyphs with 4-byte offsets

Type Name Description
IndexSubHeader header Header info.
Offset32 offsetArray[] offsetArray[glyphIndex] + imageDataOffset = glyphData sizeOfArray = (lastGlyph - firstGlyph + 1) + 1 + 1 pad if needed

IndexSubTable2: all glyphs have identical metrics

Type Name Description
IndexSubHeader header Header info.
uint32 imageSize All the glyphs are of the same size.
BigGlyphMetrics bigMetrics All glyphs have the same metrics; glyph data may be compressed, byte-aligned, or bit-aligned.

IndexSubTable3: variable-metrics glyphs with 2-byte offsets

Type Name Description
IndexSubHeader header Header info.
Offset16 offsetArray[] offsetArray[glyphIndex] + imageDataOffset = glyphData sizeOfArray = (lastGlyph - firstGlyph + 1) + 1 + 1 pad if needed

IndexSubTable4: variable-metrics glyphs with sparse glyph codes

Type Name Description
IndexSubHeader header Header info.
uint32 numGlyphs Array length.
GlyphIdOffsetPair glyphArray[numGlyphs + 1] One per glyph.

GlyphIdOffsetPair record:

Type Name Description
uint16 glyphID Glyph ID of glyph present.
Offset16 offset Location in EBDT.

IndexSubTable5: constant-metrics glyphs with sparse glyph codes

Type Name Description
IndexSubHeader header Header info.
uint32 imageSize All glyphs have the same data size.
BigGlyphMetrics bigMetrics All glyphs have the same metrics.
uint32 numGlyphs Array length.
uint16 glyphIdArray[numGlyphs] One per glyph, sorted by glyph ID.

The size of the EBDT image data can be calculated from the IndexSubTable information. For the constant-metrics formats (2 and 5) the image data size is constant, and is given in the imageSize field. For the variable metrics formats (1, 3, and 4) image data must be stored contiguously and in glyph ID order, so the image data size may be calculated by subtracting the offset for the current glyph from the offset of the next glyph. Because of this, it is necessary to store one extra element in the offsetArray pointing just past the end of the range’s image data. This will allow the correct calculation of the image data size for the last glyph in the range.

Contiguous, or nearly contiguous, ranges of glyph IDs are handled best by formats 1, 2, and 3 which store an offset for every glyph ID in the range. Very sparse ranges of glyph IDs should use format 4 or 5 which explicitly call out the glyph IDs represented in the range. A small number of missing glyphs can be efficiently represented in formats 1 or 3 by having the offset for the missing glyph be followed by the same offset for the next glyph, thus indicating a data size of zero.

The only difference between formats 1 and 3 is the size of the offsetArray elements: format 1 uses uint32s while format 3 uses uint16s. Therefore format 1 can cover a greater range (> 64k bytes) while format 3 saves more space in the EBLC table. Since the offsetArray elements are added to the imageDataOffset base address in the IndexSubHeader, a very large set of glyph bitmap data could be addressed by splitting it into multiple ranges, each less than 64k bytes in size, allowing the use of the more efficient format 3.

The EBLC table specification requires 32-bit alignment for all subtables. This occurs naturally for IndexSubTable formats 1, 2, and 4, but may not for formats 3 and 5, since they include arrays of type uint16. When there is an odd number of elements in these arrays it is necessary to add an extra padding element to maintain proper alignment.