<<

TUGboat, Volume 8 (1987), No. 3 275

Generating an APL Font a typewriter-like with fixed spacing; the Aarno Hohti and Okko Kanerva same approach for representing TEX input was University of Helsinki adopted by Knuth in the wbook. The verbatim macros have often been used for importing screen ABSTRACT. The APL language is well known for its or paper outputs into 'I@X documents; some people peculiar symbols which have inhibited the use of this misuse them for an easy construction of tables etc. language in many programming environments. Making In verbatim, the typewriter mode is entered by the APL documents of good quality has been difficult and control sequence \ begint t - that mode is ended by expensive. We describe here a simple way how to use METAFONT to generate an APL font for Tk,X by using \endtt. In the same vein, we could enter the APL existing font definitions as far as possible. mode by the control sequence \beginapl, and to end it by \endapl. However, it is more convenient Introduction to augment verbatim with aplstyle so that it This note describes an interesting exercise in using can be used with several different typewriter-like METAFONT to produce new by combining fonts. (The verbatim macros can be found in the letters from standard fonts. As we know, the APL Wbook, p. 421.) Since Q (the at sign) is used as language [6] of Kenneth Iverson has never gained the escape character inside verbatim mode, our the popularity it deserves largely because of its code might (and in fact does) look as follows: strange symbol set. Indeed, true APL users require \choosett(apl) a special keyboard to support the nonstandard but \begintt powerful operator symbols. Moreover, putting APL @DL-S-SUMSQ N;I into print has always been a problem, and modern Cll s-1-0 low cost computerized typesetting programs do not [2] @GO (N

The APL font table comparison with modern typesetting. Then he de- APL symbols are divided into two classes: the prim- cided (together with the second author) to remedy itive symbols and those obtained by overstriking the situation by creating an APL font for Tm he two primitive ones. The overstrikes are tradition- was using for other kinds of document. Many of ally obtained by typing the first symbol, by using the APL symbols needed were contained in stan- backspace to go back one space and then typing dard fonts: for example. dzamond can be found in the second symbol over the first one. However, in cmsyl0. For alphanumeric characters one could use modern APL keyboards these double symbols are cmslttl0. The simplest try for a solution of the assigned to non-alphanumeric keys (for example, to problem would be to write a list of definitions that keys under the ALT key). We decided to include pick symbols from appropriate fonts. However. this only the primitive APL symbols in the font table; brute force method does not really work since these this enabled us to include also the lower-case letters, symbols come from very different typefaces and. following modern conventions. (The original APL moreover. do not provide a fixed typeface. Hence. letters were restricted to capitals.) The comment we decided to find an easy way of producing an symbol a is the only exception since it is keyed in APL font by using METRFONT. as a double quote. Our font is a fixed size typeface As the starting point. we took the font cm- with strongly slanted letters. Moreover, we have texl0. This is a fixed typeface for an extended followed the style of best books in APL: all symbols typewriter-like font including some Greek charac- should be drawn with a thin pen to get a touch of ters and mathematical symbols. The METRFONT a typewriter. (This point is clearly witnessed, for file for this font, cmtexl0 .mf contains (as usual) a example, in [5].) The places of some symbols are preamble that assigns values to several global vari- determined by the TEX font tables. For example, ables. and the command generate textset;. Now the hash sign # is used for the sign the driver file textset . mf contains the commands in VAX APL. and hence the corresponding symbol mode-setup;f ont-setup; (establishing the values has the the same octal code (043) as the hash sign of the variables for this font) and several input in m. The font table has the following form: files from which the METAFONT descriptions of the characters are to be found. Since some of these files treat the characters by name and since some of the definitions have to be changed (and some dropped). we considered it advisable to discard the driver file and to collect the separate METAFONT files. together with the preamble, to form a large single file cmapll0.mf. The .mf character files needed for cmapllo .mf are the following: greekl (.omega.alpha) i talms () romand (roman digits) punct (punctuation symbols) romanp symbol (math symbols) sym romanu (upper case letters) roman1 (lower case letters)

