<<

A PostScript Installation Package Written in TEX

Alan Jeffrey School of Cognitive and Computing Sciences University of Sussex Falmer Brighton BN1 9QH UK Internet: a1 an jeecogs. susx.ac. uk

Abstract Ths paper describes a font installation package written entirely in TEX. It can parse Adobe Font Metric and Font Encoding files, and convert them into Prop- erty List and Virtual Property List files, for processing with pltotf and vptovf. Since it is written in TEX, it is very custornizable, and can deal with arbitrary font encodings, as well as mathematics .

Introduction The most important difference between ths package and other PostScript font installation packages (such This paper describes fonti nst version 0.19, a pro- as Rokicki's (1993) afm2tfm, used in Rahtz's (1993) totype font installation package for PostScript fonts psnfss) is that it is written in TEX rather than C, (or any other fonts with font metrics given in Adobe and so can be more easily customized by the user to Font Metric format). This package: deal with non-standard encodings and mathematical Is written in TEX, for maximum portabhty (at fonts. At the moment, only the T1 (Cork) encoding the cost of speed). is supported, but mathematical fonts will be added Supports as much of the Cork encoding as once an 8-bit font standard can be agreed upon. possible. Allows fonts to be generated in an arbitrary Usage encoding, with arbitrary 'fake' characters, There are four ways to generate fonts using the for example, the 'ij' can be faked if fonti nst package: necessary by putting an 'i' next to a 'j'. The simplest method to install the 'varda' Allows caps and small caps fonts with letter fonts (Times, and ) with spacing and . the T1 (Cork) encoding is to run TEX on Allows kerning to be shared between fontvani . . characters, for example, 'ij' can be kerned If you want to install other TI fonts, you can on the left as if it were an 'i' and on the edit fontvani . tex to create a TEX file which right as if it were a 'j'. This is useful, installs your fonts. since many PostScript fonts only include a Alternatively, you can run TEX on the lile kerning information for characters without fontinst. tex and get an interactive prompt, diacriticals. wbch asks you for details on the fonts you Allows the generation of math fonts with want to install. nextlarger, varchar, and arbitrary font If you want to install some fonts in a dmensions. non-Cork encoding, you can create new Allows more than one PostScript font to encodmg files. These consist of: a macros file, contribute to a TEX font, for example, the 'ffi' a PostScript encoding vector, and a 'fudge' file ligatures for a font can be taken from the containing all the information that TEX needs Expert encoding, if you have it. that isn't contained in the afm lile. Automatically generates an fd file for use with In each case, the fonti nst package creates a nurn- version 2 of the New Font Selection Scheme. ber of files: Can be customized by the user to deal with filename. pl contains the Property List of each arbitrary font encodings. PostScript font. You should convert it to a TEX

TUGboat, Volume 14 (1993), No. 3 -Proceedings of the 1993 Annual Meeting 285 Alan Jeffrey

font metric with pl totf, and then delete the ptmbq roman, bold weight. pl file. ptmbi q italic, bold weight.

