The 'hmtx' table

General table information

The 'hmtx' table contains metric information for the horizontal layout each of the glyphs in the font. It begins with the hMetrics array. Each element in this array has two parts: the advance width and left side bearing. The value numOfLongHorMetrics is taken from the 'hhea' (Horizontal Header) table. In a monospaced font, only one entry is required but that entry may not be omitted.

Optionally, an array of left side bearings follows. Generally, this array of left side bearings is used for a run of monospaced glyphs. For example, it might be used for a Kanji font or for Courier. Only one such run is allowed per font. It must be at the end of the table.The corresponding glyphs are assumed to have the same advance width as that found in the last entry in the hMetrics array. Since there must be a left side bearing and an advance width associated with each glyph in the font, the number of entries in this array is derived from the total number of glyphs in the font minus the value numOfLongHorMetrics.

A longHorMetric is defined by the C structure shown here:

 

struct {
    uint16 advanceWidth;
    int16 leftSideBearing;
}

Table 24 : 'hmtx' table
Type Name Description
longHorMetric hMetrics[numOfLongHorMetrics] The value numOfLongHorMetrics comes from the 'hhea' table. If the font is monospaced, only one entry need be in the array but that entry is required.
FWord leftSideBearing[] Here the advanceWidth is assumed to be the same as the advanceWidth for the last entry above. The number of entries in this array is derived from the total number of glyphs minus numOfLongHorMetrics. This generally is used with a run of monospaced glyphs (e.g. Kanji fonts or Courier fonts). Only one run is allowed and it must be at the end.



Mac OS-specific information

Although it is officially listed as a "required" TrueType table, the 'hmtx' table is not in fact required for all sfnt-housed fonts on the Mac OS.

Non-TrueType fonts housed in an sfnt data structure may not have a 'hmtx' table. This is allowed by the OFA2 architecture.

TrueType fonts which have no outline data but consist of bitmaps only should not have a 'head' table. They should use the byte-by-byte identical 'bhed' table instead. The Mac OS uses the presence of a 'bhed' to signal the fact that a font has no outlines. Such fonts may also lack an 'hmtx' table.

Newton-specific information

Although they consist of bitmaps only, Newton fonts are required to have the 'hhea' table.

Dependencies

The value of the numOfLongHorMetrics field is found in the 'hhea' (Horizontal Header) table. Fonts that lack an 'hhea' table must not have an 'hmtx' table.

Other tables may have information duplicating data contained in the 'hmtx' table. For example, glyph metrics can also be found in the 'hdmx' (Horizontal Device Metrics) table and 'bloc' (Bitmap Location) table. There is naturally no requirement that the ideal metrics of the 'hmtx' table be perfectly consistent with the device metrics found in other tables, but care should be taken that they are not wildly inconsistent.

Tools

Editing of the 'hmtx' table is possible using TrueEdit. Other tools may automatically update fields in the 'hmtx' table as needed.


Change Log

15 February 2000
Noted that this table is not required in non-TrueType sfnt-housed fonts.
1 October 1996
Created unified TrueType book.
applefonts@apple.com

[Table of Contents]