Adobe Technical Note #5004 describes metrics for four kinds of PostScript font program: normal Type 1 (a base font), composite fonts (Type 0), multiple master fonts (an extension of Type 1) and CID-keyed fonts. A base font is described in chapter 5 of the PostScript Language Reference Manual, second edition, and has up to about 200 characters reached by single-byte codes. This page covers the other three; the keys they share with every AFM file are on the keys page.
Composite fonts and the ACFM file
A composite font program is a “font of fonts”: instead of characters it holds descendent font programs, in a recursive structure whose leaves are base fonts. It can hold several thousand characters, reached by multi-byte codes, so it is used for non-roman scripts such as Japanese kanji, and it can support several writing directions. A key in the font dictionary selects the set of metrics used to show a string. The AFM file of a composite font lists every character of every descendent, so it can be large (a Japanese OCF font is about 2.7 megabytes); the ACFM file instead gives the structure only and is small.
An ACFM file has three sections: the header (control and global information of the top-level composite font, identical to the same font’s AFM file), the writing direction information (also
identical), and the descendent fonts. It starts with StartCompFontMetrics and ends with EndCompFontMetrics.
| Key | Values | Meaning |
|---|---|---|
Descendents | integer | Required. The number of entries in the Encoding array of the PostScript font program (not usually the number of distinct descendent fonts). Exactly this many descendent sections follow; the key occurs before the first StartDescendent. |
MetricsSets | integer | As in an AFM file. |
StartDescendent … EndDescendent | <from> <to> | Required. One descendent font. The two values are hexadecimal numbers in angle brackets: the range of byte values mapped to this font program, for example <2100> <21FF>. |
Inside a descendent section go the global keys of the keys page (FontName, IsBaseFont, Characters, FontBBox,
EncodingScheme …) and the writing direction sections, as far as they apply to that descendent and are not already given at the top level. Entries mapped to the NotDefFont have
Characters 0.
StartCompFontMetrics 3.0
MetricsSets 1
FontName Ryumin-Light-V
IsBaseFont false
Characters 7238
FontBBox -500 -1185 500 23
EncodingScheme JIS12-88-CFEncoding
MappingScheme 2
StartDirection 1
ItalicAngle 0
CharWidth 0 -1000
EndDirection
Descendents 256
StartDescendent <0000> <00FF>
FontName NotDefFont
IsBaseFont true
Characters 0
EncodingScheme NotDefEncoding
EndDescendent
StartDescendent <2100> <21FF>
FontName Ryumin-Light.r21v
IsBaseFont true
Characters 94
FontBBox -495 -1020 495 0
EncodingScheme JISEncoding
EndDescendent
…
EndCompFontMetrics
This is cut down from section 11.5 of the note. The note’s second example, the Shift-JIS encoded GothicBBB-Medium-83pv-RKSJ-H (section 11.6), has seven descendents whose ranges are one
byte (<00> <7F>) or two bytes (<8100> <9FFF>); a program that wants to replace a descendent, such as the user gaiji font, changes the entry of the Encoding array at the descendent’s position,
counted from 0.
CID-keyed fonts
The CID-keyed font technology was designed for the large character sets of Chinese, Japanese and Korean fonts. The AFM file of a CID-keyed font does not use the ACFM and multiple AFM structure: the character
metrics are listed once, ordered by CID number, which saves a great deal of space (about 400 kilobytes against 2.7 megabytes for the same Japanese font as an original composite font). It starts with
StartFontMetrics like any AFM file and says IsCIDFont true; FontName is the CIDFontName of the CIDFont file, and CharacterSet names the
character collection (Adobe-Japan1-2). Each character line has C -1 and the CID number as its name:
StartFontMetrics 4.0
MetricsSets 2
FontName Ryumin-Light
Weight Light
FontBBox -170 -331 1024 903
Version 3.003
CharacterSet Adobe-Japan1-2
Characters 8720
IsBaseFont true
IsCIDFont true
Ascender 903
Descender -331
CapHeight 903
StartDirection 2
UnderlinePosition -100
UnderlineThickness 50
ItalicAngle 0
IsFixedPitch false
EndDirection
StartCharMetrics 8720
C -1 ; W0X 1000 ; N 0 ; B 0 0 0 0 ;
C -1 ; W0X 250 ; N 1 ; B 0 0 0 0 ;
…
EndCharMetrics
EndFontMetrics
A CID that is left out has no character. The viewer checks that every N of a CID-keyed file is an integer and notes a CID that does not follow the one before it. The format of the CID-keyed AFM file was introduced in version 4.1 of the note, with IsCIDFont.
Multiple master fonts and the AMFM file
A multiple master font program contains two or more typeface designs, the master designs, organised along one or more design axes, each a typographic variable such as weight, width or optical size. The ends of an
axis are master designs, as are any intermediate designs; the maximum number of masters is sixteen, and with n axes and x intermediate designs the rule is 2n + x = 16 (section 6). An instance of the font is a weighted average of
the masters, set by the WeightVector array of the font dictionary: for k masters there are k weights that sum to 1.0.
The AMFM file holds the global information and a section for each master design. It starts with StartMasterFontMetrics, ends with EndMasterFontMetrics, and uses the family name for its own name (MyriadMM); the character metrics of each master design are in a standard AFM
file named after that master’s FontName (MyriadMM-LightCn). In environments such as the Macintosh and Windows the metrics of an instance are in the FOND resource or the PFM file, and an application need not interpolate.
| Key | Values | Meaning |
|---|---|---|
Masters | integer | Required. The number of master designs: the number of StartMaster … EndMaster pairs. It occurs before the first StartMaster and before WeightVector. |
Axes | integer | Required. The number of axes: the number of StartAxis … EndAxis pairs. |
WeightVector | array | Required. The weights for the default instance; k numbers summing to 1.0. In a master section the array has zeros and one 1, at the position of that master. |
BlendDesignPositions | array of k arrays of n numbers | Required. The place of each master in the design space, each coordinate from 0 to 1. For five masters (the middle, light condensed, light expanded, bold condensed, bold expanded): [[.5 .5] [0 0] [0 1] [1 0] [1 1]]. |
BlendDesignMap | array of n arrays of 2 to 12 pairs | Required. For each axis, the mapping of design coordinates to normalised coordinates, as pairs [design normalised]. The note’s optical size example maps 6 to 0, 24 to 0.5 and 72 to 1: piecewise linear, the 0.5 point at design coordinate 24 and not at the linear middle, 39. |
BlendAxisTypes | array of names | Required. The name of each axis: [ /Weight /Width /OpticalSize ]. |
StartAxis … EndAxis | none | Required, one for each axis. Contain AxisType (optional: only the types Adobe reserves, Weight, Width and OpticalSize) and AxisLabel (optional, any text, for a user interface). |
StartMaster … EndMaster | none | Required, one for each master. Hold what is global to that master: FontName (it gives the name of the master’s AFM file), FullName, FamilyName, Version and its WeightVector. |
StartPrimaryFonts … EndPrimaryFonts | count | Optional (added in 4.1). The primary fonts shipped with the font, pre-calculated for standard styles. Each line has PC (required: one integer for each axis, the primary coordinates), PL (optional: a string in parentheses for each axis) and PN (optional: the traditional name). |
The AMFM file also carries the global keys of the keys page: FontName, FullName, FamilyName, Weight, ItalicAngle,
IsFixedPitch, FontBBox (numbers, not integers, since multiple masters), UnderlinePosition, UnderlineThickness, Version, Notice, EncodingScheme, CapHeight,
XHeight, Ascender and Descender.
StartMasterFontMetrics 4.0
FontName MyriadMM
FontBBox -55.16 -250.00 1143.86 834.91
Masters 4
Axes 2
WeightVector [0.17 0.08 0.52 0.23 ]
BlendDesignPositions [[0 0] [0 1] [1 0] [1 1]]
BlendDesignMap [[[215 0][830 1]][[200 0][600 1]]]
BlendAxisTypes [/Weight /Width ]
StartAxis
AxisLabel Weight
AxisType Weight
EndAxis
StartAxis
AxisLabel Width
AxisType Width
EndAxis
StartMaster
FontName MyriadMM-LightCn
WeightVector [1 0 0 0 ]
EndMaster
…
EndMasterFontMetrics
This is cut down from section 11.2 of the note. The viewer checks the counts against Masters and Axes, that no more than sixteen masters are given, that the weights sum to 1.0, that each master’s weight vector is zeros and a single 1, the shape of the blend arrays (the number of positions, the number of coordinates in each, 0 to 1, 2 to 12 pairs
per axis) and the primary font lines.
Interpolating the metrics of an instance
An application that depends on AFM files must calculate the metrics of the font instance the user chose: a weighted average of the values from the AFM file of each master design. With k masters and the
weight vector W (the values of the WeightVector array of the instance, summing to 1.0), a width is
Width = Σi=1…k Wi × Vi
where Vi is the width of the character in the ith master’s AFM file. The same blend applies to widths, side bearings, underline position and thickness, and every other numeric parameter that varies among the masters (section 3.3 of the note). The viewer shows the AMFM structure; it does not interpolate, because that needs the AFM file of every master.