filename. vpl contains the Virtual Property rn ptmbcq caps and small caps, bold weight. List of each TEX font. You should convert it Each of these fonts may be built from more than to a TEX font metric and a Virtual Font with one PostScript font, for example, ptmrq might use vptovf, and then delete the vp1 file. Times-Roman for most characters, and the Expert filename. f d contains the LATEX Font set for the ffi and ffl Ligatures. Definitions for each family. If you are using When you run TEX on fontinst. tex you are version 2 of the New Font Selection Scheme, prompted for information on the font family you you can use these to access the font family by would llke to install. For each famdy, you are promp- saying \font fami 1y{family name}. ted for: filename. atx is a temporary file containing \Fami 1yName, for example, Adobe Times a translation of an afm file into a that Roman is ptm. can be read by TEX, and can be deleted. \Fami 1yEncodi ng, for example, TI. filename. etx is a temporary file containing Each famly can include a number of fonts, and a translation of a PostScript encoding vector you will be prompted for mformation about each into a syntax that can be read by TEX, and can of them: be deleted. \FontName, for example, Adobe Times Roman Vanilla Fonts is ptmrq. s \FontEncodi ng, for example, Tlul c (for T1 To install the vanilla fonts, you just copy the follow- upper and lower case) or Tlcsc (for T1 caps ing afm files into a directory read by TEX, and run TEX and small caps). on fontvani tex. . \Fontweight, for example, m (medium) or b Ti mes-Roman Ti mes-Ital i c (bold). Ti mes-Bo1 d Times-BoldItalic \Fontshape, for example, n (normal), sl Courier Couri er-Obl i que (oblique), it (italic) or sc (caps and small Courier-Bold Courier-Boldoblique caps). He1 veti ca Helveti ca-Obl i que Helveti ca-Bold Helveti ca-BoldObl ique Each TEX font can be built from a number of Post- Script fonts. For each Postscript font you will be This installs the Times, Courier and Helvetica famil- asked for: ies, in bold and normal weights, with roman, italic, and small caps variants. If you would like to install \AFMName, for example, Adobe Times is other PostScript fonts, the simplest thing to do is Ti mes-Roman. edit fontvani . tex. For example, to generate the \AFMShortName, for example, Adobe Times fonts, you can say: Roman is ptmr0. \makevanilla{ppt} \AFMEncodi ng, for example, adobe (for Adobe {Pal ati no}{Palati no-Ital i c} Standard Encoding) or expert (for Adobe {Pal ati no-Obl ique}{Pal atino-Bol dl Expert Encoding). {Pal ati no-Bol dIta1i c} Using font inst in Other Macro Packages {Pal ati no-Bol dObl i que} If you run TEX on fonti nst . tex, you will be promp- Prompts ted interactively about the fonts you want to in- When you run TEX on fontinst.tex, you Mill1 be stall. Sometimes this is not what you want, for ex- prompted for mformation about the fonts you are ample, fontvani . tex uses the macros defined in going to install. For each font family, you can specify fonti nst. tex without running the prompt. This is a number of TEX fonts, which can in turn be built achieved by having fonti nst. tex check to see if a from a number of PostScript fonts. For example, the macro \noprompt is defined. So if you want to use Times Roman (ptm) font famdy consists of the fonts: fonti nst . tex yourself, you should say: ptmrq roman, medium weight. \def\noprompt{!} \input fonti nst ptmri q italic, medium weight. The most useful commands given by fonti nst . tex rn ptmrcq caps and small caps, medium weight. are:

286 TUGboat, Volume 14 (1993), No. 3 -Proceedings of the 1993 Annual Meeting A PostScript Font Installation Package Written in TEX

\makef ami 1y {commands} This generates \afmuni ts is the length of one afm unit. a font famdy named \Fami 1yName with There are usually 1000 afm units to the encodmg \Fami 1yEncodi ng using the -quad. \maketexfont commands. \itsl ant is the italic slant, measured in \maketexfont{commands) Ths generates points. Ths is normally assigned to font a TEX font named \FontName with encoding dimension 1. \FontEncoding, weight \Fontweight and \xhei ght is the x-height of the font, shape \Fontshape using the \makerawfont measured in afm units. This is usually commands. assigned to font dimension 5. \makerawfont Ths generates a PostScript \capheight is the capital height of the font, font named \AFMName with short name measured in afm units. \AFMShortName and encoding \AFMEncodi ng. \ is the ascender height of the font, For example, to generate a family consisting of just measured in afm units. Adobe Times Roman you could say: \under1 inethi ckness is the rule width of \def\FamilyName{ptm} the font, measured in afm units. \def\Fami 1yEncodi ng{Tl} \iffi xedpi tch is true if the font is \makefami 1y{ monoweight. \def\FontName{ptmr} \getchar{} globally sets the following \def\FontEncoding{Tlul c} parameters: \def\FontWeight{m} - \chardp, \charht, \chari c and \def\FontShape{n} \charwd are the dimensions of the \maketexfont{ character and its italic correction. These \def\AFMName{Times-Roman) are given in points. \def\AFMShortName{rptmr} - \map is a token list consisting of the MAP \def\AFMEncodi ng{adobe} instructions used to generate the glyph. 1 For example, to set character 123 from 1 font 0, followed by character 45 from Installing a New Encoding font 2, \map would be set to: (SETCHAR D 123) The main advantage of using a font installation pack- (SELECTFONT D 2) age written in TEX is that it is very custornizable. To (SETCHAR D 45) install a font in a new encoding, you just have to - \startfont is the font number the generate a new enc file, a new mac file and a new character expects to start in, and fud file. The enc file is just a Postscript encoding \stopfont is the font number the vector, as described in the PostScript Language Ref- character expects to stop in. For erence Manual. The mac file just defines any macros example, in the above case, \startfont you may wish to use the fud file. The most im- in would be 0 and \stopfont would be 2. portant file is the fud file, that contains all the font Information for a TEX font that is not present in the The commands that can be used to change the TEX afm file. This includes: font generated by fontinst . tex are: The coding scheme name. \codi ngscheme{scheme name} sets the coding scheme of the font, for example: The boundary character. The font dimensions. \codi ngschemeCEXTENDED TEX FONT ENCODING - LATIN} The ligatures. \boundarychar{glyph} sets the boundary The varchar and nextlarger entries. character of the font, for example: How to kern such as 'ffi' whch aren't given kerning information in the afm file. \boundarychar{percent) How to fake glyphs such as 'ffi' which aren't \fontdi mens{font dimension commands} defined in the Postscript font. sets the font dimensions of the font. Within the font dimension commands, you can say When an afm file is read, the following parameters \parameter{number}{dimen} to set each are set: parameter. For example:

TUGboat, Volume 14 (1993), No. 3 -Proceedings of the 1993 Annual Meeting 287 Alan Jeffrey

\fontdimens{ \rkernCjl{ \getchar{space} \sca1 e{ll{\doCjl\do{i 131 \parameter{l}{\i tslant} 1 \parameter{2}{\charwd} \I rkern combines an \Ikern and a \rkern. \parameter{3}{.5\charwd} For example, to say that '%' should kern like a \parameter{4}{.33333\charwd} word boundary, you can say: \parameter{5}{\xheight\afmunits} \parameter{6}{1000\afmunits} \lrkern{space}{ \parameter{7}{. 33333\charwd} \scal e{l}{\do{percent}} 1 1 \li gature{glyph}{lig commands} \next1 arger{glyph} {glyph} specifies the sets the ligatures for a glyph. With next element in a NEXTLARGER list. For1 the lig commands, you can say example, to say that C is followed by you can say: \Ii gCglyph1 {glyph} {type}. The type is given in pl syntax, that is one of: \nextlarger{textsum}{di splaysum} LIG /LIG /LIG> LIG/ \varchar{main}{top}{mid}{rep}{bot} gives LIG/> /LIG/ /LIG/> /LIG/>> a VARCHAR entry for a glyph. If an entry is For example, the ligatures for 'f' could be empty, it is omitted. For example, to say how given: large left brackets are built, you can say: \ligature{f}{ \varchar{lbracktop}{lbracktop} \iffixedpi tch\el se {Ibrackmi d}{}{l brackbot} \lig{i}{fi}{LIG} \defchar{glyph){commands} gives the \I ig{fl{fflCLIGl default defmtion of a glyph. If the glyph is \~ig~~l~f~l~LI~l not defined in the Postscript font, then this \fi definition is used instead. The commands should define the parameters given above for \Ikerniglyph} {lkern commands} sets \getchar. For example, the 'compound word how characters should kern on the left. mark' character is defined: Within the lkern commands, you can use \defchar{compwordmark}{ \scal e{number}{commands} to set the \global \charht=Opt scale, and \do{glyph} to set a kern. For \global \charwd=Opt example, to say that 'i' and 'ij' should kern on \global \chardp=Opt the left like 'i' you can say: \global \chari c=Opt \Ikern{i}{ \gl obal\mapCI \scale{l}{\do{i }\do{i j}} 1 1 In giving the default character definitions, The \scale command is provided for fonts it is useful to define macros in the mac file. such as caps and small caps, where you may For example, Tl. mac defines a command wish to scale the kerning of a character. For \doubl echar which joins characters together. Tlulc. fud example, to say that 'T' should kern 85% as For example, contains: much as 'T' you could say: \defchar{fi}{\doublechar{f}{i}{O}} \Ikern{T}{ \defchar{ffi}{\doubl echar{f}{fi}{O}} \seal eCll{\do{Tll This says that 'fi' can be faked by putting an \sca1 e{O. 85}{\do{Tsmall}} 'f' next to an 'i', and that an 'ffi' can be faked 1 by putting an 'f' next to an 'fi'. Since fakes Ths command is useful for glyphs me 'A', can be nested, ths means that some fonts Milll whch most Postscript fonts do not include generate 'ffi' out of an 'f', an 'f' and an 'i'. kerning information for. \mi ssi ngchar is the character used if there \rke rn is just like \Ikern but for kerns on is no sensible fake, for example, for '1'. The the right. For example, to say that 'ij' kerns on default is a half-em black box 'a'. the right like 'j' you can say:

288 TUGboat, Volume 14 (1993), No. 3 -Proceedings of the 1993 Annual Meeting A PostScript Font Installation Package Written in TEX

An Overview of fontinst. tex example, the Times-Roman font can be generated with: The most important file in the fonti nst package is fonti nst. tex, which provides TEX macros for pars- \makepl {Tlul c}{ ing afrn and enc files, for faking characters, and for \readafm{Times-Roman}{adobe}{ptmrO} writing pl and vpl files. The most important com- \readafm{Ti mes-Expert}{expert} {ptmrx} mands are: 1 \makeatx{filename} reads filename. afrn and The code for these macros is fairly gory, especially writes the same information to filename. atx, the parsers, since TEX was never really intended for in a form whch can be parsed more easily by these tasks! TEX. For example, a file which begins: Examples StartFontMetrics 2.0 FontName Ti mes-Roman Table 1 shows the Times Roman font in T1 encoding, Ital i cAngl e 0.0 as produced by the fonti nst package. Note that IsFixedPi tch false there are a number of missing characters: wdl be converted to a file which begins: oJndrJ~~ap \fontname{Ti mes-Roman} Four of these characters (D. P, a and b) are available \i tsl ant=Opt in the Times font, but are not in the default Adobe \fixedpi tchfal se encoding. These characters can be used if you have a dvi to Postscript converter such as dvi ps which Ths macro is an interesting example of can re-encode fonts. Unfortunately, re-encoding the writing a parser in TEX, and contains a lot font to use the IS0 Latin-1 encoding results in the of hacking with \catcodes. One annoying loss of the characters: feature is that afrn files give italic angles in fifl< degrees, where pl files use gradients. To > "" ,,LIGce-- convert from one to the other, we use Phil Ths means that any encodmg which we re-encode Taylor's (1989) excellent trigonometry macros the raw PostScript fonts with is going to have to be \makeetx{filename} reads filename. enc and non-standard. Sigh.. . writes the same information to filename. etx, Figure 1 shows what can be acheved with TEX in a form which can be parsed more easily and Postscript. by TEX. For example, an encoding file whch begins: Bugs /TlEncoding [/grave /acute ... The fonti nst package is currently avdable for P- testing, and has a number of 'features' which should will be converted to a file which begins: be dealt with at some .. . \characternumber{grave}{O} The documentation is very scrappy, and the \characternumber{acute}{l} code is badly commented. This is quite a simple parser. It takes seven minutes to generate a font on a \readafm{afm}{enc}{pl) reads afm. atx Macintosh Classic. and enc. etx (makmg them if necessary), and The interactive prompt is very unfriendly. stores the results in macros, whch are used The error handhng is non-existent (and some by \makepl and \makevpl. of the errors are rather odd, for example, a \makepl {encoding} {commands} reads in the missing enc file Mill1 result in the complaint afm files given by the commands and writes a 'File blah.afm not found.' pl file. For example, the 'raw' Times-Roman The accent positioning in italic fonts is pretty font can be generated with: poor. \makepl {adobe}{ Some characters, such as 'Lcaron' (E) are \readafm{Times-Rornan}{adobe}{ptmrO} pretty poor in monoweight fonts. 1 Producing oblique fonts by optical effects is \makevpl {encoding} {commands} reads not supported. (But I'm not sure ths isn't a in the afrn files given by the commands good thlng!) and writes a vpl file. It also reads the file Composite character instructions in the afrn encoding. fud to find the font fudges. For file are ignored.

TUGboat, Volume 14 (1993),No. 3 -Proceedings of the 1993 Annual Meeting Alan Jeffrey

The support for math and Expert fonts is Rahtz, Sebastian. Notes on setup of the New Font untested, and is awaiting an agreement on Selection Scheme 2 to use Postscript fonts, dis- suitable encodings for 8-bit math and Expert tributed with the nfss2 package, 1993. fonts. Rolucki, Tomas. Dvips: A THDriver, distributed with I've made some assumptions about the format dvi ps, 1993. Available for anonymous ftp from of afm files, for example, that italic angles lie ftp.tex.ac.uk. between 0 and 90". Taylor, Phd. "Trigonometry.T~X"in Twax, Septem- The vpl files generated can have arbitrarily ber 1989. Included in the fonti nst package. long lines in them, caused by long \map instructions. This may cause a problem on some systems. This software is available by anonymous ftp from ftp.cogs.susx.ac.uk in pub/tex/fontinst. All comments are welcome! Afterword After presenting ths paper at the Aston meeting, I had a number of requests from potential users of the fontinst package. The ability to produce ar- bitrary encodings, and to tweak the resulting virtual font seemed quite popular! However, there were a number of reservations: The version of the fonti nst package described here is very user-unfriendly, and is more suit- able for TEX hackers than end-users. There is no distinction between the font- installers interface and the internal details of f ontinst, which makes upward compatibility with future releases difficult. Twealung the virtual fonts is more difficult than it should be, and involves developing a com- plete new fud file for that font. These points dlbe addressed by fonti nst version l.x, whch will include: A more user-friendly interface for non-hackers. A fully-defined font-installer's user interface. A simple way of over-riding the default virtual fonts. Version 1.x ulll not be upwardly compatible with ver- sion 0.19. However, future releases will be upwardly compatible with version 1.x. When version 1.x has been fully tested, the font-installer's interface will be submitted to TUGboat. The fontinst package described here is cur- rently available for use by experienced TEX hackers. Version 1.x will soon be avadable for use by the rest of the TEX world. Bibliography Adobe Systems. Postscript Language Reference Manual, 2nd edition. Addison-Wesley, 1990.

290 TIJGboat, Volume 14 (1993),No. 3 -Proceedings of the 1993 Annual Meeting A Postscript Font Installation Package Written in TEX

Test of ptmrq at l0pt on June 10. 1993 at 1533

'002 " - "Ox '01x < > '02x '6 << >> - - "ix '032 1 ff fi fl ffi ffl

1 , '1Ox A B C D E F G @ "4x 'llx H I J K L M N 0

'24~ a c E 8 6 3 e i2 "Ax '25~ 1 1' 1 n fi 6 i '262 i 4 S 8 t' 1 fi B . . "Bx '27x Y i i z 1J i i f '30x A A A A A A A2 C "Cx '31x E E 13 E i i i I '322 fi 0 0 0 d 0 (E "Dx '33x 0 u u 0 u Y SS '34x A 6 L 5 a A a: F "Ex '35x & C C e i i 1 i' '36x ii b 6 6 5 o CE "Fx '37x @ ti 13 ii ii 9 I3

Table 1: The Times Roman font generated by fonti nst.

TUGboat, Volume 14 (1993), No. 3 -Proceedmgs of the 1993 Annual Meeting Alan Jeffrey

4OP Friday January 22 1993 Published in London and Manchester TheGuardian Businesses press for base rate cut c Pound plunges with fall in production Jobless total on brink of 3m

Lam" WI hop iomgaze* Wllh IhC kl"d you merhan,rm\ onto ihe nihaell) only an a whole wauid k lundcd w8Lh md dzd no, ,hey nor Figure 1: Sample output of a TEX document.

TUGboat, Volume 14 (1993), No. 3 -Proceedings of the 1993 Annual Meeting