The Table Directory

The TrueType font file begins at byte 0 with the Offset Table.

Type

Name

Description

Fixed

sfnt version

0x00010000 for version 1.0.

USHORT

numTables

Number of tables.

USHORT

searchRange

(Maximum power of 2 £ numTables) x 16.

USHORT

entrySelector

Log2(maximum power of 2 £ numTables).

USHORT

rangeShift

NumTables x 16-searchRange.


This is followed at byte 12 by the Table Directory entries. Entries in the Table Directory must be sorted in ascending order by tag.

Type

Name

Description

ULONG

tag

4 -byte identifier.

ULONG

checkSum

CheckSum for this table.

ULONG

offset

Offset from beginning of TrueType font file.

ULONG

length

Length of this table.


The Table Directory makes it possible for a given font to contain only those tables it actually needs. As a result there is no standard value for numTables.

Tags are the names given to tables in the TrueType font file. At present, all tag names consist of four characters, though this need not be the case. Names with less than four letters are allowed if followed by the necessary trailing spaces. A list of the currently defined tags follows.

Required Tables

Tag

Name

cmap

character to glyph mapping

glyf

glyph data

head

font header

hhea

horizontal header

hmtx

horizontal metrics

loca

index to location

maxp

maximum profile

name

naming table

post

PostScript information

OS/2

OS/2 and Windows specific metrics


Optional Tables

Tag

Name

cvt

Control Value Table

EBDT

Embedded bitmap data

EBLC

Embedded bitmap location data

EBSC

Embedded bitmap scaling data

fpgm

font program

gasp

grid-fitting and scan conversion procedure (grayscale)

hdmx

horizontal device metrics

kern

kerning

LTSH

Linear threshold table

prep

CVT Program

PCLT

PCL5

VDMX

Vertical Device Metrics table

vhea

Vertical Metrics header

vmtx

Vertical Metrics


Other tables may be defined for other platforms and for future expansion. Note that these tables will not have any effect on the scan converter. Tags for these tables must be registered with Apple Developer Technical Support. Tag names consisting of all lower case letters are reserved for Apple's use. The number 0 is never a valid tag name.

Table checksums are the unsigned sum of the longs of a given table. In C, the following function can be used to determine a checksum:

ULONG

CalcTableChecksum(ULONG *Table, ULONG Length)

{

ULONG Sum = 0L;

ULONG *Endptr = Table+((Length+3) & ~3) / sizeof(ULONG);

while (Table < EndPtr)

Sum += *Table++;

return Sum;

}

Note: This function implies that the length of a table must be a multiple of four bytes. While this is not a requirement for the TrueType scaler itself, it is suggested that all tables begin on four byte boundries, and pad any remaining space between tables with zeros. The length of all tables should be recorded in the table directory with their actual length.

Note that the offset in the Table Directory is measured from the start of the TrueType font file.