|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T p
Length: 48016 (0xbb90) Types: TextFile Names: »psfonts.tex«
└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12 └─⟦af5ba6c8e⟧ »unix3.0/DVIWARE.tar.Z« └─⟦ca79c7339⟧ └─⟦this⟧ »DVIware/laser-setters/dvi-to-ps/TeXPS/doc/psfonts.tex«
% Stream to read in the encoding vectors. \newread\EncStream % Current column you are working on. \newcount\ColumnCount % \ReadEnc % ======== % Read in an encoding vector and print it nicely. % #1: the file name of the file to read in. \def\ReadEnc #1{ \par \openin\EncStream = #1 \ifeof\EncStream \errmessage{\string\ReadEnc: can't read #1} \fi % Table begins here. \bgroup \edef\CollectLine{} \catcode`\#=12 % So you can read in #s from the file \tabskip = 0pt \small \ColumnCount = 0 \halign\bgroup \tt##\hfil \tabskip = 20pt& \tt##\hfil \tabskip = 40pt& \tt##\hfil \tabskip = 20pt& \tt##\hfil \tabskip = 40pt& \tt##\hfil \tabskip = 20pt& \tt##\hfil \tabskip = 0pt \cr \ReadEncTwo } % \ReadEncTwo % =========== % This is where we try to read in a line and % potentially decide on stopping the whole thing. \def\ReadEncTwo{% \read\EncStream to \ALine \def\partemp{\par}% \ifx\partemp\ALine % Done: empty line at the end. \let\ReadNext = \ReadEncThree \else \let\ReadNext = \ReadEncFour \fi \ReadNext } % \ReadEncThree % ============= % Call this one if you are done with the input. \def\ReadEncThree{% \crcr \egroup % \halign \egroup % The whole thing was inside a group. \closein\EncStream } \def\ReDefALine #1 #2\Del{\def\ALine{#1}} % Call this one if you have something. \def\ReadEncFour{% \expandafter\ReDefALine \ALine\Del \ifcase\ColumnCount \xdef\CollectLine{\ALine}% \let\dodo = \relax \or \xdef\CollectLine{\CollectLine&\ALine}% \let\dodo = \relax \or \edef\CollectLine{\CollectLine&\ALine\cr}% \let\dodo = \CollectLine \fi \dodo \ifnum\ColumnCount = 2 \global\ColumnCount = 0 \xdef\CollectLine{}% \else \global\advance\ColumnCount by 1 \fi \ReadEncTwo } \chapter{\protect\PS{} Fonts and \protect\TeX} % ============================================ \label{c-ps-fonts} \section{Introduction} % ==================== I will now discuss using \PS{} fonts in \TeX. Observe that \TeX{} does not make any distinction between different font types. All \TeX{} needs and cares about are {\tt TFM} files. So I will on one hand discuss how {\tt TFM} files for \PS{} fonts are generated. This is not the whole story though and I also have to discuss how certain information about the used \PS{} fonts is passed to the driver. \FigRef{f-data-flow}, \page{}, explains exactly what is going on: from a {\tt PFD} file (a text file containing information like which \PS{} font's {\tt TFM} and {\tt PFD} file should be generated) and a {\tt AFM} file the program {\tt pfd2tfm} generates a {\tt TFM} and a {\tt PDR} file. The {\tt TFM} file is read in by \TeX{} and the {\tt PDR} file is read in by the driver. \section{What are \protect\PS{} Fonts?} % ===================================== \PS{} printers, like for instance the Apple LaserWriter, have ``built in fonts'', where each character is stored in an outline format and not as a bitmap in part of the ROM of the printer. These fonts are called \PS{} fonts. The storage in outline form allows the usage of those fonts at arbitrary sizes, because the pixels patterns which are ultimately needed to print text with these characters are computed by the \PS{} interpreted in the printer. They are not loaded from some file on the host computer the printer is connected to. \PS{} fonts can be ``modified'' which means stretched, bent etc., as you will see in \SectionRef{s-helvetica-2}, \page{}, for examples. The programs described in this report allow \TeX{} to also access those variations of \PS{} fonts. There are also \PS{} fonts available which are {\it downloaded\/} from a diskete to the printer. After downloading these fonts they are identical to regular \PS{} fonts stored in the ROM of the printer. As far as our programs are concerned these \PS{} fonts do not require any special attention. \section{Available \protect\PS{} Typefaces and Fonts} % =================================================== The following typefaces are standard on all \PS{} printers. The fonts belonging to these typefaces are listed too; the Symbol font is not really a typeface by itself, but simply a font. Our discussion in the following for the most part will center around the fonts listed here because these are the fonts which are available on any \PS{} printer. \begin{enumerate} \item {\it Helvetica}. {\tt Helvetica}, {\tt Helvetica-Bold}, {\tt Helvetica-Oblique}, {\tt Helvetica-BoldOblique}. Examples are shown in \SectionRef{s-helvetica}, \page{}. \item {\it Courier}. {\tt Courier}, {\tt Courier-Bold}, {\tt Courier-Oblique}, {\tt Courier-BoldOblique}. For an example \see{s-courier}. \item {\it Times}. {\tt Times-Roman}, {\tt Times-Bold}, {\tt Times-Italic}, {\tt Times-BoldItalic}. See also \SectionRef{s-times}, \page{}. \item {\it Symbol}. {\tt Symbol}, \see{s-ps-symbol}. \end{enumerate} \section{Basic Characteristics of \protect\PS{} Fonts} % ==================================================== \PS{} fonts have character codes in the range of $[0\ldots255]$ whereas \TeX's pixel based fonts usually have only 128 characters. Characters in \TeX{} with character codes $\ge 128$ are only accessible with \TeX's \verb+\char+ primitive. The mapping of character codes to the characters to print is completely flexible and programmable when \PS{} fonts are used. A considerable part of the discussion in this chapter will center around exactly that question: which characters of \PS{} fonts are mapped to which character codes. The default encoding chosen in our programs follows the ASCII code and the encoding of \TeX{} assuming \MF{} based fonts as closely as possible. But it is not always possible to exactly simulate regular \MF{} based fonts. One reason for that is that there are many more characters in \PS{} fonts then there are in regular \MF{} based characters which have typically only 128 characters. The design size for \PS{} fonts as far as \TeX{} is concerned has been set to 10~pt because this is the design size of most of the \TeX{} fonts; \PS{} itself does not have the concept of a design size of a font. The design size can be changed with the {\tt DesignSize} command; \see{s-commands-pfd}. \section{{\tt AFM} Files} % ======================= \label{s-afm-files} For each \PS{} font Adobe, the ``company behind \PS'', provides an {\tt AFM} file which is a regular text file containing the metric information of \PS{} fonts. These {\tt AFM} files are available on the ARPAnet and also on diskettes. If you have ordered a cartridge containing this software here then the basic set of {\tt AFM} files can be found on the tape. There is a {\tt AFM} manual page which explains the structure of {\tt AFM} files. But even without this manual page the software is easy to understand. Our software requires the usage of {\tt AFM} files version~2.0. Version 1.0 {\tt AFM} files can not be used with our programs. The information about composite characters is the only information from {\tt AFM} files {\bf not} used by our programs and {\tt pfd2tfm} in particular. All the other information is used as you will see later. Certain parameters read in from the {\tt AFM} file can be overwritten by the user through instructions stored in the {\tt PFD} file. \See{s-commands-pfd}. Some printer's version of \PS{} fonts stored in their ROM is older than the the version~2.0 {\tt AFM} files might make you believe\footnote{This has {\bf nothing} to do with the {\tt AFM} file versions}. As a consequence some characters mentioned in the {\tt AFM} file may not be printable on your printer because of this version problem. In particular {\tt AFM} files contain the following information: \begin{enumerate} \item {\it Basic font information\/} like pitch, manufacturer, copy right, name, typeface font belongs to etc. \item {\it Character names\/} and {\it character codes\/}: in general characters in \PS{} fonts are identified by {\it character names\/} as, for instance, {\tt A}~for the character~``A'' or {\tt percent} for~``\%''). With the help of an {\it encoding vector\/} these names are mapped to character codes. As far as the relationship between character names and character codes in an {\tt AFM} file is concerned there are two different possibilities as the following two excerpts from an {\tt AFM} file show: \btex ... C 62 ; WX 584 ; N greater ; B 50 -10 539 474 ; C 63 ; WX 556 ; N question ; B 77 0 509 740 ; C 64 ; WX 1015 ; N at ; B 34 -146 951 740 ; C 65 ; WX 667 ; N A ; B 17 0 653 729 ; C 66 ; WX 667 ; N B ; B 79 0 623 729 ; ... C -1 ; WX 778 ; N Oacute ; B 38 -20 742 939 ; C -1 ; WX 778 ; N Ocircumflex ; B 38 -20 742 939 ; C -1 ; WX 778 ; N Odieresis ; B 38 -20 742 908 ; C -1 ; WX 778 ; N Ograve ; B 38 -20 742 939 ; C -1 ; WX 778 ; N Otilde ; B 38 -20 742 915 ; ... \etex Characters are called {\it characters with recommended character code\/} if there is a character code given after the~{\tt C} in the {\tt AFM} file. This recommended character code in {\tt AFM} files follows the standard ASCII encoding. In the above example we, for instance, see that character code~{\tt 64} is recommended for the greater sign. One calls characters {\it without recommended character code\/} if there is no such character code recommended. The character descriptions of those characters in the {\tt AFM} file start with~{\tt C~-1} (second block in the examples above). \item The {\it width\/} of characters. \item The {\it minimum bounding box\/} of a character, which is used to compute height and depth of the character information to be stored in the {\tt TFM} file. \item {\it Ligature\/} and {\it kerning\/} information. \item {\it Composite character\/} information; this is the only information stored in the {\tt AFM} file which is not by the {\it pfd2tfm\/} program. \end{enumerate} \section{{\tt PFD} Files and {\tt pfd2tfm}} % ========================================= A lot of the remaining part of this report contains a description of {\tt pfd2tfm}. There are two sources of input to {\tt pfd2tfm}: first of all a {\tt PFD} file (\PS{} Font Description) which contains information about with \PS{} font will be defined etc. This file in particular contains any information which changes the \PS{} font, for instance, to define a new encoding vector. The second source of input are {\tt AFM} files. This program generates two output files per \PS{} font. One is the {\tt TFM} file to be used by \TeX, and the other is the {\tt PDR} file to be used by {\tt dvitps} to print a document containing the specified \PS{} font. The {\tt PDR} file in particular contains the encoding vector for the \PS{} font and the necessary character width information. \section{Character Metrics} % ========================= \label{s-metrics} I will now discuss the handling of the character metric information itself. The character widths in an {\tt AFM} file are given in a coordinate system, where 1000 corresponds to the design size of a font. I use this unit in various cases---I call it ``{\tt AFM} file dimension unit''. The {\tt pfd2tfm} program is the central program when it comes to using \PS{} fonts in \TeX. It uses the information from the {\tt AFM} file to generate a {\tt TFM} file. Actually this process is performed in two steps: first a {\tt PL} file\footnote{{\tt PL} stands for ``property list''} is generated which is a textual representation of a {\tt TFM} file. This {\tt PL} file is converted into a {\tt TFM} file with the help of {\tt pltotf}. part of its job. In order to treat \PS{} fonts and pixel based fonts alike in the driver and also to be able to implement all the rules of {\tt dvitype} in the driver, in particular a maxdrift control it was decided to adjust the handling of \PS{} fonts to the handling of pixel based fonts as much as possible. An immediate consequence of this is that all characters of \PS{} fonts must have a width which is an integer multiple of the resolution of the printer. This requires the usage of a width vector with \PS{} fonts which is the only way to force certain character widths onto the \PS{} interpreter in the printer. This way all movements by the printer (whether it is a ``pure'' movement or a movement caused as side effect of printing a string is irrelevant) are in integer pixels. The \PS{} interpreter in the printer will do no rounding of positions, and the driver knows the current position in the \PS{} interpreter at all times. This width vector can be eliminated using the {\tt -w} option of {\tt dvitps}. This option was introduced because adding a width vector to \PS{} fonts increases the amount of virtual memory needed in the \PS{} printer considerably: {\bf with} width vector each \PS{} font requires about 13kB of VM, {\bf without} it about 7kB; that's almost a ratio of 1:2 \footnote{If there is any complaint to be made about the Apple LaserWriter then it is the fact that its virtual memory is much too small---otherwise the printer is extremely reliable and produces good quality output. The situation is much better with the newer LaserWriter~II series.}! \section{Determining Character Codes} % =================================== \label{s-comp-char-codes} In the section about {\tt AFM} files (\SectionRef{s-afm-files}, \page{}) it was already explained that an encoding vector is needed to map character names to character codes. I will now explain how {\tt pfd2tfm} determines character codes. For that purpose, so called {\it default character code classes\/} were defined. The {\it character name\/} is the name of the character as defined in the {\tt AFM} file. The rules of this game can be described as follows: \begin{enumerate} \item Instructions in the {\tt PFD} file have precedence over all other assignments. These instructions are described in detail in \ItemRef{i-enc-changes} of the list on \page{}. Instructions in the {\tt PFD} file allow the user to \begin{enumerate} \item Request specific character codes for specific character names. See the {\tt MapChar} instruction in {\tt PFD} files. \item Eliminate certain characters (identified by their names) from the encoding vector. See the {\tt ExcludeChar} instruction of {\tt PFD} files. \end{enumerate} \item Next in the hierarchy is a {\it default character code vector}. The user has the possibility of using no ``default vector''. \See{s-defaults-evs}, for details. {\tt pfd2tfm} will check the default vector for an entry, and in case there is an entry the value of this entry will be used as character code. \item Last but not least the value in the {\tt AFM} file is used. \begin{enumerate} \item In case the character is a character with recommended character code this code is used. There are two possibilities now: \begin{enumerate} \item If the recommended character code is free, i.e.~the character code requested is not used by another character, everything is ok. \item The recommended character code is already used by some other character. A warning is printed and the character is dropped and therefore can not be printed. \end{enumerate} \item If the character is without recommended character code ({\tt C~-1} in the {\tt AFM} file) the character is simply ignored after a warning has been printed. The character therefore can not be used. \end{enumerate} \end{enumerate} \section{Default Character Code Vectors} % ====================================== \label{s-ev} I already mentioned in the previous section default character code vectors. We will look into them more closely now. The \PS{} Symbol font is not discussed here because for every character in this font a particular character code is recommeded in the {\tt AFM} file and therefore there is no reason to resort to any type of default constructs. \subsection{Default Character Codes Vector Classes} % ================================================= \label{s-defaults-evs} There are three default character code classes~0, 1 and~2. The {\it default character code vector class\/} is determined as follows: use class~0 unless a prefix of the basename of the font to be computed can be found in the file {\tt DefClasses}. In this case the entry in this file determines the class. Class~$-1$ means that no default vector is supposed to be used. For instance, the default encoding vector for Helvetica is~0, for Courier-Oblique is~1 etc. The file {\tt DefClasses} which defines the selection of the proper encoding vector class reads as follows: {\VerbatimTab = 8 \ListVerb{DefClasses.xxx}} When designing those three default encoding vector classes our philosophy was to {\bf not} map characters into character positions in the range [0\dots127] which do not match the standard encoding of \TeX, but to leave these positions free. An example for this is the dotless~j which is available in regular \TeX{} tex fonts but in none of the \PS{} fonts. The dotless~j can be normally found at position~`021. This character position is therefore unused when a \PS{} font like Times-Roman is used in \TeX. Out of the same reason character positions '000 to '012 in regular \TeX{} fonts occupied by a selected set of capital greek letters are left blank. Here is the list of three default encoding vectors. \begin{enumerate} \item Default character code class~0 is used for the Helvetica and Times-Roman fonts. It is not used for the Courier fonts. It can be found in \TableRef{t-enc-def-0}, \page{}. \item Default encoding vector~1 used for the Courier fonts can be found in \TableRef{t-enc-def-1}, \page{}. \item Default encoding vector~2 can be found in \TableRef{t-enc-def-2}, \page{}. \end{enumerate} \begin{table} \caption{Default encoding vector 0} \label{t-enc-def-0} \bigskip \ReadEnc{EncDef-0.ev} \end{table} \begin{table} \caption{Default encoding vector 1} \label{t-enc-def-1} \bigskip \ReadEnc{EncDef-1.ev} \end{table} \begin{table} \caption{Default encoding vector 2} \label{t-enc-def-2} \bigskip \ReadEnc{EncDef-2.ev} \end{table} \subsection{The Difference between Classes~0 and 1} % ================================================= Here I will briefly reprint the output of {\tt diff} on the two previously listed default character code vectors. This way you can see easily the difference between the two vectors {\VerbatimTab = 8 \ListVerb{EncDiff.tex}} \subsection{Changing Default Encodings} % ===================================== Let me discuss here what you should do in case you don't like the default encodings listed before. \begin{enumerate} \item First of all do {\bf not} change the listed defaults. You would destroy any compatability between a document generated at your site and at some other site. \item Solution~1 is to use instructions like {\tt MapChar} and such to change the mapping from within a {\tt PFD} file. \item Solution~2 is to really add new default vectors. To do so you have to go through the following steps: \begin{enumerate} \item Add a new default encoding code vector class. Go into {\tt pfd2tfm/src/free.c}. \item Put the new encoding vector into {\tt pfd2tfm/evs}, change {\tt IMakefile} and install the new vector. \item Use the {\tt EncodingClass} command in your {\tt PFD} file to set the default encoding vector class to the desired value for an encoding class. Use a non standard name for the {\tt PFD} file you will use. \end{enumerate} \end{enumerate} \section{Font Emulation} % ====================== \label{s-font-emulation} In \SectionRef{s-metrics}, \page{}, it was pointed out that a {\it width vector\/} is downloaded with each \PS{} font to force the width of each character to be an integer multiple of the resolution of the printer used. This feature can be missused in the following sense: first of all arbitrary widths could be downloaded, widths which have nothing to do with the width of the characters. While this is more of an intellectual exercise it does have a useful application in the case of font emulation. First of all: what is font emulation? Assume your prepare a document with the final output to appear on a photo typesetter. You would like to use the fonts of the phototypesetter (i.e.~you have been provided with {\tt TFM} files of those fonts). For proofreading you would like to use your local laser printer for which you have {\bf no} pixel files of the phototypesetter fonts. But you want to have the exactly same layout of the output using your laser printer because you want to ensure the same line breaks, you want to check on the hyphenation etc. In font emulation I will show how a \PS{} font can be used to print a text using a font for which no pixel file is available. Of course, one of the selling arguments of \PS{} and its fonts is that tricks like that are not necessary if a \PS{} laser printer and a \PS{} phototypesetter is used. When a font is emulated (for this font a {\tt TFM} file must be available) then a font which is used for the emulation must be specified. The way the programs are currently set up this font must be a \PS{} font. This could be changed so that pixel file based fonts could be also used for emulation. The implementation of font emulation is rather straight forward: instead of retrieving the font width information from the {\tt AFM} file to build the {\tt TFM} and {\tt PDR} file of the font, the width information is retrieved from another {\tt TFM} file and literally forced onto the \PS{} font which is used for the emulation. For an example \see{s-emul-ex}. The output of a font emulation looks pretty ugly because the widths of the characters in the two fonts don't match quite. But now this font can be used to check the output of another font. One more thing should be pointed out here: the font being used for emulation may have characters at certain character codes not defined but the same characters are defined in the font being emulated. In this case a black box of about the size of the character which is undefined in the emulation font is printed. \section{\protect\PS{} Procedure Characters} % ========================================= \label{s-ps-proc-chars} The driver allows the user to execute some arbitrary \PS{} procedure at a character position instead of just printing a \PS{} character. The \PS{} procedures then invoked for those characters are defined in the {\tt PFD} file. These \PS{} procedures can be pretty arbitrary but there are some rules which I will discuss now. \subsection{Motivation} % ===================== This extension to the whole set of programs, introduced at a rather late stage, was motivated by the following: when font emulation is used then it is a very nice feature to be able to print ligatures of the font being emulated correctly by the emulating font, despite the fact that the emulating font has no ligature or at least not the ligature needed in the first place. In such case one can use the following ideas to simulate a ligature with the help of a little \PS{} procedure. \subsection{Setting Things Up} % ============================ The user has to provide the following information when such a \PS{} procedure is defined: \begin{enumerate} \item A \PS{} code class: as of now there is only one class~0. The idea here is that one could extend the programs and make different assumptions about the \PS{} procedures. \item The character code for which the \PS{} procedure has to be executed. There is no character name for those characters. \item The height, depth and width of that ``pseudo character'' so that information can be written to the {\tt TFM} file. \item The procedure to be executed. \end{enumerate} \subsection{\protect\PS{} Code Class 0} % ===================================== Here briefly an example and some more details for \PS{} code class~0. No other classes have been defined so far. Obviously I can not prevent people from totally misusing this feature and writing \PS{} code which makes ``global changes'' etc. You should follow the guidelines below, and you should be save: \begin{enumerate} \item The \PS{} procedure associated with a particular character will be defined by a name chosen by the driver during the execution of pass~0 of each page in the driver. This name is then used to invoke this character's function in pass~1 of each page of the driver. The name for the procedure is assigned as follows by the driver (what follows is a short C~statement): \verb+sprintf(buffer, "@F%d==%o", fn, cc);+ where {\tt fn} is the font number and {\tt cc} is the character code. See {\tt driver/src/pdr.c} for details. \item The \PS{} procedure should assume the regular \TeX{} coordinate system: x-axis goes to the right, and the y-axis goes {\it down}. The unit in this system is {\tt AFM} units in other words 1000 corresponds to the design size of the font (which is usually 10~pt). \item The \PS{} code as net effect should move to the right by {\tt Move-X} which is a value in pixels where the driver assigns the proper amount. This is normally achieved by enclosing the whole \PS{} procedure inside a pair of {\tt currentpoint} and {\tt moveto} followed by ``{\tt Move-X~0 rmoveto}''. \item Inside the procedure a \PS{} procedure {\tt Convert-Afm-To-Pixels} can be called which converts a dimension (in {\tt AFM} units) which is pushed on the stack into pixels (leaving the result on the stack). \item The \PS{} procedure body itself should {\bf not} be enclosed inside curly braces. \end{enumerate} The following is an example for such a \PS\ procedure. In \SectionRef{s-execps-ex}, \page{}, you find a more detailed example. {\VerbatimTab = 8 \btex % Code 0: print "#" and "paragraphsign" (8#266) on top of each other. ExecPsCode 0 8#000 500 673 17 "currentpoint % This is the way PS procedures % normally start for ExecPsCode. currentpoint (#) show moveto (\266) show moveto % This is the way these procedures Move-X 0 rmoveto"; % normally end. % Code 1: print a small square ExecPsCode 0 1 500 400 000 "currentpoint 100 Convert-Afm-To-Pixels 0 rmoveto % 100 to the right currentpoint newpath moveto 300 Convert-Afm-To-Pixels 0 rlineto % 300 right 0 -300 Convert-Afm-To-Pixels rlineto % 300 up -300 Convert-Afm-To-Pixels 0 rlineto % 300 left closepath fill % makes square moveto Move-X 0 rmoveto"; \etex } \subsection{\protect\PS{} Procedures with Font Emulation} % ======================================================= Observe that if \PS{} procedure characters are used in the connection with font emulation ({\tt EmulateFont}) then the height, depth and width parameters still have to be given. I recommend to set them to zero in the input because their values are overwritten by the size information found in the {\tt TFM} file of the font being emulated. \section{Setting Things Up for \TeX} % ================================== The process of making \PS{} fonts available under \TeX{} consists of the following steps: \begin{enumerate} \item {\it Define various font parameters\/}: if the \PS{} fonts are used without modifications, then this step is trivial. But the user is, for instance, allowed to define his own encoding vector (in other words the user has complete control over which character appears at which position of the font map). The default follows the encoding of \TeX{} as closely as possible. The information about which \PS{} font is to be used, which encoding is to be assigned, etc. is stored in a {\tt PFD} file where {\tt PFD} stands for \underbar{\sc P}{\sc ostScript} \underbar{f}ont \underbar{d}efinition. This is a regular text file. The font metric information itself is derived from the {\tt AFM} file specified in the {\tt PFD} file. To use the \PS{} fonts {\tt Helvetica} one generates the following simple {\tt PFD} file called {\tt PS-Helvetica.pfd}: \btex StartPfd; BaseFontName "Helvetica"; EndPfd; \etex The choice of the prefix {\tt PS-} is arbitrary, but it is a convention which is used throughout the whole software and this documentation. It is recommended that this convention is followed. \item {\it Execute the program\/} {\tt pfd2tfm} ({\tt pfd2tfm PS-Helvetica.pfd} in our example): this program reads the user's {\tt PFD} file and the specified {\tt AFM} file. The program will generate two files: \begin{enumerate} \item A {\tt TFM} file which can be accessed by \TeX. \item A {\tt PDR} file (\underbar{p}rinter \underbar{d}river file). This file can be read by the driver. \end{enumerate} \item {\it Install the font files} so that \begin{enumerate} \item \TeX{} can access the {\tt TFM} file. \item The driver can access the {\tt PDR} file. \end{enumerate} \item {\it Generate a \TeX{} document and access \PS{} font\/}: to use the \PS{} fonts simply use the \verb+\font+ instruction of \TeX. Here is a short example using the font we generated in the above example. \btex \font\helvetica = PS-Helvetica \helvetica This is some text printed in Helvetica. \etex \item {\it Run \TeX}. At this point \TeX{} will access the previously generated {\tt TFM} file. \item {\it Run the driver\/} to convert the {\tt DVI} file into a \PS{} file. At this point the driver will access the previously generated {\tt PFD} file. \item {\it Print\/} \PS{} {\it file}. A spooler is invoked to print the \PS{} file on a \PS{} printer. \end{enumerate} \section{{\tt PFD} Files} % ======================= \label{s-pfd-files} \subsection{General Remarks} % ========================== The user has to provide information in a {\tt PFD} file (\PS{} font description file) as already outlined before. {\tt PFD} files are regular text files. I will now give a complete description of those files (what follows is a very loose description of a little programming language). I should point out here that as far as \TeX{} is concerned you are not able to specify something like ``load font Helvetica with the following encoding vector''. Instead you must prepare a {\tt TFM} file which can be loaded by \TeX{} with a simple \verb+\font+ instruction. The choice of a clever name for the {\tt TFM} file hopefully allows you to still remember what font you precisely specified. If you are not interested in any modifications, then the following discussion is probably of little interest to you, and you can use short {\tt PFD} files as one was just recently shown. The {\tt PFD} files are written on a statement by statement basis with the semicolon as separator. The name of the {\tt PFD} file determines the names of the {\tt TFM} and {\tt PDR} files. The name is the same, only the extension is changed. Here some remarks for the following instructions: \begin{enumerate} \item \angt{string}s are enclosed in quotes, \angt{name}s are not. \angt{character name} is a \angt{name}. \item \angt{real}s are written the way you expect them---with or without decimal point. \item \angt{integer}s are also written the way you expect them. Numbers can also be entered in octal format (\verb+8#...+) or in hexadecimal format (\verb+16#...+). The format is the same as in \PS. \angt{character code} is an integer in the range [0\dots255]. \item Dimensions are specified in two different ways: \begin{enumerate} \item \angt{\TeX{} dimen}. \TeX{} like dimension, in {\tt pt}. No other unit is possible, also the unit {\tt pt} must be present. \item \angt{AFM dimen}. The coordinates in {\tt AFM} files are based on 1000. Such a dimension is used in the specified cases. No dimension unit! \end{enumerate} \item \verb+%+ is a comment character as it is in \TeX---everything up to the end of line is ignored. \end{enumerate} \subsection{Commands In {\tt PFD} Files} % ====================================== \label{s-commands-pfd} Here are the commands which can be used in a {\tt PFD} file. \begin{enumerate} \item \underline{Start / End Instructions}. \begin{enumerate} \item {\tt StartPfd ;}\\ Must be the first instruction in a {\tt PFD} file. \item {\tt EndPfd ;}\\ End of the {\tt PFD} file. As of now {\tt PFD} files can contain only the description of one font. It would be possible to extend the programs so more than one font can be described in a {\tt PFD} file. This would require an additional instruction to name {\tt TFM} and {\tt PDR} files. \end{enumerate} \item \underline{General Instructions}. \begin{enumerate} \item\label{i-base-font-name} {\tt BaseFontName} \angt{string} {\tt ;}\\ One of the \PS{} fonts, i.e.{} Helvetica, Helvetica-BoldOblique, \dots, Courier, \dots, of which the new font is to be derived. Field must be present, no default. \angt{string} is the file name of the {\tt AFM} file {\tt pfd2tfm\/} will use to find the {\tt AFM} file (after the extension {\tt AFM} has been appended). \item {\tt DesignSize} \angt{\TeX{} dimen} {\tt ;}\\ The design size which by default is 10~pt can be changed with this instruction. \item {\tt HRatio} \angt{real} {\tt ;}\\ Ratio of height versus width. 1.0 is the default. 2.0~gives characters twice as high as they are wide, 0.5~gives characters, which are half as high as usual characters. The width never changes, only the height is adjusted. For an example \see{s-helvetica-2}. \item {\tt WidthDelta} \angt{AFM dimen} {\tt ;}\\ The given dimension is added to the width of each character. The default is~0. \item {\tt TiltAngle} \angt{real} {\tt ;}\\ \angt{real} determines, how much characters are tilted to the left or right. The default is~0.0. Positive tilting means tilting to the right, as it is used in section~9.3 (page~96) of \bref{POSTSCRIPT 85a}. \item {\tt NoAfmKernings ;}\\ Ignore all kerning information found in the {\tt AFM} file. The default is obviously to use this information from the {\tt AFM} file. \item {\tt NoAfmLigatures ;}\\ Ignore all ligature information found in the {\tt AFM} file. The default is obviously to use this information from the {\tt AFM} file. \item {\tt InvisibleSlitexFont ;}\\ It's an invisible font which can be used with Sli\TeX. See the \LaTeX{} book about it. \item {\tt OutlineFactor} \angt{real} {\tt ;}\\ Make an outline character with the factor determining how thick the outline is. A factor of 0.0 would generate invisible characters, 1.0 would create an un-outlined full character, i.e.{} the original one. The default is 1.0. Outline fonts are {\bf not} implemented yet. \item {\tt MonoCase} \angt{real} {\tt ;}\\ In case a mono-case font is desired, this value is the ratio of the height of lower case capital characters compared with upper case capital characters. A good starting point is 0.6. The value of 0, which also is the default, generates an ordinary font (with lower and upper case letters). Monocase fonts are {\bf not} implemented yet. \end{enumerate} \item \underline{Instructions to set {\tt\string\fontdimen} parameters} (the names of the following commands are derived from the output of {\tt tftopl}, a program, which converts {\tt TFM} files into property lists ({\tt pl} files)): \begin{enumerate} \item {\tt Slant} \angt{afm dimen} {\tt ;}{} {} (\verb+\fontdimen 1+)\\ Sets the slant to the given value, default is 0. \item {\tt Space} \angt{afm dimen} {\tt ;}{} {} (\verb+\fontdimen 2+)\\ Sets the amount of interword space (see also {\tt Stretch}, {\tt Shrink}) to the given value. The default is the width of the space character (character code {\tt '40}) as it is stored in the {\tt AFM} file. \item {\tt Stretch} \angt{afm dimen} {\tt ;}{} {} (\verb+\fontdimen 3+)\\ Sets the amount of interword space can stretch. The default for fixed-pitch fonts is zero; for proportionally spaced fonts it is half of the width of the space character (character code {\tt '40}). \item {\tt Shrink} \angt{afm dimen} {\tt ;}{} {} (\verb+\fontdimen 4+)\\ The interword space shrink. The default for fixed-pitch fonts is zero, for proportionally spaced fonts it is a third of the width of the space character (character code {\tt '40}). \item {\tt XHeight} \angt{afm dimen} {\tt ;}{} {} (\verb+\fontdimen 5+)\\ The x-height is normally taken directly from the {\tt AFM} file, but the user can overwrite the value with this instruction. \item {\tt Quad} \angt{afm dimen} {\tt ;}{} {} (\verb+\fontdimen 6+)\\ How much is a quad. The default is 1000 (10~pt). \item {\tt ExtraSpace} \angt{afm dimen} {\tt ;}{} {} (\verb+\fontdimen 7+)\\ The amount of extra space added after a period ending a sentence. \item {\tt FontDimen} \angt{number} \angt{AFM dimen} {\tt ;} (\verb+\fontdimen+ \angt{number})\\ Set the font dimension parameter \angt{number} to the given dimension. This allows the user to define all the other font parameters (there are up to 22, see the \TeX{} Book for details). \angt{number} must be~$\ge 8$ in this case. \end{enumerate} \item\label{i-enc-changes} \underline{Encoding Vector Changes}:\\ For details \see{s-ev}. {\tt EncodingClass} \angt{number} {\tt ;}\\ This command defines the character code vector class which is used instead of the default determined by {\tt pfd2tfm}. How the default encoding vector class is found by default can be found in \SectionRef{s-defaults-evs}, \page{}. Now the list of commands used to change the encoding vector: \begin{enumerate} \item {\tt MapChar} \angt{character name} \angt{character code} $\lbrace$ {\tt ,} \angt{character name} \angt{character code} $\rbrace^*$ {\tt ;}\\ This instruction allows you to specify a specific character code \angt{character code} for the character with name \angt{character name}. If you try to map a character to a position which is used by a character code definition of the {\tt AFM} file then you must exclude that character first by using the {\tt ExcludeChar} instruction which follows below. \item {\tt ExcludeChar} \angt{character name} $\lbrace$ {\tt ,} \angt{character name} $\rbrace^*$ {\tt ;}\\ Exclude the character with name \angt{character name} from the encoding vector. \end{enumerate} \item \underline{Other instructions}: \begin{enumerate} \item {\tt ExecPsCode} \angt{type} \angt{character code} \angt{width} \angt{height} \angt{depth} \angt{ps code}\\ Execute \PS{} code. It is possible with this instruction to tell the driver to execute directly some \PS{} code. The parameters are: \begin{enumerate} \item \angt{type}. An integer describing the type of the \PS{} procedure which follows. As of now only one type (type~0) is defined. \item \angt{character code}. The character code for which the \PS{} procedure is executed. \item \angt{height}, \angt{depth}, \angt{width}. Height, depth and width of the symbol defined with the help of this procedure. \item \angt{ps code}. \PS{} code to be executed for this procedure. \angt{ps code} is a \angt{string}. \end{enumerate} There are a couple of additional details to observe; \see{s-execps-ex}, for an example. This example shows how you have to account for the horizontal movement after such a \PS{} procedure has executed. \item {\tt TeXMacroDefs} \angt{number} \angt{string} {\tt ;}\\ \angt{string} is the file name of a file which will contain the names of all \TeX{} macro definitions to load any of the special characters. \angt{number} controls which definitions are written to this file. If the number is~0, only those definitions appear in the file, for which our program assigned the code (these characters, with original character code~$-1$ in the {\tt AFM} file are marked by an asterisk in our tables; see, for instance, \FigRef{t-PS-Helvetica.pdr}, \page{}). If the number is~1, definitions for {\bf all} characters will be written to the specified file. This is, for instance, very useful for the Symbol font (see, for instance, \FigRef{t-PS-Symbol.pdr}, \page{}): this file allows the user to conveniently access all characters of this font. For an example see the reprint of file {\tt PS-Helvetica-2-mac.tex} on \page{ps-helvetica-2-mac}. \item {\tt ChangeWidth} \angt{character name} \angt{afm dimen} {\tt ;}\\ Overwrites the width of character \angt{character name} as specified in the {\tt AFM} file by the width in \angt{afm width}. \item {\tt EmulateFont} \angt{name} {\tt ;}\\ The font specified with {\tt BaseFontName} emulates another font \angt{name}. Each character in the font being generated inherits the font metric information from the font \angt{name} by accessing \angt{name}{\tt .tfm}. Font emulation is discussed in \SectionRef{s-font-emulation}, \page{}. \item {\tt KPX} \angt{name$_1$} \angt{name$_2$} \angt{afm dimen} {\tt ;}\\ Change the kerning between the two characters \angt{name$_1$} and \angt{name$_2$}. The instruction is identical to the {\tt KPX} instruction in {\tt AFM} files. \item {\tt Ligature} \angt{name$_1$} \angt{name{$_2$}} \angt{name$_{lig}$} {\tt ;}\\ This is the user's way to add ligature definition: define a new ligature \angt{name$_{lig}$}, if character \angt{name$_1$} is followed by \angt{name$_2$}. \end{enumerate} \end{enumerate} \section{{\tt PDR} Files} % ======================= \subsection{Introduction} % ======================= I will now describe the {\tt PDR} file format. These files are read in by the driver when a \PS{} font is accessed. There is one {\tt PDR} file for each \PS{} font defined by the user. These {\tt PDR} files contain information like the encoding vector, the width of characters, any modifications to the fonts in general (like stretched out characters) and other things. Here is a short description. The way the file format is described here, resembles very much the way all other file types in the context of \TeX\ are described: {\tt k[2]} means a two byte long value {\tt k}. Some numbers are considered to be 32 bit signed numbers with the ``binary point'' at the 20th bit. I abbreviate this number format as {\tt b32.20}. In other words: to get the value of a number $a$, divide $a$ by $2^{20}$. {\tt PDR} files are broken up into two parts: the preamble is followed by the encoding vector and width information. \subsection{The Preamble of {\tt PDR} Files} % ========================================== The preamble has the following format: \begin{center} \it fid[2] le[1] bna[l] cs[4] hcc[2] ds[4] sp[4] a[4] b[4] c[4] d[4] t$_x$[4] t$_y$[4] o[4] mc[4] em[1] sli[1] lec[1] \end{center} \begin{enumerate} \item {\it fid}. File id. This value is changed in every release. \item {\it le}. Length of the following basename $bna$. \item {\it bna}. The basename is the name of the \PS{} font, on which the current font is built. \item {\it cs}. The checksum. \item {\it hcc}. The highest character code in this font, either 127 or 256. \item {\it ds}. The design size of the font. \item {\it sp}. The space factor. \item {\it a}, {\it b}, {\it c}, {\it d}, $t_x$ and $t_{y}$. These factors describe the transformation matrix, as it can be found, for instance, on page~65 of \bref{POSTSCRIPT 85b}. The numbers are given in the {\tt b32.20} format. \item {\it o}. Outline factor in the {\tt b32.20} format. This number is unused as of now. \item {\it dl}. True for downloadable fonts. \item {\it em}. 1~for an emulation font. 0~means it is a regular font (not emulation). \item {\it mc}. Mono-case factor in the {\tt b32.20} format. If the value is 0 then a regular font with lower and uppercase letters is chosen. In case the value is non-zero it gives the factor by which the height, width and depth of ``upper case letters'' has to be multiplied in order to find the height, width and depth of the small printings of those letters for lower case letters. This information is unused as of now. \item {\it sli}. \SLITEX{} invisible font. 0~is the default for regular fonts; 1~means that the font is an invisible \SLITEX{} font. \item {\it lec}. The length of the encoding array, {\it not\/} the number of bytes, but how many elements it contains. \end{enumerate} \subsection{The Encoding Array in {\tt PDR} Files} % ================================================ Each element of this array consists of information about a specific character code, the name of the character and the width of the character. There is at most one entry per character code. The input does not have to be sorted by character code. For each character we have an entry of five elements (observe that in general different elements are of different lengths): \par\centerline{\it cc[1], inf[1], inf2[1], wd[4], ls[2], st[ls]} \begin{enumerate} \item {\it cc\/} is the character code. \item {\it inf\/} is a code revealing information about the character: \begin{enumerate} \item {\tt 0}: assigned character; the character code of this character was derived from the {\tt AFM} file. \item {\tt 1}: unassigned character. This character's character code was assigned by {\tt pfd2tfm}. See also item~\ref{i-inf2} of this list. \item {\tt 2}: \PS{} procedure character. \item {\tt 3}: there is no character to be printed. Instead only some width information is available. This is for the case where a character is not defined in the \PS{} font but it is defined in the font being emulated. The driver needs to know the width information so it can print a black box instead of the character. \end{enumerate} \item\label{i-inf2} {\it inf2}. This code is normally unused with the exception of \PS{} procedure characters in which case it contains the \PS{} procedure character type (first parameter of the {\tt ExecPsCode} command). When unused its value is zero. \item {\it wd\/} is the width of the character (identical to the width given in the {\tt TFM} file, i.e.\ in {\tt fixes}). This duplication is not really necessary---I could just as well have accessed the {\tt TFM} file of the font. But that would have meant another file access and so I decided to store the information into this file. \item {\it ls\/} is the length of the following string {\it st}. This value is zero for character with {\it inf\/}~$=3$. \item {\it st\/} is a string. For {\it inf\/}=~0 and~1 it is the name of the character for instance {\tt /circumflex}. Observe that the ``{\tt /}'' is included in the string. For {\tt inf} value~2 (\PS{} procedure character) this is the \PS{} procedure for this character. This string is missing for {\it inf\/}~$=3$. \end{enumerate} \subsection{Font Matrix} % ====================== The transformation matrix contained in the {\tt PDR} file is normalized: for unrotated and unbent fonts this matrix is simply $[1\ 0\ 0\ 1\ 0\ 0]$. The transformation matrix for the \PS{} fonts must accommodate for the global as well as the font magnification. For simplicity I wil now use the {\tt scalefont} operator. The factor sent down with this operator determines the size in the currently valid unit. If the initial transformation matrix is used, then this means {\tt bp} (big points), which are almost points. Our coordinate system is already converted to pixels, and that is, what has been sent down. Define $d\over s$ as the font magnification. This stands for the multiple at which the font is used. Including the global magnification this would be $M = {mag\over 1000} * {s\over d}$. You know that the design size of such fonts is 10~pt. 10~pt on the other hand is ${10\over 72.27}$ inches, which in turn is ${10\over72.27} * Resolution$ pixels. In other words the factor one have to use is $M * {10\over 72.27} * Resolution = {mag\over 1000} * {s\over d} * {10\over 72.27} * Resolution$.