PostScript fonts
The Windows 3.0 Device Driver Kit’s chapter on PFM files for PostScript printers lists the structures of the file in this order: the header, the extension (whose pointers to the extended metrics, the extent table and the driver data must not be NULL), the device name, the Windows face name, the extended text metrics, the extent table and the PostScript font name, and optionally the pair kerning table and the track kerning table. The rules it states:
- There is no width table: PostScript fonts are scalable, so the widths are in the extent table, unscaled, at 1000 units to the em, over the range
dfFirstChartodfLastChar. - The driver assumes all PostScript fonts are scalable and ignores
dfPointsanddfPixHeight;dfAvgWidthanddfMaxWidthare in units of 1000 to the em. - The attributes in a PostScript font name (bold, italic) should be taken out of the Windows name and put in
dfWeightanddfItalic. - The driver assumes
dfVertRes= 300,etmMasterHeight= 300 andetmMasterUnits= 1000; the extent table must be built at 1000 units to the em. The true scaling range of the font should be given inetmMinScaleandetmMaxScale(device units at 300 dpi), although the driver ignores them. The driver ignoresetmPointSize. - Pair kerning values are in the same 1000 units as the extents. “We do not know of any application that uses the track-kern table.” The only field of
EXTTEXTMETRICknown to be used isetmKernPairs, but the others should still be given reasonable values. - The driver-specific structure pointed to by
dfDriverInfois a null-terminated string: the PostScript name of the font. The Windows name (the name in the application’s font list, such asTms-Rmn) is pointed to bydfFaceand the PostScript name bydfDriverInfo; the PostScript name can vary by printer manufacturer and is what the driver sends to the printer to select the font. - The DDK adds that the driver does not make the PFM file from font data; a font vendor must supply it, from the font’s AFM file, to guarantee an accurate description.
CJK fonts (Technical Note #5178)
Adobe Technical Note #5178, “Building PFM Files for PostScript-Language CJK Fonts” (10 January 1997), describes PFM files for Type 1, CID-keyed and composite Chinese, Japanese and Korean fonts, which Adobe Type Manager and other software need to install them under Windows. The file has five sections: the header (117 bytes), the extension (30 bytes), the extended text metrics (52 bytes), three PostScript information strings, and the extent table (448 bytes for the codes 32 to 255). Most values do not change from font to font. The values it fixes are in the field tables of the header, the extension and the extended metrics pages; the three strings are:
| String | Content |
|---|---|
| Device type | The static string PostScript, zero terminated. |
| Windows name | The menu name of the font in applications, zero terminated. It is typically a localised non-ASCII string. For a font used vertically (/WMode 1, or otherwise intended for vertical use) an at sign, @ (0x40), is put in front of it, which makes the string one byte longer. |
| PostScript name | The fully qualified PostScript font name (a valid argument to findfont or selectfont), zero terminated. For a CID-keyed font it is the CIDFont name and a CMap name joined by one or two hyphens; two are preferred, one may be needed for fonts that were once OCF (Original Composite Format) fonts: STSong-Light--GBK-EUC-V (CID-only), Ryumin-Light-RKSJ-H (both an OCF font and a CID-keyed font). The name is written in ASCII for Latin, in Shift-JIS for Japanese, EUC-KR for Korean, EUC-CN for Simplified Chinese and Big Five for Traditional Chinese. |
EUC-KR and EUC-CN are recommended over UHC and GBK, because UHC and GBK were only supported starting with Windows 95. For the extent table, the value of a code that is the first byte of a two-byte character is 500. The extended text metrics
etmCapHeight, etmXHeight, etmLowerCaseAscent and etmLowerCaseDescent are those of the H, x, d and p of the Roman characters the font instance uses (half-width or proportional); when the font has no Roman characters the defaults are 880, 880, 880 and 120 (the CJK characters are optically centred between −120 and 880). The note’s file name rule: an 8.3 name with the extension pfm.
Building a PFM file
TN 5178 includes a Perl program (by Ken Lunde, December 1996) that builds the PFM file of a CJK font from a small data file; its binary layout is the one on these pages. It packs the header as vVa60vvvvvvvCCCvCvvCvvCCCCvVVVV, the extension as vVVVVVVV, the extended text metrics as 26 words and the
strings as three null-terminated strings, then the 224 extent words; v is a little-endian 16-bit value, V a little-endian 32-bit value, a60 a 60 byte zero-padded string and C a byte. It computes the offset of the PostScript name as 210 + the length of the Windows name + 1, the offset of the extent table as that plus the length of the PostScript name + 1, and the size of the file as the offset of the extent table plus 448.
The note says many values, such as the ascent and descent, can be read from the font itself, and that an AFM file makes this “trivial”: the ascent comes from the fourth number of FontBBox and the descent from the second.
PCL fonts
For a PCL printer font (the HP LaserJet driver of the Windows 3.1 Printers and Fonts Kit) the device name is PCL / HP LaserJet, a width table is present for variable-pitch fonts, and dfDriverInfo points at a DRIVERINFO structure instead of a PostScript name. The fields the Windows 3.1 DDK gives are:
| Field | Meaning |
|---|---|
epSize (word) | The size of the structure in bytes. |
epVersion (word) | The version of the structure, currently 1. |
epMemUsage (long) | The memory the font uses in the printer, in bytes. |
epEscape (long) | The offset from the start of the file of the escape string that selects the font. |
xtbl (TRANSTABLE) | Character translation: symbolSet (the kind of translation table: epsymRoman8, epsymECMA94 …), offset (long, of a user-defined table), len (word, its length in bytes), firstchar and lastchar (bytes, the range). The Windows PCL driver ignores everything in it but symbolSet. |
The SYMBOLSET values, from 0: epsymUserDefined, epsymRoman8, epsymKana8, epsymMath8, epsymUSASCII, epsymLineDraw, epsymMathSymbols, epsymUSLegal, epsymRomanExt, epsymISO_DenNor, epsymISO_UK, epsymISO_France, epsymISO_German, epsymISO_Italy, epsymISO_SwedFin, epsymISO_Spain,
epsymGENERIC7, epsymGENERIC8, epsymECMA94. The DDK declares the enumeration without saying how many bytes it takes in the file; the viewer takes 16 bits and reads the whole DRIVERINFO as 22 bytes, and the size in epSize is shown beside it.