The order of the structures
The Windows DDK gives a PFM file this general form:
PFMHEADER Header; /* font header */
WORD WidthTable[]; /* character widths */
PFMEXTENSION Extensions; /* extensions */
char DeviceName[]; /* printer-device name */
char FaceName[]; /* font name */
EXTTEXTMETRIC ExtTextMetrics; /* extended-text metrics */
WORD ExtentTable[]; /* unscaled-character widths */
DRIVERINFO DriverInfo; /* driver-specific information */
PAIRKERN KerningPairs[]; /* pair-kerning table */
KERNTRACK KerningTracks[]; /* track-kerning table */
The PFMHEADER structure, the PFMEXTENSION structure and the font name must be present in every PFM file; whether the other structures are present depends on the printer driver and the font vendor.
The header and the extension must be, respectively, the first and second structures in the file (the width table, if there is one, sits between them); the rest may appear in any order, and their locations are indicated by
the offsets in the header and extension. All file positions are offsets from the start of the individual PFM file.
The width table
The width table is an array of 16-bit values, the width of each character; the number of elements is dfLastChar − dfFirstChar + 2, and the last, extra entry is zero. It is optional: a fixed-pitch font does not
need it, as all characters have the same width. It is present only in the PFM files of variable-pitch PCL fonts; a PostScript PFM file has none and keeps the widths in the extent table. A reader finds out whether the table is there by
looking at the two bytes after the header: the extension begins with dfSizeFields, which is 30.
PFMEXTENSION
The extension is 30 bytes; its fields are file offsets, and the first is its own size. In a PostScript file Adobe’s tools write only three meaningful fields (TN 5178: the extended metrics, the extent table and the driver information).
| Offset in the structure | Size | Field | Meaning |
|---|---|---|---|
| 0 | 2 | dfSizeFields | The size of this structure in bytes: 30. |
| 2 | 4 | dfExtMetricsOffset | The offset of the EXTTEXTMETRIC structure. 147 in Adobe’s layout. Must be non-NULL in a PostScript file. |
| 6 | 4 | dfExtentTable | The offset of the extent table, dfLastChar − dfFirstChar + 1 words of unscaled widths in 1/1000 em. Must be present in a PostScript file. |
| 10 | 4 | dfOriginTable | The offset of a table of character origins, dfLastChar − dfFirstChar + 1 words, used by screen fonts (signed left adjustments). NULL in a printer font metrics file. |
| 14 | 4 | dfPairKernTable | The offset of the pair kerning table; NULL if the font has no kerning pairs. Its size is etmKernPairs of the extended metrics. |
| 18 | 4 | dfTrackKernTable | The offset of the track kerning table; NULL if no tracks. Its size is etmKernTracks. |
| 22 | 4 | dfDriverInfo | The offset of driver-specific data, documented by each driver writer. In a PostScript file, the PostScript name of the font; in a PCL file, a DRIVERINFO structure. |
| 26 | 4 | dfReserved | Reserved; NULL. |
The strings
The device name and the face name are null-terminated strings; the header’s dfDevice and dfFace point at them. The device name is PostScript for a PostScript font. The face name is the name that appears in applications’ font menus,
the Windows name (Tms Rmn, for example); the PostScript name, which the driver sends to the printer to select the font and which can vary by printer manufacturer, is pointed to by dfDriverInfo. Both are null-terminated.
Adobe’s layout
TN 5178 section 8 says the order and location of the extended metrics, device string, face string, PostScript name string and extent table does not matter, because the offsets say where they are, but that Adobe’s convention is the order: extended text metrics, device type string, Windows name string, PostScript name string, extent table. That order has fixed values for three fields:
| Field | Value | Why |
|---|---|---|
dfExtMetricsOffset | 147 | 117 bytes of header and 30 of extension. |
dfDevice | 199 | 147 plus the 52 bytes of EXTTEXTMETRIC. |
dfFace | 210 | 199 plus the 11 bytes of PostScript and its zero byte. |
The PostScript name then follows the face name (dfDriverInfo = 210 + the length of the face name + 1), and the extent table follows the PostScript name; for a fixed range of 32 to 255 it is 448 bytes, so the file size is the offset of the extent table plus 448.