Definitions The necessary METRFONT files First. put font-ldentifier:="CMAPL1';and set The whole process started when the first author slant:=O; in the preamble. Many definitions can had a paper containing APL symbols and was dis- be copied verbatim from the .mf files. but some of appointed with the quality of the symbols available them need changes. The Greek zota. as given in on the typewriter. Moreover. the secretary who greekl .mf,is strange to APL style: we use instead had typed in the text had forgotten a couple of the dotless z from italms .mf. Moreover. we used lines in the middle of the paper. and the correc- the symbol elt () from sym.mf instead of tion of such mistakes seemed to be very clumsy in the Greek epsilon. The symbols del and delta are TUGboat, Volume 8 (1987), No. 3 taken from symbol .mf (where their names are large triangle and large inverted triangle). However, they \def\ifundefined#lC\expandafter are too sturdy and too short to be placed in a \ifx\csname#l\endcsname\relax~ proper APL font. Further, del must be lifted up so \outer\def \choosett#l(\ifundef ined(#l3 that it is vertically aligned with other symbols. The \message(Undefined font(?), modifications are very easy to do, and the modified replaced with cmttl03 definition is shown below. \let\tt=\tentt % sqrt48 was changed to 6.25 since the \else % Del symbol in APL has a narrower top \def\ttC\expandafter % than the original reversed triangle \csname#l\endcsname)\f i) % symbol (The control sequence \ifundefined comes from % rule.nib has been changed to the mbook, p. 308.) With the help of \choosett, % light-rule.nib the standard verbatim macro can be used without % bot y3=-d-o has been changed to y3=0 changes. % top yl=h-d has been changed to The APL symbols not in the font table are ob % top yl=h+20 tained - as usual -by overstriking two table sym- bols. cmchar "Del" ; \newskip\charwidth beginchar(oct"0021t,16u#,asc~height#,0); \def\overstrike#l#2(\setboxO=\hbox~#l~% adjust-fit(0,O); pickup light-rule.nib; \charwidth=\wdO #l\hskip-\charwidth#2) top yl=h+20; y2=yl; bot y3=0; For example, the grade up and grade down symbols .5[xl,x2]=x3=good.x .5w; w:=r:=2x3; and A are obtained by striking the stile symbol I If t xl=hround( .5w-u*6.25) ; over V and A. respectively. draw zl--z2--z3--cycle; % stroke \def\GU(\overstrike(\DL){\AB)) % grade up labels(1,2,3) ; endchar; \def\GD{\overstrike(\LD)(\AB)) % grade down As can be seen from this example, the pen strokes Now let us take another example of APL. Figure 1 were made thinner. Actually only one symbol was shows some input and the resulting output. directly missing - this is the quad box. However, it can be obtained from the above by adding one User extension control point: A modern user of a computerized typesetting facility cmchar "Quad" ; will probably ask if it is possible to extend or modify beginchar (oct"OOltt,16u# ,body-height#,0) ; fonts coming with the system. As with [5], where adjust-f it (0,O) ; pickup light-rule .nib; the font has an analytic and a bitmapped variant, bot yl=O; y2=yl; top y3=h+20; y4=y3; we can distinguish between the need of modifying .5[xl,x2]=~5=good.x .5w; w:=r:=2x5; cmapll0 via METAFONT and modification of the % The quad box is slightly wider than Del pixel files. APL symbols of various "blackness" or If t xl=hround( .5w-u*7) ; "thickness" may be desirable. Indeed, in [3] the x3=xI; x4=x2; user input is written with boldface APL symbols draw zl--z2--z4--z3--cycle; % box and the answers from the interpreter with thin ones. labels(1,2,3,4); endchar; Furthermore, certain screen previewers use specific After taking care of the special symbols, the letters small size pixel files, and do not support the APL can be treated by finding a suitable value for tilt font. ratio (slant). Indeed, APL letters are very slanted. The modification of the font by changing the We suggest the value 115 for this font (the font values of some global variables in the preamble of cmsllO uses 116). One should remember to give the METAFONT file is easy and can be done by the command font-setup; after setting slant to following how it is done in standard fonts such as 115. Finally, one has to make the verbatim macros cmbxlO etc. This is the recommended way, too. suitable for APL style. Since verbatim might be However, if METAFONT is not available, then one used for several different fonts in one document, we must attack the pixel files. For direct hand editing, decided to include a control sequence \choosett. we use a program that converts a pixel file into a (bitmapped) text file acceptable to any standard screen editor, and another program reading the edited file back into a 7&X pixel file. Scaling fonts TUGboat, Volume 8 (1987), No. 3 down to a desired size can be done in a similar [4] Grenander, Ulf: Mathematical Experiments on the (but automatic) manner; this facility is needed by Computer, Academic Press, 1982. a previewer (written by the first author) not using [5] Howland, John E.: Typesetting APL using a Mac- runtime scaling. intosh, Proceedings of the 1986 APL Conference, SIGAPL, pp. 301 - 305. References [6] Iverson, Kenneth: A , Wi- ley, New York, 1962. [I] Digital Equipment Corporation: VAX-11 APL Ref- erence Manual, 1983. The address [2] Feldberg, Ian: TEXT: Publication-Quality Char- acters Come To APL Graphics, Proceedings of the University of Helsinki 1986 APL Conference, SIGAPL, pp. 306 - 313. Department of [3] Gilman, Leonard, and Allen . Rose: APL, An Hallituskatu 15 Interactive Approach, John Wiley & Sons, Inc., SF-00100 HELSINKI 1984. FINLAND

Figure 1. An APL example The input \choosett{apl3 \setboxO=\vbox{\hsize=5.5truein \begintt [O] Z-A1 PROD A2;A;I;V [I] "RETURNS THE PRODUCT OF THE POLYNOMIALS A1 AND A2 [21 "THE ARGUMENTS ARE GIVEN AS COEFFICIENT ARRAYS [31 I-@RO"Al [4] Z-Al@SO .#A2 [5] L0OP:V-@ROeZ @DMV[(@RO"I)+I]-1 [6] V-@RO-Z-Z , [ (@ROeI>+I1 V@ROO C71 A~(~+-@IO"V~~~>@SO.#((@NT(@IO@RO"V~@EP(~,(@RO~I~+~~~/V~@RO~ [81 Z-+/[1IA@RV[(@RO"I)+1]Z [Sl ( (@RO@ROxZ)>@RO-I) /LOOP \endtt 3 $$\boxit{\boxitI\boxOl3$$ \centerlineC\sevenrm An APL function for polynomial multiplication) gives the output

Z+Al PROD A2;A; I; V QRETURNS THE PRODUCT OF THE POLYNOMIALS A1 AND A2 QTHE ARGUMENTS ARE GIVEN AS COEFFICIENT ARRAYS I+pAI Z+Alo.xA2 LOOP: V+pZ 0 VC()+Il-1 v+pz+z, C(pI)+ll vpo A+(I+-%V[I])~.~((N(%~V)E(~,(~I)+~))/V)~~ Z++/ C1I A@ C(pI)+II Z ((ppZ)>pI)/LOOP

An APL function for polynomial multiplication