\newcommand{\Lit}[1]{\texttt{#1}} \let\Lfn\Lit \let\fn\Lit \let\vref\ref \title{Using Adobe Type 1 Multiple Master fonts with \protect\TeX} \author[Michel Goossens and Sebastian Rahtz]{Michel Goossens\\ CERN, Geneva\\\texttt{m.goossens@cern.ch}\\ and\\ Sebastian Rahtz\\Elsevier Science Ltd\\\texttt{s.rahtz@elsevier.co.uk}} \begin{Article} \section{Introduction} The multiple master font format is an extension of the Type 1 font format, which allows the generation of a wide variety of typeface styles from a single font program. This capability allows users and applications control over the typographic parameters of fonts used in their documents, in a manner reminiscent of Knuth's ground-breaking \MF. This article describes the multiple master system in some detail, and describes the procedures needed to make instances, and create the appropriate font metrics for use with \TeX. \section{Multiple Master overview} A multiple master font program contains two or more outline typefaces called \emph{master designs}, which describe one or more \emph{design axes}. The master designs that constitute a design axis represent a dynamic range of one typographic parameter, such as the weight or width. This range of styles is defined in a multiple master font program by specifying one master design to represent each end of an axis, such as a \emph{light} and \emph{extra-bold} weight, as well as any \emph{intermediate master designs} that are required. The maximum number of master designs allowed is sixteen. A \emph{font instance} consists of a font dictionary derived from the multiple master font program (or from another font instance). It contains a \Lit{WeightVector} array with \emph{k} values that sum to 1.0 and which determine the relative contributions of each master design to the resulting interpolated design. All derived font instances share the \Lit{CharStrings} dictionary and \Lit{Subrs} array of the main multiple master font program, making it relatively economical to generate a variety of font instances. Multiple master fonts can be made compatible with the installed base of PostScript language interpreters by including several PostScript language procedures and a new set of \Lit{OtherSubrs} routines in the font program. The procedures include the new \Lit{makeblendedfont} operator, the interpolation procedure \Lit{\$Blend} and a new definition of the \Lit{findfont} operator. \subsection{Multiple Master Design Space} It is possible to think of the master designs as being arranged in a 1, 2, 3, or 4 dimensional space with various font instances corresponding to different locations in that space. The entries in the \Lit{FontInfo} dictionary specify what this space is and where the master designs are located in it. This information is necessary for interactive programs that allow users to create new font instances, and should be included in the font's s Adobe Multiple Font Metrics (\Lfn{AMFM}) file. \begin{figure*} \begin{minipage}{.5\textwidth} \centerline{\epsfig{file=mmdesign.eps,width=.8\linewidth}} \caption{Multiple master typeface design space arrangement} \label{fig:MMdesignspace} \end{minipage} \begin{minipage}{.5\textwidth} \centerline{\epsfig{file=mmfour.eps,width=.8\linewidth}} \caption{Arrangement of the multiple master design space for a four axis font} \label{fig:MMfouraxes} \end{minipage} \end{figure*} Fig.~\ref{fig:MMdesignspace} illustrates an example of the design space of a three axis multiple master font. In this example, the axes are \emph{weight}, \emph{width}, and \emph{optical} size. It is recommended that a font program be organized to have the lightest weight, narrowest width, and smallest design size mapped to the origin of the blend space. Multiple master coordinates are of two types: those which represent the design space and those which represent the blend space. Design coordinates are integers whose range for a particular typeface is chosen by the designer. They are used in font names and in the user interface for software which creates and manipulates multiple master font programs. The theoretical range for a weight or width axis is from 1 to 999 design units; however a typical typeface, with styles ranging from light to black, might have a dynamic range of from 200 (for light) to 800 units (for black). Another type of optional axis would be for optical size, in which the character design changes with the point size. The design coordinates for the optical size axis might have a dynamic range of from 6- to 72-point, which represents the practical extremes of sizes for typefaces designed for publishing purposes. \emph{Blend coordinates} are normalized values, in the range of 0 to 1, which correspond to the minimum and maximum design space coordinates. They are used by the Type~1 rasterizer because they are more convenient for mathematical manipulations. The linear space of blend coordinates is related to the (potentially) non-linear space of the design coordinates by the \Lit{BlendDesignMap} entry in the font dictionary. Fig.~\vref{fig:MMfouraxes} illustrates how a four axis design might be represented. An example of a fourth axis would be having an axis for a typographic style (serif/sans serif) or contrast (high/low: the ratio of thick to thin stem widths). This diagram illustrates that if four axes are defined, sixteen master designs are required. Also, since sixteen is the maximum number of designs allowed, there can be no intermediate designs with four axes. \section{Multiple Master Font Programs} Multiple master typefaces may contain from two to sixteen master designs, organized as having from one to four design axes. The maximum number of master designs allowed in a multiple master font is expressed by the equation \(2^n + x = 16\), where \(n\) is the number of design axes, \(x\) is the number of intermediate designs, and 16 is the maximum allowed number of master designs. The values used for calculating the weighted average are stored in the font dictionary in an array named \Lit{WeightVector}. The multiple master font program, as shipped by the font vendor, can have a default setting for the \Lit{WeightVector}; it is recommended that it is set so the default font instance will be the normal roman design for that typeface. \subsection{Multiple Master Keywords} \Lit{BlendAxisTypes} is a (required) array of \emph{n} PostScript language strings where \emph{n} is the dimensionality of the design space and hence the number of axes. Each string specifies the corresponding axis type. In the case of 3-axis example, this value would be: \begin{verbatim} /BlendAxisTypes [/Weight /Width /OpticalSize] \end{verbatim} \Lit{BlendDesignPositions} is a (required) array of \emph{k} arrays giving the locations of the \emph{k} master designs in the design space. Each location subarray has \emph{n} numbers giving the location of the design in the \emph{n} dimensions of the design space, with a minimum value of zero and a maximum value of one. Table~\vref{tab:MMdesign} with eight master designs is based on the example shown in Fig.~\vref{fig:MMdesignspace}. It corresponds to the design space for the Minion 3-axis multiple master font. \begin{table*} \centering \begin{tabular}{@{}l@{\qquad}l} \hline \emph{Design label} & \emph{Blend space coordinates} \\ \hline design 1: light condensed small & 0 0 0 \\ design 2: black condensed small & 1 0 0 \\ design 3: light expanded small & 0 1 0 \\ design 4: black expanded small & 1 1 0 \\ design 5: light condensed large & 0 0 1 \\ design 6: black condensed large & 1 0 1 \\ design 7: light expanded large & 0 1 1 \\ design 8: black expanded large & 1 1 1 \\ \hline \end{tabular} \caption{Design labels and blend space values for the Minion 3-axis multiple master font} \label{tab:MMdesign} \end{table*} The \Lit{BlendDesignPositions} array corresponding to this case is: \begin{verbatim} /BlendDesignPositions [[0 0 0][1 0 0][0 1 0][1 1 0] [0 0 1][1 0 1][0 1 1][1 1 1]] def \end{verbatim} \Lit{BlendDesignMap} is a required entry consisting of an array of \emph{n} arrays where \emph{n} is the dimensionality of the design space. Each array contains \emph{m} subarrays that describe the mapping of design coordinates into normalized coordinates for that design axis. The minimum value allowed for \emph{m} is two, and the maximum is twelve. The order of the subarrays corresponds to the order of design axes in \Lit{BlendAxisTypes}. In the case of the Minion font this array is three dimensional ($n=3$) and has the following form: \begin{small} \begin{verbatim} /BlendDesignMap [ [[345 0] [620 1]] [[450 0] [600 1]] [[6 0] [8 0.35] [11 0.5] [18 0.75] [72 1]] ] \end{verbatim} \end{small} The first number in an individual subarray is in design coordinates with a minimum value of 1 and a maximum value of 999. The second number in the subarray is in normalized coordinates, that is, in the range of 0 to 1. In the above example, the weight ranges from 345 to 620, while the width ranges from 450 to 600 in design space. The third axis, optical size, ranges from 6 to 72 (corresponding to the point sizes for which the typeface can be adjusted for optimal legibility). \subsection{The \texttt{makeblendedfont} Operator} \noindent\fbox{\textit{blendedfontdict weightvector} \textbf{makeblendedfont} \textit{blendedfontdict}} This operator creates a font dictionary with blended entries. The \textit{blendedfontdict} argument is a font dictionary of an existing multiple master font; it can be from either the original multiple master font itself, or from an interpolated font instance since any \Lit{Blend} dictionary contains all elements needed to derive additional font instances. The \textit{weightvector} argument is an array of numbers summing to 1.0 to be used as the weights for creating the new font instance. The value of \Lit{WeightVector} in \textit{blendedfontdict'} is set to the values in the array weightvector. Blended values are calculated for entries in the \Lit{Private} and \Lit{FontInfo} dictionaries. The result is a font dictionary that can be used as an argument to \Lit{definefont}. The resulting dictionary and its contents are still read-write, so the caller of \Lit{makeblendedfont} can make further modifications if necessary. The \Lit{Blend} dictionary data structures provide the information needed by the \Lit{makeblendedfont} operator, without needing to have the specific list of entries to be blended built into the procedure. This allows a single copy of the procedure to be used even if the set of entries to be blended varies in future fonts. \subsection{Multiple Master findfont Procedure} Multiple master font programs from Adobe include a procedure which redefines the \Lit{findfont} operator in \Lit{systemdict}. This is necessary because of the need to generate font instances on-the-fly to satisfy multiple master font references in a PostScript language document. The procedure creates all necessary font instances before calling the standard \Lit{findfont} procedure. Two procedures, \Lit{NormalizeDesignVector} and \Lit{ConvertDesignVector}, which are referenced in \Lit{findfont}, must be configured for the number of axes and master designs in the font program in which they are used. The \Lit{NormalizeDesignVector} procedure must calculate the normalized equivalent of the design coordinates in the FontName, using the values in the \Lit{BlendDesignMap} array. These normalized coordinates must be left on the stack for the \Lit{ConvertDesignVector} procedure. This procedure should take the normalized coordinates, generate \Lit{WeightVector} values, and leave them on the stack for the \Lit{makeblendfont} operator. \begin{figure*} \begin{small} \begin{verbatim} /y 140 def 300 100 700 % outer loop on width>>>>>>>>>>>>+ { /x 25 def % reset x v /y y 25 sub def % calculate y v /Wi exch def % width from for loop<<+ 220 100 820 % inner loop on weight>>>>>>>>>>>+ { x y moveto % go to new coordinate v /We exch def % weight from for loop<<+ /MM /MyriadMM findfont dup begin [ We Wi NormalizeDesignVector ConvertDesignVector ] end makeblendedfont definefont 20 scalefont setfont (Hxkp) show /x x 55 add def % recalculate x } for } for \end{verbatim} \end{small} \caption[PostScript code to instantiate a multiple master font]% {PostScript code for generating a a two-dimensional matrix showing instances of the multiple master font Myriad} \label{fig:minionprogram} \begin{minipage}{.5\textwidth} \centering\epsfig{file=myriad.eps,width=\textwidth} \caption[Two dimensional matrix showing multiple master Myriad font]% {Two dimensional grid showing various instances of the two axes multiple master Myriad sans serif font. } \label{fig:minionmatrix} \end{minipage} \begin{minipage}{.5\textwidth} \centering\epsfig{file=minion.eps,width=\textwidth} \caption[The three axes multiple master Minion serif font]% {The three axes multiple master Minion serif font. \begin{small}The top line shows various optical sizes (6pt, 8pt, 11pt, 18pt, 40pt, and 72pt) normalized to 20pt. The bottom matrix shows various weights (increasing from left to right) and widths (increasing from top to bottom).\end{small}} \label{fig:myriadmatrix} \end{minipage} \end{figure*} \section{Using Multiple master fonts with \TeX{}} Multiple master fonts come with a set of multiple master AFM files, which are called ``AMFM'' (Adobe Master Font Metrics) files. This file contains information about the number of master designs, the number of axes, the \texttt{BlendDesignPositions} and \texttt{BlendDesignMap} arrays, as well as the names, and \texttt{weightvector} for the master designs, from which all font instances are derived. To get the actual metric information for the characters in a font instance, one has to combine the metric information of the master designs (eight, in the case of Minion). To do this one needs to calculate the \texttt{weightvector} for the given instance. Starting from design-coordinate space one can use the \texttt{NormalizeDesignVector} operator to transform to the normalized coordinate space, and from there with the \texttt{ConvertDesignVector} operator one obtains the weightvector. These two operators are particular to a font (since they depend on the master designs), and are present in the multiple master font dictionary. One can decode the \PS{} code for calculating the weightvector and translate it into another computer language, and then use the procedure to combine the values in the AFM files for the master designs to calculate the values needed for the font instance. For instance, in the case of the MinionMM font, the \PS{} code defines the eight components of the weightvector as follows: \[ \begin{array}{ccc@{\quad}ccc} w_1 & = & x y z& w_2 & = & (1-x) y z \\ w_3 & = & x (1-y) z & w_4 & = & (1-x) (1-y) z \\ w_5 & = & x y (1-z) & w_6 & = & (1-x) y (1-z) \\ w_7 & = & x (1-y) (1-z) & w_8 & = & \sum_{n=1}^7 w_n \end{array} \] where $x$ is the normalized weight, $y$ the normalized width, and $z$ the normalized optical size. These eight numbers $w_i$ allow the calculation of all needed parameters in an \fn{afm} file for a font instance. One reads each parameter value in turn in the eight master design \fn{afm} files, applies the relevant weight, and the weighted sum thus obtained is the desired interpolated value of the given parameter for the font instance. Myriad is a sans serif companion font to Minion. It has two design axes and four master designs. The weights for deriving font-instance parameters in normalized coordinate space in function of the four master designs are given by: \[ \begin{array}{ccc@{\quad}ccc} w_1 & = & (1-x)(1-y)& w_2 & = & (1-x) y \\ w_3 & = & x (1-y) & w_4 & = & xy \end{array} \] where $x$ is the normalized weight and $y$ the normalized width. The corresponding mapping parameters between design space and normalized coordiantes are: \begin{verbatim} BlendDesignPositions [ [0 0] [1 0] [0 1] [1 1] ] BlendDesignMap [[[215 0][830 1]][[300 0][700 1]]] BlendAxisTypes [/Weight /Width ] \end{verbatim} Now one can extract any of the boundingbox and kern entries for a given font instance by getting the element in question from the eight (or four, in the case of Myriad) master files and calculating the interpolated value. To make matters simpler an explicit example will be given for the Myriad font, since it involves only four numbers in each case. Fig.~\vref{fig-Myriadcalculate-afm} shows some parts of the four master-design \fn{afm} files %% 1322 7802 26322 afm/MyriaMMLigCn.AFM %% 1322 7802 26322 afm/MyriaMMBlaCn.AFM %% 1322 7803 26489 afm/MyriaMMLigSemEx.AFM %% 1322 7803 26731 afm/MyriaMMBlaSemEx.AFM \begin{figure*} \begin{tiny} \begin{multicols}{4} \begin{verbatim} FontName MyriadMM-LightCn FamilyName Myriad MM Weight Light ItalicAngle 0 IsFixedPitch false FontBBox -52 -250 970 818 ... StartKernPairs 974 KPX A z 10 KPX A y -31 KPX A x 4 KPX A w -36 KPX A v -42 KPX A u -9 KPX A t -17 KPX A s 0 KPX A r -4 KPX A quoteright -90 KPX A quotedblright -90 KPX A q -9 KPX A p -4 KPX A o -12 ... EndKernPairs \end{verbatim} \newpage \begin{verbatim} StartFontMetrics 2.0 FontName MyriadMM-BlackCn FamilyName Myriad MM Weight Black ItalicAngle 0 IsFixedPitch false FontBBox -64 -250 970 843 ... StartKernPairs 974 KPX A z 10 KPX A y -10 KPX A x 0 KPX A w -10 KPX A v -10 KPX A u 0 KPX A t 0 KPX A s 10 KPX A r 0 KPX A quoteright -20 KPX A quotedblright -20 KPX A q 0 KPX A p 0 KPX A o 0 ... EndKernPairs \end{verbatim} \newpage \begin{verbatim} FontName MyriadMM-LightSemiEx FamilyName Myriad MM Weight Light ItalicAngle 0 IsFixedPitch false FontBBox -58 -250 1100 825 ... StartKernPairs 974 KPX A z 25 KPX A y -10 KPX A x 0 KPX A w -10 KPX A v -25 KPX A u -10 KPX A t 0 KPX A s -10 KPX A r 0 KPX A quoteright -30 KPX A quotedblright -30 KPX A q -10 KPX A p 0 KPX A o -10 ... EndKernPairs \end{verbatim} \newpage \begin{verbatim} FontName MyriadMM-BlackSemiEx FamilyName Myriad MM Weight Black ItalicAngle 0 IsFixedPitch false FontBBox -48 -250 1432 867 ... StartKernPairs 974 KPX A z 7 KPX A y -44 KPX A x -6 KPX A w -47 KPX A v -62 KPX A u -22 KPX A t -32 KPX A s -6 KPX A r -10 KPX A quoteright -90 KPX A quotedblright -90 KPX A q -18 KPX A p -10 KPX A o -18 ... EndKernPairs \end{verbatim} \end{multicols} \end{tiny} \caption{The four \fn{afm} files for the Myriad master designs} \label{fig-Myriadcalculate-afm} \centerline{\epsfig{figure=mmblowup.eps,width=.6\textwidth}} \caption{Minion instances from opposite ends of the optical size axis set at the same size (exaggerated)} \label{mmblowup} \end{figure*} When the instance \fn{afm} file has been created, a suitable metric for \TeX\ can be built with \Lit{afm2tfm} or the \emph{fontinst} package. \section{In practice} We have instantiated the ideas outlined above by developing Unix shell scripts, and adapting an AFM-parsing program distributed by Adobe. The main script takes the following actions: \begin{enumerate} \item create a small PostScript file to invoke multiple master operators with values passed to the script; \item run GhostScript on this file to derive normalized weights, and write them to a temporary file; \item run our ``mmafm'' program to read master AFM files, write a new instance AFM file, and create a \TeX\ metric (our initial setup uses \Lit{afm2tfm} to create 8r base-encoded metrics, and EC-encoded virtual fonts for actual use); \item write a \Lit{dvips} map entry and header file to tell the driver about the new font. \end{enumerate} Thus a call to our script consists of the parameters \texttt{MinionMM zmnl8ac6 360 460 6}; this creates a metric file called \Lit{zmnl8ac6}, using Karl Berry's scheme to name ``Minion, light weight, 8a-encoded, condensed, at 6pt design size''. The entry in the map file reads \texttt{zmnl8rc6 zmnl8ac6 " TeXBase1Encoding ReEncodeFont " <8r.enc zmnl8tc6 % <7-10>zmnl8tc8 % <10-15>zmnl8tc11 % <15->zmnl8tc18} {} \end{verbatim} The effect of the optical sizes is demonstrated by Fig.~\ref{mmblowup} which shows the 6pt and 18pt instances scaled to the same size. The differences in design are as apparent as a corresponding examples from Computer Modern would be. The tools we developed served to test the ideas, and build a set of metrics; they are available from us on request, but users should beware that they are neither intuitive in use, nor robust. It is to be hoped that a more functional, portable, solution will be developed in time. The keen \TeX xie may be interested in developing a \Lit{MakeTeXTFM} script for Unix \Lit{web2c} systems to apply the programs on the fly from within \TeX. \afterpage{\clearpage} \end{Article} \endinput