202  INTRODUCTION  VPtoVF §1

1. Introduction. The utility program converts virtual-property-list (“ ”) files into an equivalent pair of files called a virtual font (“ ”) file and a TEX font metric (“ ”) file. It also makes a thorough check of the given file, so that the file should be acceptable to device drivers and the file should be acceptable to TEX.

is an extended version of the program , which is part of the standard TEXware library. The idea of a virtual font was inspired by the work of David R. Fuchs who designed a similar set of conventions in 1984 while developing a device driver for ArborText, Inc. He wrote a somewhat similar program called .

The banner string defined here should be changed whenever gets modified. define banner ≡ ´ ␣ ␣ ␣ ␣ ´ { printed when the program starts }

2. This program is written entirely in standard Pascal, except that it has to do some slightly systemdependent character code conversion on input. Furthermore, lower case letters are used in error messages; they could be converted to upper case if necessary. The input is read from vpl file, and the output is written on vf file and tfm file; error messages and other remarks are written on the output file, which the user may choose to assign to the terminal if the system permits it.

The term print is used instead of write when this program writes on the output file, so that all such output can be easily deflected.

define print (#) ≡ write(#) define print ln(#) ≡ write ln(#)

program VPtoVF (vpl file, vf file, tfm file, output ); const ⟨ Constants in the outer block 3 ⟩ type ⟨ Types in the outer block 23 ⟩ var ⟨ Globals in the outer block 5 ⟩ procedure initialize; { this procedure gets things started properly }

var ⟨ Local variables for initialization 25 ⟩ begin print ln(banner ); ⟨ Set initial values 6 ⟩ end;

3. The following parameters can be changed at compile time to extend or reduce ’s capacity. ⟨ Constants in the outer block 3 ⟩ ≡

buf size = 60; { length of lines displayed in error messages } max header bytes = 100; { four times the maximum number of words allowed in the file header

block, must be 1024 or less } vf size = 10000; { maximum length of vf data, in bytes } max stack = 100; { maximum depth of simulated stack } max param words = 30; { the maximum number of parameters allowed } max lig steps = 5000; { maximum length of ligature program, must be at most 32767 − 257 = 32510 } max kerns = 500; { the maximum number of distinct kern values } hash size = 5003;

{ preferably a prime number, a bit larger than the number of character pairs in lig/kern steps }

This code is used in section 2.

4. Here are some macros for common programming idioms.

§5  VPtoVF  PROPERTY LIST DESCRIPTION OF FONT METRIC DATA 203

define incr (#) ≡ # ← # + 1 { increase a variable by unity } define decr (#) ≡ # ← # − 1 { decrease a variable by unity } define do nothing ≡ { empty statement } 5. Property list description of font metric data. The idea behind files is that precise details about fonts, i.e., the facts that are needed by typesetting routines like TEX, sometimes have to be supplied by hand. The nested property-list format provides a reasonably convenient way to do this.

A good deal of computation is necessary to parse and process a file, so it would be inappropriate for TEX itself to do this every time it loads a font. TEX deals only with the compact descriptions of font metric data that appear in files. Such data is so compact, however, it is almost impossible for anybody but a computer to read it.

Device drivers also need a compact way to describe mappings from TEX’s idea of a font to the actual characters a device can produce. They can do this conveniently when given a packed sequence of bytes called a file.

The purpose of is to convert from a human-oriented file of text to computer-oriented files of binary numbers. There’s a companion program, , which goes the other way. ⟨ Globals in the outer block 5 ⟩ ≡ vpl file: text ;

See also sections 21, 24, 27, 29, 31, 36, 44, 46, 47, 52, 67, 75, 77, 82, 86, 89, 91, 113, 123, 138, 143, 147, 158, 161, 167, and 175. This code is used in section 2.

6. ⟨ Set initial values 6 ⟩ ≡ reset (vpl file);

See also sections 22, 26, 28, 30, 32, 45, 49, 68, 80, 84, and 148. This code is used in section 2.

204  PROPERTY LIST DESCRIPTION OF FONT METRIC DATA  VPtoVF §7

7. A file is like a file with a few extra features, so we can begin to define it by reviewing the definition of files. The material in the next few sections is copied from the program .

A file is a list of entries of the form

where the property name is one of a finite set of names understood by this program, and the value may itself in turn be a property list. The idea is best understood by looking at an example, so let’s consider a fragment of the file for a hypothetical font.

This example says that the font whose metric information is being described belongs to the hypothetical family; its face code is medium italic extended; and the characters appear in ASCII code positions. The design size is 10 points, and all other sizes in this file are given in units such that 18 units equals the design size. The font is slanted with a slope of −.25 (hence the letters actually slant backward—perhaps that is why the family name is ). The normal space between words is 6 units (i.e., one third of the 18-unit design size), with glue that shrinks by 2 units or stretches by 3. The letters for which accents don’t need to be raised or lowered are 10.55 units high, and one em equals 18 units.

The example ligature table is a bit trickier. It specifies that the letter followed by another is changed to code ´ 200 , while code ´ 200 followed by is changed to ´ 201 ; presumably codes ´ 200 and ´ 201 represent the ligatures ‘ff’ and ‘ffi’. Moreover, in both cases and ´ 200 , if the following character is the code ´ 51 (which is a right parenthesis), an additional 1.5 units of space should be inserted before the ´ 51 . (The ‘ ’ skips over one or command, which in this case is the second ; in this way two different ligature/kern programs can come together.) Finally, if either or ´ 200 is followed by a question mark, the question mark is replaced by and the ligature program is started over. (Thus, the character pair ‘ ’ would actually become the ligature ‘ff’, and ‘ ’ or ‘ ’ would become ‘fff’. To avoid this restart procedure, the command could be replaced by ; then ‘ would become ‘ff’ and ‘ ’ would become ‘fff’.)

Character itself is 6 units wide and 13.5 units tall, in this example. Its depth is zero (since is not given), and its italic correction is 1.5 units.

8. The example above illustrates most of the features found in files. Note that some property names,

like  or  , take a string as their value; this string continues until the first unmatched right
parenthesis. But most property names, like  and  and  , take a number as their value.

This number can be expressed in a variety of ways, indicated by a prefixed code; stands for decimal, for hexadecimal, for octal, for real, for character, and for “face.” Other property names, like , take two numbers as their value. And still other names, like and and , have more complicated values that involve property lists.

A property name is supposed to be used only in an appropriate property list. For example, shouldn’t occur on the outer level or within .

The individual property-and-value pairs in a property list can appear in any order. For instance, ‘ ’ precedes ‘ ’ in the above example, although the file always puts the stretch parameter first. One could even give the information about characters like ‘ ’ before specifying the number of units in the design size, or before specifying the ligature and kerning table. However, the itself is an exception to this rule; the individual elements of the property list can be reordered only to a certain extent without changing the meaning of that table.

If property-and-value pairs are omitted, a default value is used. For example, we have already noted that the default for is zero. The default for every numeric value is, in fact, zero, unless otherwise stated below.

If the same property name is used more than once, will not notice the discrepancy; it simply uses the final value given. Once again, however, the is an exception to this rule; will complain if there is more than one label for some character. And of course many of the entries in the property list have the same property name.

9. A file also includes information about how to create each character, by typesetting characters from other fonts and/or by drawing lines, etc. Such information is the value of the ‘ ’ property, which can be illustrated as follows:

(These specifications appear in addition to the conventional information. The attribute can be mixed in with other attributes like or it can be given separately.)

In this example, the virtual font is composed of characters that can be fabricated from three actual fonts, ‘ ’, ‘ ’, and ‘ ’ (where is the unit size in this file). Character ´ 0 is typeset as a ‘G’ from the symbol font. Character ´ 76 is typeset as character ´ 277 from the ordinary Times font. (If no other font is selected, font number 0 is the default. If no attribute is given, the default map is a character of the same number in the default font.)

Character 197 (decimal) is more interesting: First an A is typeset (in the default font Times), and this is enclosed by and so that the original position is restored. Then the accent character ´ 312 is typeset, after moving up .937 units and right 1.5 units.

To typeset character ´ 200 in this virtual font, we move down 2.1 units, then typeset a rule that is 1 unit high and 8 units wide.

Finally, to typeset character ´ 201 , we do something that requires a special ability to interpret PostScript commands; this example sets the PostScript “color” to 50% gray and typesets an ‘A’ from in that color.

In general, the attribute of a virtual character can be any sequence of typesetting commands that might appear in a page of a file. A single character might map into an entire page.

10. But instead of relying on a hypothetical example, let’s consider a complete grammar for files, beginning with the (unchanged) grammatical rules for files. At the outer level, the following property names are valid in any file:

(four-byte value). The value, which should be a nonnegative integer less than 2^{32}, is used to identify a particular version of a font; it should match the check sum value stored with the font itself. An explicit check sum of zero is used to bypass check sum testing. If no checksum is specified in the file, will compute the checksum that would compute from the same data.

(numeric value, default is 10). The value, which should be a real number in the range 1.0 ≤ x < 2048, represents the default amount by which all quantities will be scaled if the font is not loaded with an ‘ ’ specification. For example, if one says ‘ ’ in TEX language, the design size in the file is ignored and effectively replaced by 15 points; but if one simply says ‘ ’ the stated design size is used. This quantity is always in units of printer’s points.

(numeric value, default is 1). The value should be a positive real number; it says how many units equals the design size (or the eventual ‘ ’ size, if the font is being scaled). For example, suppose you have a font that has been digitized with 600 pixels per em, and the design size is one em; then you could say ‘ ’ if you wanted to give all of your measurements in units of pixels.

(string value, default is ‘ ’). The string should not contain parentheses, and its length must be less than 40. It identifies the correspondence between the numeric codes and font characters. (TEX ignores this information, but other software programs make use of it.)

(string value, default is ‘ ’). The string should not contain parentheses, and its length must be less than 20. It identifies the name of the family to which this font belongs, e.g., ‘ ’. (TEX ignores this information; but it is needed, for example, when converting files to files for Xerox equipment.)

(one-byte value). This number, which must lie between 0 and 255 inclusive, is a subsidiary identification of the font within its family. For example, bold italic condensed fonts might have the same family name as light roman extended fonts, differing only in their face byte. (TEX ignores this information; but it is needed, for example, when converting files to files for Xerox equipment.)

(string value, default is ‘ ’). The value should start with either ‘ ’ (true) or ‘ ’ (false). If true, character codes less than 128 cannot lead to codes of 128 or more via ligatures or charlists or extensible characters. (TEX82 ignores this flag, but older versions of TEX would only accept files that were seven-bit safe.) computes the correct value of this flag and gives an error message only if a claimed “true” value is incorrect.

(a one-byte value followed by a four-byte value). The one-byte value should be between 18 and a maximum limit that can be raised or lowered depending on the compile-time setting of max header bytes . The four-byte value goes into the header word whose index is the one-byte value; for example, to set header [18] ← 1, one may write ‘ ’. This notation is used for header information that is presently unnamed. (TEX ignores it.)

(property list value). See below for the names allowed in this property list. (property list value). See below for the rules about this special kind of property list. (one-byte value). If this character appears in a command, it matches “end of

word” as well as itself. If no boundary character is given and no occurs within , word boundaries will not affect ligatures or kerning.

. The value is a one-byte integer followed by a property list. The integer represents the number of a character that is present in the font; the property list of a character is defined below. The default is an empty property list.

208  PROPERTY LIST DESCRIPTION OF FONT METRIC DATA  VPtoVF §11

11. Numeric property list values can be given in various forms identified by a prefixed letter.

denotes an ASCII character, which should be a standard visible character that is not a parenthesis. The

numeric value will therefore be between ´ 41 and ´ 176 but not ´ 50 or ´ 51 . denotes an unsigned decimal integer, which must be less than 2^{32}, i.e., at most ‘ ’. denotes a three-letter Xerox face code; the admissible codes are , , , , , , , ,

, , , , , , , , , and , denoting the integers 0 to 17, respectively. denotes an unsigned octal integer, which must be less than 2^{32}, i.e., at most ‘ ’. denotes an unsigned hexadecimal integer, which must be less than 2^{32}, i.e., at most ‘ ’. denotes a real number in decimal notation, optionally preceded by a ‘ ’ or ‘ ’ sign, and optionally

including a decimal point. The absolute value must be less than 2048.

12. The property names allowed in a property list correspond to various TEX parameters, each of which has a (real) numeric value. All of the parameters except are in design units. The

admissible names are  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,
,  ,  ,  ,  ,  ,  ,  ,  ,  ,  , and  ,
for parameters 1 to 22. The alternate names  ,  ,  ,
,  , and  , may also be used for parameters 8 to 13.

The notation ‘ n’ provides another way to specify the nth parameter; for example, ‘ ’ is another way to specify that the is −0.25. The value of n must be positive and less than max param words .

13. The elements of a property list can be of six different types.

(real value) denotes the character’s width in design units.

(real value) denotes the character’s height in design units.

(real value) denotes the character’s depth in design units.

(real value) denotes the character’s italic correction in design units.

(one-byte value), specifies the character that follows the present one in a “charlist.” The value must be the number of a character in the font, and there must be no infinite cycles of supposedly larger and larger characters.

(property list value), specifies an extensible character. This option and are mutually

exclusive; i.e., they cannot both be used within the same list. The elements of a property list are either , , or ; the values are integers, which must be zero or the number of a character in the font. A zero value for , , or means that the corresponding piece of the extensible character is absent. A nonzero value, or a value of zero, denotes the character code used to make up the top, middle, bottom, or replicated piece of an extensible character.

14. A property list contains elements of four kinds, specifying a program in a simple command language that TEX uses for ligatures and kerns. If several lists appear, they are effectively concatenated into a single list.

(one-byte value) means that the program for the stated character value starts here. The integer must

be the number of a character in the font; its  property list must not have a  or
field. At least one  or  step must follow.

means that the program for beginning-of-word ligatures starts here. (two one-byte values). The instruction ‘ c r ’ means, “If the next character is c, then insert

character r and possibly delete the current character and/or c; otherwise go on to the next instruction.” Characters r and c must be present in the font. may be immediately preceded or followed by a slash, and then immediately followed by characters not exceeding the number of slashes. Thus there are eight possible forms:

The slashes specify retention of the left or right original character; the signs specify passing over the result without further ligature processing.

(a one-byte value and a real value). The instruction ‘ c r ’ means, “If the next character is c, then insert a blank space of width r between the current character character and c; otherwise go on to the next intruction.” The value of r, which is in units of the design size, is often negative. Character code c must exist in the font.

(no value). This instruction ends a ligature/kern program. It must follow either a or

instruction, not a or or . (value in the range 0 . . 127). This instruction specifies continuation of a ligature/kern program after

the specified number of or has been skipped over. The number of subsequent and instructions must therefore exceed this specified amount.

15. In addition to all these possibilities, the property name is allowed in any property list. Such comments are ignored.

16. So that is what files hold. In a file additional properties are recognized; two of these are valid on the outermost level:

(string value, default is empty). The value will be reproduced at the beginning of the file (and

printed on the terminal by when it examines that file). . The value is a nonnegative integer followed by a property list. The integer represents an

identifying number for fonts used in attributes. The property list, which identifies the font and relative size, is defined below.

And one additional “virtual property” is valid within a :

. The value is a property list consisting of typesetting commands. Default is the single command c, where c is the current character number.

17. The elements of a property list can be of the following types.

(string value, default is ). This is the font’s identifying name. (string value, default is empty). If the font appears in a nonstandard directory, according to

local conventions, the directory name is given here. (This is system dependent, just as in files.) (four-byte value, default is zero). This value, which should be a nonnegative integer less

than 2^{32}, can be used to check that the font being referred to matches the intended font. If nonzero, it should equal the parameter in that font.

(numeric value, default is the of the present virtual font). This value is relative to the design units of the present virtual font, hence it will be scaled when the virtual font is magnified or reduced. It represents the value that will effectively replace the design size of the font being referred to, so that all characters will be scaled appropriately.

(numeric value, default is 10). This value is absolute, in units of printer’s points. It should

equal the parameter in the font being referred to. If any of the string values contain parentheses, the parentheses must be balanced. Leading blanks are removed from the strings, but trailing blanks are not.

18. Finally, the elements of a property list are an ordered sequence of typesetting commands chosen from among the following:

(four-byte integer value). The value must be the number of a previously defined . This font (or more precisely, the final font that is mapped to that code number, if two properties happen to specify the same code) will be used in subsequent instructions until overridden by another . The first-specified is implicitly selected before the first in every character’s map.

(one-byte integer value). There must be a character of this number in the currently selected font.

(  doesn’t check that the character is valid, but  does.) That character is typeset at the
current position, and the typesetter moves right by the  in that character’s  file.

(two real values). The first value specifies height, the second specifies width, in design units. If both height and width are positive, a rule is typeset at the current position. Then the typesetter moves right, by the specified width.

, , , (real value). The typesetter moves its current position by the

number of design units specified. The current typesetter position is remembered, to be restored on a subsequent . The current typesetter position is reset to where it was on the most recent unmatched . The

and commands in any must be properly nested like balanced parentheses. (string value). The subsequent characters, starting with the first nonblank and ending just before

the first ‘ ’ that has no matching ‘ ’, are interpreted according to local conventions with the same system-dependent meaning as a ‘special’ (xxx ) command in a file.

(hexadecimal string value). The subsequent nonblank characters before the next ‘ ’ must consist entirely of hexadecimal digits, and they must contain an even number of such digits. Each pair of hex digits specifies a byte, and this string of bytes is treated just as the value of a . (This convention permits arbitrary byte strings to be represented in an ordinary text file.)

19. Virtual font mapping is a recursive process, like macro expansion. Thus, a might specify another virtual font, whose characters are themselves mapped to other fonts. As an example of this possibility, consider the following curious file called , which defines a virtual font that is self-contained and self-referential:

The design size is 10 points (the default), hence the character in font is a 10 × 10 point black square. Character is typeset as character in scaled 2000, hence it is a 20×20 point black square. And character is typeset as character in scaled 2000, hence its size is 40 × 40.

Users are responsible for making sure that infinite recursion doesn’t happen.

20. So that is what  files hold. From these rules, you can guess (correctly) that  operates in four

main stages. First it assigns the default values to all properties; then it scans through the file, changing property values as new ones are seen; then it checks the information and corrects any problems; and finally it outputs the and files.

21. The next question is, “What are and files?” A complete answer to that question appears in the documentation of the companion programs, and , so the details will not be repeated here. Suffice it to say that a or file stores all of the relevant font information in a sequence of 8-bit bytes. The number of bytes is always a multiple of 4, so we could regard the files as sequences of 32-bit words; but TEX uses the byte interpretation, and so does . Note that the bytes are considered to be unsigned numbers. ⟨ Globals in the outer block 5 ⟩ +≡ vf file: packed file of 0 . . 255; tfm file: packed file of 0 . . 255;

22. On some systems you may have to do something special to write a packed file of bytes. For example, the following code didn’t work when it was first tried at Stanford, because packed files have to be opened with a special switch setting on the Pascal that was used. ⟨ Set initial values 6 ⟩ +≡

212  BASIC INPUT ROUTINES  VPtoVF §23

rewrite(vf file); rewrite(tfm file); 23. Basic input routines. For the purposes of this program, a byte is an unsigned eight-bit quantity, and an ASCII code is an integer between ´ 40 and ´ 177 . Such ASCII codes correspond to one-character constants like in language. ⟨ Types in the outer block 23 ⟩ ≡

byte = 0 . . 255; { unsigned eight-bit quantity } ASCII code = ´ 40 . . ´ 177 ; { standard ASCII code numbers }

See also sections 66, 71, 78, and 81. This code is used in section 2.

24. One of the things has to do is convert characters of strings to ASCII form, since that is the code used for the family name and the coding scheme in a file. An array xord is used to do the conversion from char ; the method below should work with little or no change on most Pascal systems.

define first ord = 0 { ordinal number of the smallest element of char } define last ord = 127 { ordinal number of the largest element of char }

⟨ Globals in the outer block 5 ⟩ +≡ xord : array [char ] of ASCII code; { conversion table }

25. ⟨ Local variables for initialization 25 ⟩ ≡ k: integer ; { all-purpose initialization index }

See also sections 48, 79, and 83. This code is used in section 2.

26. Characters that should not appear in files (except in comments) are mapped into ´ 177 . define invalid code = ´ 177 { code deserving an error message }

§27  VPtoVF  BASIC INPUT ROUTINES 213

⟨ Set initial values 6 ⟩ +≡ for k ← first ord to last ord do xord [chr (k)] ← invalid code; xord [´ ␣´ ] ← ␣ ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ #´ ] ← # ; xord [´ $´ ] ← $ ; xord [´ %´ ] ← % ; xord [´ ´ ] ← ; xord [´ ´ ´ ´ ] ← ´ ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ` ´ ] ← ` ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; xord [´ ´ ] ← ; 27. In order to help catch errors of badly nested parentheses, assumes that the user will begin each line with a number of blank spaces equal to some constant times the number of open parentheses at the beginning of that line. However, the program doesn’t know in advance what the constant is, nor does it want to print an error message on every line for a user who has followed no consistent pattern of indentation.

Therefore the following strategy is adopted: If the user has been consistent with indentation for ten or more lines, an indentation error will be reported. The constant of indentation is reset on every line that should have nonzero indentation. ⟨ Globals in the outer block 5 ⟩ +≡ line: integer ; { the number of the current line } good indent : integer ; { the number of lines since the last bad indentation } indent : integer ; { the number of spaces per open parenthesis, zero if unknown } level : integer ; { the current number of open parentheses }

28. ⟨ Set initial values 6 ⟩ +≡ line ← 0; good indent ← 0; indent ← 0; level ← 0;

29. The input need not really be broken into lines of any maximum length, and we could read it character by character without any buffering. But we shall place it into a small buffer so that offending lines can be displayed in error messages. ⟨ Globals in the outer block 5 ⟩ +≡ left ln, right ln: boolean; { are the left and right ends of the buffer at end-of-line marks? } limit : 0 . . buf size; { position of the last character present in the buffer } loc: 0 . . buf size; { position of the last character read in the buffer } buffer : array [1 . . buf size] of char ; input has ended : boolean; { there is no more input to read }

30. ⟨ Set initial values 6 ⟩ +≡ limit ← 0; loc ← 0; left ln ← true; right ln ← true; input has ended ← false;

31. Just before each property list is evaluated, the character code is printed in octal notation. Up to eight such codes appear on a line; so we have a variable to keep track of how many are currently there. ⟨ Globals in the outer block 5 ⟩ +≡ chars on line: 0 . . 8; { the number of characters printed on the current line }

32. ⟨ Set initial values 6 ⟩ +≡ chars on line ← 0; 33. The following routine prints an error message and an indication of where the error was detected. The error message should not include any final punctuation, since this procedure supplies its own.

define err print (#) ≡ begin if chars on line > 0 then print ln(´ ␣´ ); print (#); show error context ; end

procedure show error context ; { prints the current scanner location } var k: 0 . . buf size; { an index into buffer } begin print ln(´ ␣ ␣´ , line : 1, ´ ´ ); if ¬left ln then print (´ ´ ); for k ← 1 to loc do print (buffer [k]); { print the characters already scanned } print ln(´ ␣´ ); if ¬left ln then print (´ ␣␣␣´ ); for k ← 1 to loc do print (´ ␣´ ); { space out the second line } for k ← loc + 1 to limit do print (buffer [k]); { print the characters yet unseen } if right ln then print ln(´ ␣´ ) else print ln(´ ´ ); chars on line ← 0; end;

34. Here is a procedure that does the right thing when we are done reading the present contents of the buffer. It keeps buffer [buf size] empty, in order to avoid range errors on certain Pascal compilers.

An infinite sequence of right parentheses is placed at the end of the file, so that the program is sure to get out of whatever level of nesting it is in.

On some systems it is desirable to modify this code so that tab marks in the buffer are replaced by blank spaces. (Simply setting xord [chr (´ 11 )] ← ␣ would not work; for example, two-line error messages would not come out properly aligned.) procedure fill buffer ;

begin left ln ← right ln; limit ← 0; loc ← 0;

if left ln then

begin if line > 0 then read ln(vpl file);

incr (line);

end; if eof (vpl file) then

begin limit ← 1; buffer [1] ← ´ ´ ; right ln ← false; input has ended ← true;

end else begin while (limit < buf size − 1) ∧ (¬eoln(vpl file)) do

begin incr (limit ); read (vpl file, buffer [limit ]); end;

buffer [limit + 1] ← ´ ␣´ ; right ln ← eoln(vpl file);

if left ln then ⟨ Set loc to the number of leading blanks in the buffer, and check the indentation 35 ⟩; end;

end; 35. The interesting part about fill buffer is the part that learns what indentation conventions the user is following, if any.

define bad indent (#) ≡ begin if good indent ≥ 10 then err print (#); good indent ← 0; indent ← 0; end

⟨ Set loc to the number of leading blanks in the buffer, and check the indentation 35 ⟩ ≡ begin while (loc < limit ) ∧ (buffer [loc + 1] = ´ ␣´ ) do incr (loc); if loc < limit then

begin if level = 0 then if loc = 0 then incr (good indent ) else bad indent (´ ␣ ␣ ␣ ␣ ␣ ␣ ´ )

else if indent = 0 then

if loc mod level = 0 then begin indent ← loc div level ; good indent ← 1; end

else good indent ← 0 else if indent ∗ level = loc then incr (good indent )

else bad indent (´ ␣ ␣ ␣´ ,

´ ␣ ␣ ␣ ␣ ␣´ , level : 1);

end; end

This code is used in section 34.

216  BASIC SCANNING ROUTINES  VPtoVF §36

36. Basic scanning routines. The global variable cur char holds the ASCII code corresponding to the character most recently read from the input buffer, or to a character that has been substituted for the real one. ⟨ Globals in the outer block 5 ⟩ +≡ cur char : ASCII code; { we have just read this }

37. Here is a procedure that sets cur char to an ASCII code for the next character of input, if that character is a letter or digit or slash or . Otherwise it sets cur char ← ␣ , and the input system will be poised to reread the character that was rejected, whether or not it was a space. Lower case letters are converted to upper case. procedure get keyword char ;

begin while (loc = limit ) ∧ (¬right ln) do fill buffer ;

if loc = limit then cur char ← ␣ { end-of-line counts as a delimiter } else begin cur char ← xord [buffer [loc + 1]];

if cur char ≥ then cur char ← cur char − ´ 40 ; if ((cur char ≥ ) ∧ (cur char ≤ )) then incr (loc) else if ((cur char ≥ ) ∧ (cur char ≤ )) then incr (loc)

else if cur char = then incr (loc) else if cur char = then incr (loc)

else cur char ← ␣ ; end;

end;

38. The following procedure sets cur char to the next character code, and converts lower case to upper case. If the character is a left or right parenthesis, it will not be “digested”; the character will be read again and again, until the calling routine does something like ‘incr (loc)’ to get past it. Such special treatment of parentheses insures that the structural information they contain won’t be lost in the midst of other error recovery operations.

define backup ≡ begin if (cur char > ) ∨ (cur char < ) then decr (loc); end { undoes the effect of get next }

procedure get next ; { sets cur char to next, balks at parentheses } begin while loc = limit do fill buffer ; incr (loc); cur char ← xord [buffer [loc]]; if cur char ≥ then

if cur char ≤ then cur char ← cur char − ´ 40 { uppercasify } else begin if cur char = invalid code then

begin err print (´ ␣ ␣ ␣ ␣ ´ ); cur char ← ; end; end

else if (cur char ≤ ) ∧ (cur char ≥ ) then decr (loc);

end;

§39  VPtoVF  BASIC SCANNING ROUTINES 217

39. Here’s a procedure that scans a hexadecimal digit or a right parenthesis. function get hex : byte;

var a: integer ; { partial result } begin repeat get next ; until cur char ≠ ␣ ; a ← cur char − ; if a > 0 then

begin a ← cur char − ;

if cur char > then if cur char < then a ← −1 else a ← cur char − + 10;

end; if (a < 0) ∨ (a > 15) then

begin err print (´ ␣ ␣ ´ ); get hex ← 0; end

else get hex ← a; end;

40. The next procedure is used to ignore the text of a comment, or to pass over erroneous material. As such, it has the privilege of passing parentheses. It stops after the first right parenthesis that drops the level below the level in force when the procedure was called. procedure skip to end of item;

var l: integer ; { initial value of level } begin l ← level ; while level ≥ l do

begin while loc = limit do fill buffer ;

incr (loc);

if buffer [loc] = ´ ´ then decr (level )

else if buffer [loc] = ´ ´ then incr (level );

end; if input has ended then err print (´ ␣ ␣ ␣ ␣ ␣ ´ ); cur char ← ␣ ; { now the right parenthesis has been read and digested } end; 41. A similar procedure copies the bytes remaining in an item. The copied bytes go into an array vf that we’ll declare later. Leading blanks are ignored.

define vf store(#) ≡ begin vf [vf ptr ] ← #; if vf ptr = vf size then err print (´ ´ ´ ␣ ␣ ␣ ␣ ␣ ´ ) else incr (vf ptr ); end

procedure copy to end of item; label 30; var l: integer ; { initial value of level }

nonblank found : boolean; { have we seen a nonblank character yet? } begin l ← level ; nonblank found ← false;

while true do

begin while loc = limit do fill buffer ;

if buffer [loc + 1] = ´ ´ then

if level = l then goto 30 else decr (level ); incr (loc); if buffer [loc] = ´ ´ then incr (level ); if buffer [loc] ≠ ´ ␣´ then nonblank found ← true;

if nonblank found then

if xord [buffer [loc]] = invalid code then begin err print (´ ␣ ␣ ␣ ␣ ´ ); vf store( ); end

else vf store(xord [buffer [loc]]); end;

30: end;

42. Sometimes we merely want to skip past characters in the input until we reach a left or a right parenthesis. For example, we do this whenever we have finished scanning a property value and we hope that a right parenthesis is next (except for possible blank spaces).

define skip to paren ≡

repeat get next until (cur char = ) ∨ (cur char = )

define skip error (#) ≡ begin err print (#); skip to paren; end { this gets to the right parenthesis if something goes wrong }

define flush error (#) ≡ begin err print (#); skip to end of item; end { this gets past the right parenthesis if something goes wrong }

43. After a property value has been scanned, we want to move just past the right parenthesis that should come next in the input (except for possible blank spaces). procedure finish the property ; { do this when the value has been scanned }

§44  VPtoVF  SCANNING PROPERTY NAMES 219

begin while cur char = ␣ do get next ; if cur char ≠ then err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); skip to end of item; end; 44. Scanning property names. We have to figure out the meaning of names that appear in the file, by looking them up in a dictionary of known keywords. Keyword number n appears in locations start [n] through start [n + 1] − 1 of an array called dictionary .

define max name index = 100 { upper bound on the number of keywords } define max letters = 666 { upper bound on the total length of all keywords }

⟨ Globals in the outer block 5 ⟩ +≡ start : array [1 . . max name index ] of 0 . . max letters ; dictionary : array [0 . . max letters ] of ASCII code; start ptr : 0 . . max name index ; { the first available place in start } dict ptr : 0 . . max letters ; { the first available place in dictionary }

45. ⟨ Set initial values 6 ⟩ +≡ start ptr ← 1; start [1] ← 0; dict ptr ← 0;

46. When we are looking for a name, we put it into the cur name array. When we have found it, the corresponding start index will go into the global variable name ptr .

define longest name = 20 { length of } ⟨ Globals in the outer block 5 ⟩ +≡ cur name: array [1 . . longest name] of ASCII code; { a name to look up } name length: 0 . . longest name; { its length } name ptr : 0 . . max name index ; { its ordinal number in the dictionary }

47. A conventional hash table with linear probing (cf. Algorithm 6.4L in The Art of Computer Programming) is used for the dictionary operations. If nhash[h] = 0, the table position is empty, otherwise nhash[h] points into the start array.

define hash prime = 141 { size of the hash table } ⟨ Globals in the outer block 5 ⟩ +≡ nhash: array [0 . . hash prime − 1] of 0 . . max name index ; cur hash: 0 . . hash prime − 1; { current position in the hash table }

48. ⟨ Local variables for initialization 25 ⟩ +≡ h: 0 . . hash prime − 1; { runs through the hash table }

220  SCANNING PROPERTY NAMES  VPtoVF §50

49. ⟨ Set initial values 6 ⟩ +≡ for h ← 0 to hash prime − 1 do nhash[h] ← 0; 50. Since there is no chance of the hash table overflowing, the procedure is very simple. After lookup has done its work, cur hash will point to the place where the given name was found, or where it should be inserted. procedure lookup; { finds cur name in the dictionary }

var k: 0 . . longest name; { index into cur name } j: 0 . . max letters ; { index into dictionary } not found : boolean; { clumsy thing necessary to avoid goto statement }

begin ⟨ Compute the hash code, cur hash, for cur name 51 ⟩; not found ← true;

while not found do

begin if cur hash = 0 then cur hash ← hash prime − 1 else decr (cur hash); if nhash[cur hash] = 0 then not found ← false else begin j ← start [nhash[cur hash]];

if start [nhash[cur hash] + 1] = j + name length then begin not found ← false; for k ← 1 to name length do

if dictionary [j + k − 1] ≠ cur name[k] then not found ← true; end; end;

end; name ptr ← nhash[cur hash]; end;

51. ⟨ Compute the hash code, cur hash, for cur name 51 ⟩ ≡ cur hash ← cur name[1]; for k ← 2 to name length do cur hash ← (cur hash + cur hash + cur name[k]) mod hash prime

This code is used in section 50.

52. The “meaning” of the keyword that begins at start [k] in the dictionary is kept in equiv [k]. The numeric equiv codes are given symbolic meanings by the following definitions.

define comment code = 0 define check sum code = 1 define design size code = 2 define design units code = 3 define coding scheme code = 4 define family code = 5 define face code = 6 define seven bit safe flag code = 7 define header code = 8 define font dimen code = 9 define lig table code = 10 define boundary char code = 11 define virtual title code = 12 define map font code = 13 define character code = 14 define font name code = 20 define font area code = 21 define font checksum code = 22 define font at code = 23 define font dsize code = 24 define parameter code = 30 define char info code = 60 define width = 1 define height = 2 define depth = 3 define italic = 4 define char wd code = char info code + width define char ht code = char info code + height define char dp code = char info code + depth define char ic code = char info code + italic define next larger code = 65 define map code = 66 define var char code = 67 define select font code = 80 define set char code = 81 define set rule code = 82 define move right code = 83 define move down code = 85 define push code = 87 define pop code = 88 define special code = 89 define special hex code = 90 define label code = 100 define stop code = 101 define skip code = 102 define krn code = 103 define lig code = 104

⟨ Globals in the outer block 5 ⟩ +≡ equiv : array [0 . . max name index ] of byte; cur code: byte; { equivalent most recently found in equiv } 53. We have to get the keywords into the hash table and into the dictionary in the first place (sigh). The procedure that does this has the desired equiv code as a parameter. In order to facilitate macro writing for the initialization, the keyword being initialized is placed into the last positions of cur name, instead of the first positions. procedure enter name(v : byte); { cur name goes into the dictionary }

var k: 0 . . longest name; begin for k ← 1 to name length do cur name[k] ← cur name[k + longest name − name length];

{ now the name has been shifted into the correct position } lookup; { this sets cur hash to the proper insertion place } nhash[cur hash] ← start ptr ; equiv [start ptr ] ← v; for k ← 1 to name length do

begin dictionary [dict ptr ] ← cur name[k]; incr (dict ptr ); end;

incr (start ptr ); start [start ptr ] ← dict ptr ; end; 54. Here are the macros to load a name of up to 20 letters into the dictionary. For example, the macro load5 is used for five-letter keywords.

define tail (#) ≡ enter name(#) define t20 (#) ≡ cur name[20] ← #; tail define t19 (#) ≡ cur name[19] ← #; t20 define t18 (#) ≡ cur name[18] ← #; t19 define t17 (#) ≡ cur name[17] ← #; t18 define t16 (#) ≡ cur name[16] ← #; t17 define t15 (#) ≡ cur name[15] ← #; t16 define t14 (#) ≡ cur name[14] ← #; t15 define t13 (#) ≡ cur name[13] ← #; t14 define t12 (#) ≡ cur name[12] ← #; t13 define t11 (#) ≡ cur name[11] ← #; t12 define t10 (#) ≡ cur name[10] ← #; t11 define t9 (#) ≡ cur name[9] ← #; t10 define t8 (#) ≡ cur name[8] ← #; t9 define t7 (#) ≡ cur name[7] ← #; t8 define t6 (#) ≡ cur name[6] ← #; t7 define t5 (#) ≡ cur name[5] ← #; t6 define t4 (#) ≡ cur name[4] ← #; t5 define t3 (#) ≡ cur name[3] ← #; t4 define t2 (#) ≡ cur name[2] ← #; t3 define t1 (#) ≡ cur name[1] ← #; t2 define load3 ≡ name length ← 3; t18 define load4 ≡ name length ← 4; t17 define load5 ≡ name length ← 5; t16 define load6 ≡ name length ← 6; t15 define load7 ≡ name length ← 7; t14 define load8 ≡ name length ← 8; t13 define load9 ≡ name length ← 9; t12 define load10 ≡ name length ← 10; t11 define load11 ≡ name length ← 11; t10 define load12 ≡ name length ← 12; t9 define load13 ≡ name length ← 13; t8 define load14 ≡ name length ← 14; t7 define load15 ≡ name length ← 15; t6 define load16 ≡ name length ← 16; t5 define load17 ≡ name length ← 17; t4 define load18 ≡ name length ← 18; t3 define load19 ≡ name length ← 19; t2 define load20 ≡ name length ← 20; t1 55. (Thank goodness for keyboard macros in the text editor used to create this file.) ⟨ Enter all the names and their equivalents, except the parameter names 55 ⟩ ≡

equiv [0] ← comment code; { this is used after unknown keywords } load8 ( )( )( )( )( )( )( )( )(check sum code); load10 ( )( )( )( )( )( )( )( )( )( )(design size code); load11 ( )( )( )( )( )( )( )( )( )( )( )(design units code); load12 ( )( )( )( )( )( )( )( )( )( )( )( )(coding scheme code); load6 ( )( )( )( )( )( )(family code); load4 ( )( )( )( )(face code); load16 ( )( )( )( )( )( )( )( )

( )( )( )( )( )( )( )( )(seven bit safe flag code); load6 ( )( )( )( )( )( )(header code); load9 ( )( )( )( )( )( )( )( )( )(font dimen code); load8 ( )( )( )( )( )( )( )( )(lig table code); load12 ( )( )( )( )( )( )( )( )( )( )( )( )(boundary char code); load9 ( )( )( )( )( )( )( )( )( )(character code); load9 ( )( )( )( )( )( )( )( )( )(parameter code); load6 ( )( )( )( )( )( )(char wd code); load6 ( )( )( )( )( )( )(char ht code); load6 ( )( )( )( )( )( )(char dp code); load6 ( )( )( )( )( )( )(char ic code); load10 ( )( )( )( )( )( )( )( )( )( )(next larger code); load7 ( )( )( )( )( )( )( )(var char code); load3 ( )( )( )(var char code + 1); load3 ( )( )( )(var char code + 2); load3 ( )( )( )(var char code + 3); load3 ( )( )( )(var char code + 4); load3 ( )( )( )(var char code + 4); { compatibility with older format } load7 ( )( )( )( )( )( )( )(comment code); load5 ( )( )( )( )( )(label code); load4 ( )( )( )( )(stop code); load4 ( )( )( )( )(skip code); load3 ( )( )( )(krn code); load3 ( )( )( )(lig code); load4 ( )( )( )( )(lig code + 2); load5 ( )( )( )( )( )(lig code + 6); load4 ( )( )( )( )(lig code + 1); load5 ( )( )( )( )( )(lig code + 5); load5 ( )( )( )( )( )(lig code + 3); load6 ( )( )( )( )( )( )(lig code + 7); load7 ( )( )( )( )( )( )( )(lig code + 11);

This code is used in section 180.

56. files may contain the following in addition to the names. ⟨ Enter all the names 56 ⟩ ≡

load6 ( )( )( )( )( )( )(virtual title code); load7 ( )( )( )( )( )( )( )(map font code); load3 ( )( )( )(map code); load8 ( )( )( )( )( )( )( )( )(font name code); load8 ( )( )( )( )( )( )( )( )(font area code); load12 ( )( )( )( )( )( )( )( )( )( )( )( )(font checksum code); load6 ( )( )( )( )( )( )(font at code); load9 ( )( )( )( )( )( )( )( )( )(font dsize code); load10 ( )( )( )( )( )( )( )( )( )( )(select font code); load7 ( )( )( )( )( )( )( )(set char code); load7 ( )( )( )( )( )( )( )(set rule code); load9 ( )( )( )( )( )( )( )( )( )(move right code); load8 ( )( )( )( )( )( )( )( )(move right code + 1); load8 ( )( )( )( )( )( )( )( )(move down code); load6 ( )( )( )( )( )( )(move down code + 1); load4 ( )( )( )( )(push code); load3 ( )( )( )(pop code); load7 ( )( )( )( )( )( )( )(special code); load10 ( )( )( )( )( )( )( )( )( )( )(special hex code);

This code is used in section 180.

57. ⟨ Enter the parameter names 57 ⟩ ≡ load5 ( )( )( )( )( )(parameter code + 1); load5 ( )( )( )( )( )(parameter code + 2); load7 ( )( )( )( )( )( )( )(parameter code + 3); load6 ( )( )( )( )( )( )(parameter code + 4); load7 ( )( )( )( )( )( )( )(parameter code + 5); load4 ( )( )( )( )(parameter code + 6); load10 ( )( )( )( )( )( )( )( )( )( )(parameter code + 7); load4 ( )( )( )( )(parameter code + 8); load4 ( )( )( )( )(parameter code + 9); load4 ( )( )( )( )(parameter code + 10); load6 ( )( )( )( )( )( )(parameter code + 11); load6 ( )( )( )( )( )( )(parameter code + 12); load4 ( )( )( )( )(parameter code + 13); load4 ( )( )( )( )(parameter code + 14); load4 ( )( )( )( )(parameter code + 15); load4 ( )( )( )( )(parameter code + 16); load4 ( )( )( )( )(parameter code + 17); load7 ( )( )( )( )( )( )( )(parameter code + 18); load7 ( )( )( )( )( )( )( )(parameter code + 19); load6 ( )( )( )( )( )( )(parameter code + 20); load6 ( )( )( )( )( )( )(parameter code + 21); load10 ( )( )( )( )( )( )( )( )( )( )(parameter code + 22); load20 ( )( )( )( )( )( )( )( )( )( )( )

( )( )( )( )( )( )( )( )( )(parameter code + 8); load13 ( )( )( )( )( )( )( )( )( )( )( )( )( )(parameter code + 9); load13 ( )( )( )( )( )( )( )( )( )( )( )( )( )(parameter code + 10); load13 ( )( )( )( )( )( )( )( )( )( )( )( )( )(parameter code + 11); load13 ( )( )( )( )( )( )( )( )( )( )( )( )( )(parameter code + 12); load13 ( )( )( )( )( )( )( )( )( )( )( )( )( )(parameter code + 13);

This code is used in section 180.

58. When a left parenthesis has been scanned, the following routine is used to interpret the keyword that follows, and to store the equivalent value in cur code. procedure get name;

begin incr (loc); incr (level ); { pass the left parenthesis } cur char ← ␣ ; while cur char = ␣ do get next ; if (cur char > ) ∨ (cur char < ) then decr (loc); { back up one character } name length ← 0; get keyword char ; { prepare to scan the name } while cur char ≠ ␣ do

begin if name length = longest name then cur name[1] ← { force error } else incr (name length); cur name[name length] ← cur char ; get keyword char ; end;

§59  VPtoVF  SCANNING NUMERIC DATA 227

lookup; if name ptr = 0 then err print (´ ␣ ␣ ´ ´ ␣ ␣ ␣ ␣ ´ ); cur code ← equiv [name ptr ]; end; 59. Scanning numeric data. The next thing we need is a trio of subroutines to read the one-byte, four-byte, and real numbers that may appear as property values. These subroutines are careful to stick to numbers between −2^{31} and 2^{31} − 1, inclusive, so that a computer with two’s complement 32-bit arithmetic will not be interrupted by overflow.

60. The first number scanner, which returns a one-byte value, surely has no problems of arithmetic overflow. function get byte: byte; { scans a one-byte property value }

var acc: integer ; { an accumulator }

t: ASCII code; { the type of value to be scanned } begin repeat get next ; until cur char ≠ ␣ ; { skip the blanks before the type code } t ← cur char ; acc ← 0; repeat get next ; until cur char ≠ ␣ ; { skip the blanks after the type code } if t = then ⟨ Scan an ASCII character code 61 ⟩ else if t = then ⟨ Scan a small decimal number 62 ⟩

else if t = then ⟨ Scan a small octal number 63 ⟩

else if t = then ⟨ Scan a small hexadecimal number 64 ⟩

else if t = then ⟨ Scan a face code 65 ⟩

else skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ );

cur char ← ␣ ; get byte ← acc; end;

61. The get next routine converts lower case to upper case, but it leaves the character in the buffer, so we can unconvert it. ⟨ Scan an ASCII character code 61 ⟩ ≡

if (cur char ≥ ´ 41 ) ∧ (cur char ≤ ´ 176 ) ∧ ((cur char < ) ∨ (cur char > )) then

acc ← xord [buffer [loc]] else skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ )

This code is used in section 60.

62. ⟨ Scan a small decimal number 62 ⟩ ≡

begin while (cur char ≥ ) ∧ (cur char ≤ ) do begin acc ← acc ∗ 10 + cur char − ; if acc > 255 then

begin skip error (´ ␣ ␣ ´ ´ ␣ ␣ ´ ); acc ← 0; cur char ← ␣ ; end

else get next ;

end; backup; end

This code is used in section 60.

228  SCANNING NUMERIC DATA  VPtoVF §63

63. ⟨ Scan a small octal number 63 ⟩ ≡

begin while (cur char ≥ ) ∧ (cur char ≤ ) do begin acc ← acc ∗ 8 + cur char − ; if acc > 255 then

begin skip error (´ ␣ ␣ ´ ´ ␣ ␣´ ´ ´ ); acc ← 0; cur char ← ␣ ; end

else get next ;

end; backup; end

This code is used in section 60.

64. ⟨ Scan a small hexadecimal number 64 ⟩ ≡

begin while ((cur char ≥ ) ∧ (cur char ≤ )) ∨ ((cur char ≥ ) ∧ (cur char ≤ )) do begin if cur char ≥ then cur char ← cur char + + 10 − ; acc ← acc ∗ 16 + cur char − ; if acc > 255 then

begin skip error (´ ␣ ␣ ´ ´ ␣ ␣ ´ ); acc ← 0; cur char ← ␣ ; end

else get next ;

end; backup; end

This code is used in section 60.

65. ⟨ Scan a face code 65 ⟩ ≡ begin if cur char = then acc ← 2 else if cur char = then acc ← 4

else if cur char ≠ then acc ← 18; get next ; if cur char = then incr (acc) else if cur char ≠ then acc ← 18; get next ; if cur char = then acc ← acc + 6 else if cur char = then acc ← acc + 12

else if cur char ≠ then acc ← 18; if acc ≥ 18 then

begin skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); acc ← 0; end;

end

This code is used in section 60.

66. The routine that scans a four-byte value puts its output into cur bytes , which is a record containing (yes, you guessed it) four bytes. ⟨ Types in the outer block 23 ⟩ +≡

four bytes = record b0 : byte; b1 : byte; b2 : byte; b3 : byte; end; 67. define c0 ≡ cur bytes .b0

define c1 ≡ cur bytes .b1 define c2 ≡ cur bytes .b2 define c3 ≡ cur bytes .b3

⟨ Globals in the outer block 5 ⟩ +≡ cur bytes : four bytes ; { a four-byte accumulator } zero bytes : four bytes ; { four bytes all zero }

68. ⟨ Set initial values 6 ⟩ +≡ zero bytes .b0 ← 0; zero bytes .b1 ← 0; zero bytes .b2 ← 0; zero bytes .b3 ← 0;

69. Since the get four bytes routine is used very infrequently, no attempt has been made to make it fast; we only want it to work. procedure get four bytes ; { scans an unsigned constant and sets four bytes }

var c: integer ; { local two-byte accumulator }

r: integer ; { radix } begin repeat get next ; until cur char ≠ ␣ ; { skip the blanks before the type code } r ← 0; cur bytes ← zero bytes ; { start with the accumulator zero } if cur char = then r ← 16 else if cur char = then r ← 8

else if cur char = then r ← 10

else skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); if r > 0 then

begin repeat get next ;

until cur char ≠ ␣ ; { skip the blanks after the type code }

while ((cur char ≥ ) ∧ (cur char ≤ )) ∨ ((cur char ≥ ) ∧ (cur char ≤ )) do

⟨ Multiply by r, add cur char − , and get next 70 ⟩; end;

end;

70. ⟨ Multiply by r, add cur char − , and get next 70 ⟩ ≡

begin if cur char ≥  then cur char ← cur char +  + 10 − ;
if cur char ≥  + r then skip error (´ ␣  ´ )

else begin c ← c3 ∗ r + cur char − ; c3 ← c mod 256; c ← c2 ∗ r + c div 256; c2 ← c mod 256; c ← c1 ∗ r + c div 256; c1 ← c mod 256; c ← c0 ∗ r + c div 256; if c < 256 then c0 ← c else begin cur bytes ← zero bytes ;

if r = 8 then skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ )

else if r = 10 then skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ )

else skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); end;

get next ;

end; end

This code is used in section 69.

71. The remaining scanning routine is the most interesting. It scans a real constant and returns the nearest fix word approximation to that constant. A fix word is a 32-bit integer that represents a real value that has been multiplied by 2^{20}. Since restricts the magnitude of reals to 2048, the fix word will have a magnitude less than 2^{31}.

define unity ≡ ´ 4000000 { 2^{20}, the fix word 1.0 } ⟨ Types in the outer block 23 ⟩ +≡

fix word = integer ; { a scaled real value with 20 bits of fraction }

72. When a real value is desired, we might as well treat ‘ ’ and ‘ ’ formats as if they were identical. function get fix : fix word ; { scans a real property value }

var negative: boolean; { was there a minus sign? } acc: integer ; { an accumulator } int part : integer ; { the integer part } j: 0 . . 7; { the number of decimal places stored }

begin repeat get next ; until cur char ≠ ␣ ; { skip the blanks before the type code } negative ← false; acc ← 0; { start with the accumulators zero } if (cur char ≠ ) ∧ (cur char ≠ ) then skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ) else begin ⟨ Scan the blanks and/or signs after the type code 73 ⟩;

while (cur char ≥ ) ∧ (cur char ≤ ) do ⟨ Multiply by 10, add cur char − , and get next 74 ⟩; int part ← acc; acc ← 0; if cur char = then ⟨ Scan the fraction part and put it in acc 76 ⟩; if (acc ≥ unity ) ∧ (int part = 2047) then skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ´ ) else acc ← int part ∗ unity + acc; end;

if negative then get fix ← −acc else get fix ← acc; end;

73. ⟨ Scan the blanks and/or signs after the type code 73 ⟩ ≡

repeat get next ;

if cur char = then begin cur char ← ␣ ; negative ← true; end

else if cur char = then cur char ← ␣ ; until cur char ≠ ␣

This code is used in section 72.

74. ⟨ Multiply by 10, add cur char − , and get next 74 ⟩ ≡ begin acc ← acc ∗ 10 + cur char − ; if acc ≥ 2048 then

begin skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); acc ← 0; cur char ← ␣ ; end

else get next ; end

This code is used in section 72.

75. To scan the fraction .d_{1}d_{2} …, we keep track of up to seven of the digits d_{j}. A correct result is obtained if we first compute f′ = ⌊2^{21}(d_{1} … d_{j})/10^{j}⌋, after which f = ⌊(f′ + 1)/2⌋. It is possible to have f = 1.0. ⟨ Globals in the outer block 5 ⟩ +≡ fraction digits : array [1 . . 7] of integer ; { 2^{21} times d_{j} } 76. ⟨ Scan the fraction part and put it in acc 76 ⟩ ≡

begin j ← 0; get next ; while (cur char ≥ ) ∧ (cur char ≤ ) do

begin if j < 7 then begin incr (j); fraction digits [j] ← ´ 10000000 ∗ (cur char − ); end;

get next ;

end; acc ← 0; while j > 0 do

begin acc ← fraction digits [j] + (acc div 10); decr (j); end;

acc ← (acc + 10) div 20; end

This code is used in section 72.

232  STORING THE PROPERTY VALUES  VPtoVF §77

77. Storing the property values. When property values have been found, they are squirreled away in a bunch of arrays. The header information is unpacked into bytes in an array called header bytes . The ligature/kerning program is stored in an array of type four bytes . Another four bytes array holds the specifications of extensible characters. The kerns and parameters are stored in separate arrays of fix word values. Virtual font data goes into an array vf of single-byte values.

We maintain information about at most 256 local fonts. (If this is inadequate, several arrays need to be made longer and we need to output font definitions that go beyond fnt1 and fnt def1 in the file.)

Instead of storing the design size in the header array, we will keep it in a fix word variable until the last minute. The number of units in the design size is also kept in a fix word . ⟨ Globals in the outer block 5 ⟩ +≡ header bytes : array [header index ] of byte; { the header block } header ptr : header index ; { the number of header bytes in use } design size: fix word ; { the design size } design units : fix word ; { reciprocal of the scaling factor } frozen du: boolean; { have we used design units irrevocably? } seven bit safe flag : boolean; { does the file claim to be seven-bit-safe? } lig kern: array [0 . . max lig steps ] of four bytes ; { the ligature program } nl : 0 . . 32767; { the number of ligature/kern instructions so far } min nl : 0 . . 32767; { the final value of nl must be at least this } kern: array [0 . . max kerns ] of fix word ; { the distinct kerning amounts } nk : 0 . . max kerns ; { the number of entries of kern } exten: array [0 . . 255] of four bytes ; { extensible character specs } ne: 0 . . 256; { the number of extensible characters } param: array [1 . . max param words ] of fix word ; { parameters } np: 0 . . max param words ; { the largest parameter set nonzero } check sum specified : boolean; { did the user name the check sum? } bchar : 0 . . 256; { the right boundary character, or 256 if unspecified } vf : array [0 . . vf size] of byte; { stored bytes for file } vf ptr : 0 . . vf size; { first unused location in vf } vtitle start : 0 . . vf size; { starting location of string } vtitle length: byte; { length of string } packet start : array [byte] of 0 . . vf size; { beginning location of character packet } packet length: array [byte] of integer ; { length of character packet } font ptr : 0 . . 256; { number of distinct local fonts seen } cur font : 0 . . 256; { number of the current local font } fname start : array [byte] of 0 . . vf size; { beginning of local font name } fname length: array [byte] of byte; { length of local font name } farea start : array [byte] of 0 . . vf size; { beginning of local font area } farea length: array [byte] of byte; { length of local font area } font checksum: array [byte] of four bytes ; { local font checksum } font number : array [0 . . 256] of four bytes ; { local font id number } font at : array [byte] of fix word ; { local font “at size” } font dsize: array [byte] of fix word ; { local font design size }

78. ⟨ Types in the outer block 23 ⟩ +≡ header index = 0 . . max header bytes ; indx = 0 . . ´ 77777 ;

§80  VPtoVF  STORING THE PROPERTY VALUES 233

79. ⟨ Local variables for initialization 25 ⟩ +≡ d: header index ; { an index into header bytes } 80. We start by setting up the default values.

define check sum loc = 0 define design size loc = 4 define coding scheme loc = 8 define family loc = coding scheme loc + 40 define seven flag loc = family loc + 20 define face loc = seven flag loc + 3

⟨ Set initial values 6 ⟩ +≡ for d ← 0 to 18 ∗ 4 − 1 do header bytes [d] ← 0; header bytes [8] ← 11; header bytes [9] ← ; header bytes [10] ← ; header bytes [11] ← ; header bytes [12] ← ; header bytes [13] ← ; header bytes [14] ← ; header bytes [15] ← ; header bytes [16] ← ; header bytes [17] ← ; header bytes [18] ← ; header bytes [19] ← ; for d ← family loc to family loc + 11 do header bytes [d] ← header bytes [d − 40]; design size ← 10 ∗ unity ; design units ← unity ; frozen du ← false; seven bit safe flag ← false; header ptr ← 18 ∗ 4; nl ← 0; min nl ← 0; nk ← 0; ne ← 0; np ← 0; check sum specified ← false; bchar ← 256; vf ptr ← 0; vtitle start ← 0; vtitle length ← 0; font ptr ← 0; for k ← 0 to 255 do packet start [k] ← vf size; for k ← 0 to 127 do packet length[k] ← 1; for k ← 128 to 255 do packet length[k] ← 2;

81. Most of the dimensions, however, go into the memory array. There are at most 257 widths, 257 heights, 257 depths, and 257 italic corrections, since the value 0 is required but it need not be used. So memory has room for 1028 entries, each of which is a fix word . An auxiliary table called link is used to link these words together in linear lists, so that sorting and other operations can be done conveniently.

We also add four “list head” words to the memory and link arrays; these are in locations width through italic, i.e., 1 through 4. For example, link [height ] points to the smallest element in the sorted list of distinct heights that have appeared so far, and memory [height ] is the number of distinct heights.

define mem size = 1028 + 4 { number of nonzero memory addresses } ⟨ Types in the outer block 23 ⟩ +≡

pointer = 0 . . mem size; { an index into memory }

82. The arrays char wd , char ht , char dp, and char ic contain pointers to the memory array entries where the corresponding dimensions appear. Two other arrays, char tag and char remainder , hold the other information that files pack into a char info word .

define no tag = 0 { vanilla character } define lig tag = 1 { character has a ligature/kerning program } define list tag = 2 { character has a successor in a charlist } define ext tag = 3 { character is extensible } define bchar label ≡ char remainder [256] { beginning of ligature program for left boundary }

⟨ Globals in the outer block 5 ⟩ +≡ memory : array [pointer ] of fix word ; { character dimensions and kerns } mem ptr : pointer ; { largest memory word in use } link : array [pointer ] of pointer ; { to make lists of memory items } char wd : array [byte] of pointer ; { pointers to the widths } char ht : array [byte] of pointer ; { pointers to the heights } char dp: array [byte] of pointer ; { pointers to the depths } char ic: array [byte] of pointer ; { pointers to italic corrections } char tag : array [byte] of no tag . . ext tag ; { character tags } char remainder : array [0 . . 256] of 0 . . 65535;

{ pointers to ligature labels, next larger characters, or extensible characters } 83. ⟨ Local variables for initialization 25 ⟩ +≡ c: byte; { runs through all character codes }

84. ⟨ Set initial values 6 ⟩ +≡ bchar label ← ´ 77777 ; for c ← 0 to 255 do

begin char wd [c] ← 0; char ht [c] ← 0; char dp[c] ← 0; char ic[c] ← 0; char tag [c] ← no tag ; char remainder [c] ← 0; end;

memory [0] ← ´ 17777777777 ; { an “infinite” element at the end of the lists }

memory [width] ← 0; link [width] ← 0; { width list is empty }

memory [height ] ← 0; link [height ] ← 0; { height list is empty }

memory [depth] ← 0; link [depth] ← 0; { depth list is empty }

memory [italic] ← 0; link [italic] ← 0; { italic list is empty }

mem ptr ← italic;

85. As an example of these data structures, let us consider the simple routine that inserts a potentially new element into one of the dimension lists. The first parameter indicates the list head (i.e., h = width for the width list, etc.); the second parameter is the value that is to be inserted into the list if it is not already present. The procedure returns the value of the location where the dimension appears in memory . The fact that memory [0] is larger than any legal dimension makes the algorithm particularly short.

We do have to handle two somewhat subtle situations. A width of zero must be put into the list, so that a zero-width character in the font will not appear to be nonexistent (i.e., so that its char wd index will not be zero), but this does not need to be done for heights, depths, or italic corrections. Furthermore, it is necessary to test for memory overflow even though we have provided room for the maximum number of different dimensions in any legal font, since the file might foolishly give any number of different sizes to the same character. function sort in(h : pointer ; d : fix word ): pointer ; { inserts into list }

var p: pointer ; { the current node of interest }

begin if (d = 0) ∧ (h ≠ width) then sort in ← 0

else begin p ← h; while d ≥ memory [link [p]] do p ← link [p]; if (d = memory [p]) ∧ (p ≠ h) then sort in ← p else if mem ptr = mem size then

begin err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); print ln(´ ␣ ´ ´ ␣ ␣ ␣ ␣ ␣ ´ ); sort in ← p; end

else begin incr (mem ptr ); memory [mem ptr ] ← d; link [mem ptr ] ← link [p]; link [p] ← mem ptr ; incr (memory [h]); sort in ← mem ptr ; end;

end; end; 86. When these lists of dimensions are eventually written to the file, we may have to do some rounding of values, because the file allows at most 256 widths, 16 heights, 16 depths, and 64 italic corrections. The following procedure takes a given list head h and a given dimension d, and returns the minimum m such that the elements of the list can be covered by m intervals of width d. It also sets next d to the smallest value d′ > d such that the covering found by this procedure would be different. In particular, if d = 0 it computes the number of elements of the list, and sets next d to the smallest distance between two list elements. (The covering by intervals of width next d is not guaranteed to have fewer than m elements, but in practice this seems to happen most of the time.) ⟨ Globals in the outer block 5 ⟩ +≡ next d : fix word ; { the next larger interval that is worth trying }

87. Once again we can make good use of the fact that memory [0] is “infinite.” function min cover (h : pointer ; d : fix word ): integer ;

var p: pointer ; { the current node of interest } l: fix word ; { the least element covered by the current interval } m: integer ; { the current size of the cover being generated }

begin m ← 0; p ← link [h]; next d ← memory [0]; while p ≠ 0 do

begin incr (m); l ← memory [p];

while memory [link [p]] ≤ l + d do p ← link [p];

p ← link [p];

if memory [p] − l < next d then next d ← memory [p] − l;

end; min cover ← m; end;

88. The following procedure uses min cover to determine the smallest d such that a given list can be covered with at most a given number of intervals. function shorten(h : pointer ; m : integer ): fix word ; { finds best way to round }

var d: fix word ; { the current trial interval length }

k: integer ; { the size of a minimum cover } begin if memory [h] > m then

begin excess ← memory [h] − m; k ← min cover (h, 0); d ← next d ; { now the answer is at least d } repeat d ← d + d; k ← min cover (h, d); until k ≤ m; { first we ascend rapidly until finding the range } d ← d div 2; k ← min cover (h, d); { now we run through the feasible steps } while k > m do

begin d ← next d ; k ← min cover (h, d); end; shorten ← d; end

else shorten ← 0;

end;

89. When we are nearly ready to output the file, we will set index [p] ← k if the dimension in memory [p] is being rounded to the kth element of its list. ⟨ Globals in the outer block 5 ⟩ +≡ index : array [pointer ] of byte; excess : byte; { number of words to remove, if list is being shortened } 90. Here is the procedure that sets the index values. It also shortens the list so that there is only one element per covering interval; the remaining elements are the midpoints of their clusters. procedure set indices (h : pointer ; d : fix word ); { reduces and indexes a list }

var p: pointer ; { the current node of interest } q: pointer ; { trails one step behind p } m: byte; { index number of nodes in the current interval } l: fix word ; { least value in the current interval }

begin q ← h; p ← link [q]; m ← 0; while p ≠ 0 do

begin incr (m); l ← memory [p]; index [p] ← m; while memory [link [p]] ≤ l + d do

begin p ← link [p]; index [p] ← m; decr (excess ); if excess = 0 then d ← 0; end;

link [q] ← p; memory [p] ← l + (memory [p] − l) div 2; q ← p; p ← link [p]; end;

§91  VPtoVF  THE INPUT PHASE 237

memory [h] ← m; end; 91. The input phase. We’re ready now to read and parse the file, storing property values as we go. ⟨ Globals in the outer block 5 ⟩ +≡ c: byte; { the current character or byte being processed } x: fix word ; { current dimension of interest } k: integer ; { general-purpose index }

92. ⟨ Read all the input 92 ⟩ ≡ cur char ← ␣ ; repeat while cur char = ␣ do get next ;

if cur char = then ⟨ Read a font property value 94 ⟩

else if (cur char = ) ∧ ¬input has ended then begin err print (´ ␣ ␣ ´ ); incr (loc); cur char ← ␣ ; end

else if ¬input has ended then junk error ;

until input has ended

This code is used in section 180.

93. The junk error routine just referred to is called when something appears in the forbidden area between properties of a property list. procedure junk error ; { gets past no man’s land }

begin err print (´ ´ ´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); skip to paren; end;

94. For each font property, we are supposed to read the data from the left parenthesis that is the current value of cur char to the right parenthesis that matches it in the input. The main complication is to recover with reasonable grace from various error conditions that might arise. ⟨ Read a font property value 94 ⟩ ≡

begin get name;

if cur code = comment code then skip to end of item

else if cur code > character code then

flush error (´ ␣ ␣ ␣ ´ ´ ␣ ␣ ␣ ␣ ␣ ´ ) else begin ⟨ Read the font property value specified by cur code 95 ⟩;

finish the property ;

end; end

This code is used in section 92.

238  THE INPUT PHASE  VPtoVF §95

95. ⟨ Read the font property value specified by cur code 95 ⟩ ≡

case cur code of

check sum code: begin check sum specified ← true; read four bytes (check sum loc);

end; design size code: ⟨ Read the design size 98 ⟩; design units code: ⟨ Read the design units 99 ⟩; coding scheme code: read BCPL(coding scheme loc, 40); family code: read BCPL(family loc, 20); face code: header bytes [face loc] ← get byte; seven bit safe flag code: ⟨ Read the seven-bit-safe flag 100 ⟩; header code: ⟨ Read an indexed header word 101 ⟩; font dimen code: ⟨ Read font parameter list 102 ⟩; lig table code: read lig kern; boundary char code: bchar ← get byte; virtual title code: begin vtitle start ← vf ptr ; copy to end of item;

if vf ptr > vtitle start + 255 then begin err print (´ ␣ ␣ ␣ ␣ ´ ); vtitle length ← 255; end

else vtitle length ← vf ptr − vtitle start ; end;

map font code: ⟨ Read a local font list 104 ⟩; character code: read char info; end

This code is used in section 94.

96. The case statement just given makes use of three subroutines that we haven’t defined yet. The first of these puts a 32-bit octal quantity into four specified bytes of the header block. procedure read four bytes (l : header index );

begin get four bytes ; header bytes [l] ← c0 ; header bytes [l + 1] ← c1 ; header bytes [l + 2] ← c2 ; header bytes [l + 3] ← c3 ; end; 97. The second little procedure is used to scan a string and to store it in the “BCPL format” required by files. The string is supposed to contain at most n bytes, including the first byte (which holds the length of the rest of the string). procedure read BCPL(l : header index ; n : byte);

var k: header index ; begin k ← l; while cur char = ␣ do get next ; while (cur char ≠ ) ∧ (cur char ≠ ) do

begin if k < l + n then incr (k);

if k < l + n then header bytes [k] ← cur char ;

get next ;

end; if k = l + n then

begin err print (´ ␣ ␣ ␣ ␣ ␣ ␣´ , n − 1 : 1, ´ ␣ ␣ ␣ ␣ ´ ); decr (k); end;

header bytes [l] ← k − l; while k < l + n − 1 do { tidy up the remaining bytes by setting them to nulls }

begin incr (k); header bytes [k] ← 0;

end; end;

98. ⟨ Read the design size 98 ⟩ ≡ begin next d ← get fix ; if next d < unity then err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ) else design size ← next d ; end

This code is used in section 95.

99. ⟨ Read the design units 99 ⟩ ≡ begin next d ← get fix ; if next d ≤ 0 then err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ) else if frozen du then err print (´ ␣ ´ ´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ )

else design units ← next d ; end

This code is used in section 95.

100. ⟨ Read the seven-bit-safe flag 100 ⟩ ≡ begin while cur char = ␣ do get next ; if cur char = then seven bit safe flag ← true else if cur char = then seven bit safe flag ← false

else err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); skip to paren; end

This code is used in section 95.

101. ⟨ Read an indexed header word 101 ⟩ ≡ begin c ← get byte; if c < 18 then skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ´ ) else if 4 ∗ c + 4 > max header bytes then

skip error (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ) else begin while header ptr < 4 ∗ c + 4 do

begin header bytes [header ptr ] ← 0; incr (header ptr ); end;

read four bytes (4 ∗ c);

end; end

This code is used in section 95.

102. The remaining kinds of font property values that need to be read are those that involve property lists on higher levels. Each of these has a loop similar to the one that was used at level zero. Then we put the right parenthesis back so that ‘finish the property ’ will be happy; there is probably a more elegant way to do this.

define finish inner property list ≡ begin decr (loc); incr (level ); cur char ← ; end

⟨ Read font parameter list 102 ⟩ ≡

begin while level = 1 do begin while cur char = ␣ do get next ; if cur char = then ⟨ Read a parameter value 103 ⟩ else if cur char = then skip to end of item

else junk error ; end;

finish inner property list ; end

This code is used in section 95.

103. ⟨ Read a parameter value 103 ⟩ ≡ begin get name; if cur code = comment code then skip to end of item else if (cur code < parameter code) ∨ (cur code ≥ char wd code) then

flush error (´ ␣ ␣ ␣ ´ ´ ␣ ␣ ␣ ␣ ␣ ´ ) else begin if cur code = parameter code then c ← get byte

else c ← cur code − parameter code;

if c = 0 then flush error (´ ␣ ␣ ␣ ␣ ␣ ´ )

else if c > max param words then

flush error (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ) else begin while np < c do

begin incr (np); param[np] ← 0; end;

param[c] ← get fix ; finish the property ;

end; end;

end

This code is used in section 102.

104. define numbers differ ≡ (font number [cur font ].b3 ≠ font number [font ptr ].b3 ) ∨ (font number [cur font ].b2 ≠ font number [font ptr ].b2 ) ∨ (font number [cur font ].b1 ≠ font number [font ptr ].b1 ) ∨ (font number [cur font ].b0 ≠ font number [font ptr ].b0 )

⟨ Read a local font list 104 ⟩ ≡ begin get four bytes ; font number [font ptr ] ← cur bytes ; cur font ← 0; while numbers differ do incr (cur font ); if cur font = font ptr then { it’s a new font number }

if font ptr < 256 then ⟨ Initialize a new local font 105 ⟩

else err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); if cur font = font ptr then skip to end of item else while level = 1 do

begin while cur char = ␣ do get next ;

if cur char = then ⟨ Read a local font property 106 ⟩

else if cur char = then skip to end of item

else junk error ; end;

finish inner property list ; end

This code is used in section 95.

105. ⟨ Initialize a new local font 105 ⟩ ≡ begin incr (font ptr ); fname start [cur font ] ← vf size; fname length[cur font ] ← 4; { } farea start [cur font ] ← vf size; farea length[cur font ] ← 0; font checksum[cur font ] ← zero bytes ; font at [cur font ] ← ´ 4000000 ; { denotes design size of this virtual font } font dsize[cur font ] ← ´ 50000000 ; { the fix word for 10 } end

This code is used in section 104.

106. ⟨ Read a local font property 106 ⟩ ≡ begin get name; if cur code = comment code then skip to end of item else if (cur code < font name code) ∨ (cur code > font dsize code) then

flush error (´ ␣ ␣ ␣ ´ ´ ␣ ␣ ␣ ␣ ␣ ´ )

else begin case cur code of

font name code: ⟨ Read a local font name 107 ⟩; font area code: ⟨ Read a local font area 108 ⟩; font checksum code: begin get four bytes ; font checksum[cur font ] ← cur bytes ;

end; font at code: begin frozen du ← true;

if design units = unity then font at [cur font ] ← get fix

else font at [cur font ] ← round ((get fix /design units ) ∗ 1048576.0); end;

font dsize code: font dsize[cur font ] ← get fix ;

end; { there are no other cases }

finish the property ;

end; end

This code is used in section 104.

107. ⟨ Read a local font name 107 ⟩ ≡ begin fname start [cur font ] ← vf ptr ; copy to end of item; if vf ptr > fname start [cur font ] + 255 then

begin err print (´ ␣ ␣ ␣ ␣ ´ ); fname length[cur font ] ← 255; end

else fname length[cur font ] ← vf ptr − fname start [cur font ]; end

This code is used in section 106.

108. ⟨ Read a local font area 108 ⟩ ≡ begin farea start [cur font ] ← vf ptr ; copy to end of item; if vf ptr > farea start [cur font ] + 255 then

begin err print (´ ␣ ␣ ␣ ␣ ´ ); farea length[cur font ] ← 255; end

else farea length[cur font ] ← vf ptr − farea start [cur font ]; end

This code is used in section 106.

109. ⟨ Read ligature/kern list 109 ⟩ ≡

begin while level = 1 do begin while cur char = ␣ do get next ; if cur char = then ⟨ Read a ligature/kern command 110 ⟩ else if cur char = then skip to end of item

else junk error ; end;

finish inner property list ; end

This code is used in section 180.

110. ⟨ Read a ligature/kern command 110 ⟩ ≡ begin get name; if cur code = comment code then skip to end of item else if cur code < label code then

flush error (´ ␣ ␣ ␣ ´ ´ ␣ ␣ ␣ ␣ ␣ ´ )

else begin case cur code of

label code: ⟨ Read a label step 112 ⟩; stop code: ⟨ Read a stop step 114 ⟩; skip code: ⟨ Read a skip step 115 ⟩; krn code: ⟨ Read a kerning step 117 ⟩; lig code, lig code + 1, lig code + 2, lig code + 3, lig code + 5, lig code + 6, lig code + 7, lig code + 11:

⟨ Read a ligature step 116 ⟩; end; { there are no other cases ≥ label code } finish the property ; end;

end

This code is used in section 109.

111. When a character is about to be tagged, we call the following procedure so that an error message is given in case of multiple tags. procedure check tag (c : byte); { print error if c already tagged }

begin case char tag [c] of no tag : do nothing ; lig tag : err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); list tag : err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); ext tag : err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); end; end;

112. ⟨ Read a label step 112 ⟩ ≡ begin while cur char = ␣ do get next ; if cur char = then

begin bchar label ← nl ; skip to paren; { }

end else begin backup; c ← get byte; check tag (c); char tag [c] ← lig tag ; char remainder [c] ← nl ;

end; if min nl ≤ nl then min nl ← nl + 1; lk step ended ← false; end

This code is used in section 110.

113. define stop flag = 128 { value indicating ‘ ’ in a lig/kern program } define kern flag = 128 { op code for a kern step }

⟨ Globals in the outer block 5 ⟩ +≡ lk step ended : boolean; { was the last property or ? } krn ptr : 0 . . max kerns ; { an index into kern }

114. ⟨ Read a stop step 114 ⟩ ≡ if ¬lk step ended then err print (´ ␣ ␣ ␣ ␣ ␣ ´ ) else begin lig kern[nl − 1].b0 ← stop flag ; lk step ended ← false;

end

This code is used in section 110.

115. ⟨ Read a skip step 115 ⟩ ≡ if ¬lk step ended then err print (´ ␣ ␣ ␣ ␣ ␣ ´ ) else begin c ← get byte;

if c ≥ 128 then err print (´ ␣ ␣ ␣ ␣ ´ )

else if nl + c ≥ max lig steps then err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ )

else begin lig kern[nl − 1].b0 ← c; if min nl ≤ nl + c then min nl ← nl + c + 1; end;

lk step ended ← false;

end

This code is used in section 110.

116. ⟨ Read a ligature step 116 ⟩ ≡ begin lig kern[nl ].b0 ← 0; lig kern[nl ].b2 ← cur code − lig code; lig kern[nl ].b1 ← get byte; lig kern[nl ].b3 ← get byte; if nl ≥ max lig steps − 1 then err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ) else incr (nl ); lk step ended ← true; end

This code is used in section 110.

117. ⟨ Read a kerning step 117 ⟩ ≡ begin lig kern[nl ].b0 ← 0; lig kern[nl ].b1 ← get byte; kern[nk ] ← get fix ; krn ptr ← 0; while kern[krn ptr ] ≠ kern[nk ] do incr (krn ptr ); if krn ptr = nk then

begin if nk < max kerns then incr (nk )

else begin err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); decr (krn ptr );

end; end;

lig kern[nl ].b2 ← kern flag + (krn ptr div 256); lig kern[nl ].b3 ← krn ptr mod 256; if nl ≥ max lig steps − 1 then err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ´ ) else incr (nl ); lk step ended ← true; end

This code is used in section 110.

118. Finally we come to the part of ’s input mechanism that is used most, the processing of individual character data. ⟨ Read character info list 118 ⟩ ≡

begin c ← get byte; { read the character code that is being specified } ⟨ Print c in octal notation 137 ⟩; while level = 1 do

begin while cur char = ␣ do get next ;

if cur char = then ⟨ Read a character property 119 ⟩

else if cur char = then skip to end of item

else junk error ; end;

if char wd [c] = 0 then char wd [c] ← sort in(width, 0); { legitimatize c } finish inner property list ; end

This code is used in section 180.

119. ⟨ Read a character property 119 ⟩ ≡ begin get name; if cur code = comment code then skip to end of item else if (cur code < char wd code) ∨ (cur code > var char code) then

flush error (´ ␣ ␣ ␣ ´ ´ ␣ ␣ ␣ ␣ ␣ ´ )

else begin case cur code of

char wd code: char wd [c] ← sort in(width, get fix ); char ht code: char ht [c] ← sort in(height , get fix ); char dp code: char dp[c] ← sort in(depth, get fix ); char ic code: char ic[c] ← sort in(italic, get fix ); next larger code: begin check tag (c); char tag [c] ← list tag ; char remainder [c] ← get byte;

end; map code: read packet (c); var char code: ⟨ Read an extensible recipe for c 120 ⟩; end; finish the property ; end;

end

This code is used in section 118.

120. ⟨ Read an extensible recipe for c 120 ⟩ ≡ begin if ne = 256 then err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ´ ) else begin check tag (c); char tag [c] ← ext tag ; char remainder [c] ← ne;

exten[ne] ← zero bytes ; while level = 2 do

begin while cur char = ␣ do get next ; if cur char = then ⟨ Read an extensible piece 121 ⟩ else if cur char = then skip to end of item

else junk error ; end;

incr (ne); finish inner property list ; end;

end

This code is used in section 119.

121. ⟨ Read an extensible piece 121 ⟩ ≡ begin get name; if cur code = comment code then skip to end of item else if (cur code < var char code + 1) ∨ (cur code > var char code + 4) then

flush error (´ ␣ ␣ ␣ ´ ´ ␣ ␣ ␣ ␣ ␣ ´ ) else begin case cur code − (var char code + 1) of

0: exten[ne].b0 ← get byte; 1: exten[ne].b1 ← get byte; 2: exten[ne].b2 ← get byte; 3: exten[ne].b3 ← get byte; end; finish the property ; end;

end

This code is used in section 120.

246  ASSEMBLING THE MAPPINGS  VPtoVF §122
122. Assembling the mappings. Each  property is a sequence of  instructions, for which we

need to know some of the opcodes.

define set char 0 = 0 { command to typeset character 0 and move right } define set1 = 128 { typeset a character and move right } define set rule = 132 { typeset a rule and move right } define push = 141 { save the current positions } define pop = 142 { restore previous positions } define right1 = 143 { move right } define w0 = 147 { move right by w } define w1 = 148 { move right and set w } define x0 = 152 { move right by x } define x1 = 153 { move right and set x } define down1 = 157 { move down } define y0 = 161 { move down by y } define y1 = 162 { move down and set y } define z0 = 166 { move down by z } define z1 = 167 { move down and set z } define fnt num 0 = 171 { set current font to 0 } define fnt1 = 235 { set current font } define xxx1 = 239 { extension to primitives } define xxx4 = 242 { potentially long extension to primitives } define fnt def1 = 243 { define the meaning of a font number } define pre = 247 { preamble } define post = 248 { postamble beginning }

§124  VPtoVF  ASSEMBLING THE MAPPINGS 247

123. We keep stacks of movement values, in order to optimize the code in simple cases. ⟨ Globals in the outer block 5 ⟩ +≡ hstack : array [0 . . max stack ] of 0 . . 2; { number of known horizontal movements } vstack : array [0 . . max stack ] of 0 . . 2; { number of known vertical movements } wstack , xstack , ystack , zstack : array [0 . . max stack ] of fix word ; stack ptr : 0 . . max stack ; 124. The packet is built by straightforward assembly of instructions.

⟨ Declare the vf fix procedure 128 ⟩ procedure read packet (c : byte);

var cc: byte; { character being typeset } x: fix word ; { movement } h, v: 0 . . 2; { top of hstack and vstack } special start : 0 . . vf size; { location of xxx1 command } k: 0 . . vf size; { loop index }

begin packet start [c] ← vf ptr ; stack ptr ← 0; h ← 0; v ← 0; cur font ← 0; while level = 2 do

begin while cur char = ␣ do get next ;

if cur char = then ⟨ Read and assemble a list of commands 125 ⟩ else if cur char = then skip to end of item

else junk error ; end;

while stack ptr > 0 do begin err print (´ ␣ ␣ ´ ); vf store(pop); decr (stack ptr ); end;

packet length[c] ← vf ptr − packet start [c]; finish inner property list ; end;

125. ⟨ Read and assemble a list of commands 125 ⟩ ≡ begin get name; if cur code = comment code then skip to end of item else if (cur code < select font code) ∨ (cur code > special hex code) then

flush error (´ ␣ ␣ ␣ ´ ´ ␣ ␣ ␣ ␣ ␣ ´ )

else begin case cur code of

select font code: ⟨ Assemble a font selection 126 ⟩;

set char code: ⟨ Assemble a typesetting instruction 127 ⟩; set rule code: ⟨ Assemble a rulesetting instruction 129 ⟩; move right code, move right code + 1: ⟨ Assemble a horizontal movement 130 ⟩; move down code, move down code + 1: ⟨ Assemble a vertical movement 131 ⟩; push code: ⟨ Assemble a stack push 132 ⟩; pop code: ⟨ Assemble a stack pop 133 ⟩; special code, special hex code: ⟨ Assemble a special command 134 ⟩; end; finish the property ; end;

end

This code is used in section 124.

126. ⟨ Assemble a font selection 126 ⟩ ≡ begin get four bytes ; font number [font ptr ] ← cur bytes ; cur font ← 0; while numbers differ do incr (cur font ); if cur font = font ptr then err print (´ ␣ ␣ ␣ ␣ ´ ) else if cur font < 64 then vf store(fnt num 0 + cur font )

else begin vf store(fnt1 ); vf store(cur font );

end; end

This code is used in section 125.

127. ⟨ Assemble a typesetting instruction 127 ⟩ ≡ if cur font = font ptr then err print (´ ␣ ␣ ␣ ␣ ␣ ␣ ´ ) else begin cc ← get byte;

if cc ≥ 128 then vf store(set1 );

vf store(cc);

end

This code is used in section 125.

128. Here’s a procedure that converts a fix word to a sequence of bytes. ⟨ Declare the vf fix procedure 128 ⟩ ≡ procedure vf fix (opcode : byte; x : fix word );

var negative: boolean; k: 0 . . 4; { number of bytes to typeset }

t: integer ; { threshold } begin frozen du ← true; if design units ≠ unity then x ← round ((x/design units ) ∗ 1048576.0); if x > 0 then negative ← false else begin negative ← true; x ← −1 − x; end; if opcode = 0 then

begin k ← 4; t ← ´ 100000000 ; end else begin t ← 127; k ← 1;

while x > t do begin t ← 256 ∗ t + 255; incr (k); end;

vf store(opcode + k − 1); t ← t div 128 + 1;

end;

repeat if negative then

begin vf store(255 − (x div t)); negative ← false; x ← (x div t) ∗ t + t − 1 − x; end

else vf store((x div t) mod 256);

decr (k); t ← t div 256; until k = 0; end;

This code is used in section 124.

129. ⟨ Assemble a rulesetting instruction 129 ⟩ ≡ begin vf store(set rule); vf fix (0, get fix ); vf fix (0, get fix ); end

This code is used in section 125.

130. ⟨ Assemble a horizontal movement 130 ⟩ ≡ begin if cur code = move right code then x ← get fix else x ← −get fix ; if h = 0 then

begin wstack [stack ptr ] ← x; h ← 1; vf fix (w1 , x); end else if x = wstack [stack ptr ] then vf store(w0 )

else if h = 1 then

begin xstack [stack ptr ] ← x; h ← 2; vf fix (x1 , x); end else if x = xstack [stack ptr ] then vf store(x0 )

else vf fix (right1 , x); end

This code is used in section 125.

131. ⟨ Assemble a vertical movement 131 ⟩ ≡ begin if cur code = move down code then x ← get fix else x ← −get fix ; if v = 0 then

begin ystack [stack ptr ] ← x; v ← 1; vf fix (y1 , x); end else if x = ystack [stack ptr ] then vf store(y0 )

else if v = 1 then

begin zstack [stack ptr ] ← x; v ← 2; vf fix (z1 , x); end else if x = zstack [stack ptr ] then vf store(z0 )

else vf fix (down1 , x); end

This code is used in section 125.

132. ⟨ Assemble a stack push 132 ⟩ ≡

if stack ptr = max stack then { too pushy }

err print (´ ´ ´ ␣ ␣ ␣ ␣ ␣ ´ ) else begin vf store(push); hstack [stack ptr ] ← h; vstack [stack ptr ] ← v; incr (stack ptr ); h ← 0; v ← 0;

end

This code is used in section 125.

133. ⟨ Assemble a stack pop 133 ⟩ ≡ if stack ptr = 0 then err print (´ ␣ ␣ ␣ ␣ ´ ) else begin vf store(pop); decr (stack ptr ); h ← hstack [stack ptr ]; v ← vstack [stack ptr ];

end

This code is used in section 125.

134. ⟨ Assemble a special command 134 ⟩ ≡ begin vf store(xxx1 ); vf store(0); { dummy length } special start ← vf ptr ; if cur code = special code then copy to end of item else begin repeat x ← get hex ;

if cur char > then vf store(x ∗ 16 + get hex ); until cur char ≤ ; end;

if vf ptr − special start > 255 then ⟨ Convert xxx1 command to xxx4 135 ⟩ else vf [special start − 1] ← vf ptr − special start ; end

This code is used in section 125.

135. ⟨ Convert xxx1 command to xxx4 135 ⟩ ≡

if vf ptr + 3 > vf size then begin err print (´ ␣ ␣ ␣ ␣ ␣ ´ ); vf ptr ← special start + 255; vf [special start − 1] ← 255; end

else begin for k ← vf ptr downto special start do vf [k + 3] ← vf [k]; x ← vf ptr − special start ; vf ptr ← vf ptr + 3; vf [special start − 2] ← xxx4 ; vf [special start − 1] ← x div ´ 100000000 ; vf [special start ] ← (x div ´ 200000 ) mod 256; vf [special start + 1] ← (x div ´ 400 ) mod 256; vf [special start + 2] ← x mod 256; end

This code is used in section 134.

136. The input routine is now complete except for the following code, which prints a progress report as the file is being read. procedure print octal (c : byte); { prints three octal digits }

begin print (´ ´ ´ ´ , (c div 64) : 1, ((c div 8) mod 8) : 1, (c mod 8) : 1); end;

137. ⟨ Print c in octal notation 137 ⟩ ≡

begin if chars on line = 8 then begin print ln(´ ␣´ ); chars on line ← 1; end

else begin if chars on line > 0 then print (´ ␣´ ); incr (chars on line); end;

print octal (c); { progress report } end

This code is used in section 118.

§138  VPtoVF  THE CHECKING AND MASSAGING PHASE 251

138. The checking and massaging phase. Once the whole file has been read in, we must check it for consistency and correct any errors. This process consists mainly of running through the characters that exist and seeing if they refer to characters that don’t exist. We also compute the true value of seven unsafe; we make sure that the charlists and ligature programs contain no loops; and we shorten the lists of widths, heights, depths, and italic corrections, if necessary, to keep from exceeding the required maximum sizes. ⟨ Globals in the outer block 5 ⟩ +≡ seven unsafe: boolean; { do seven-bit characters generate eight-bit ones? }

139. ⟨ Correct and check the information 139 ⟩ ≡ if nl > 0 then ⟨ Make sure the ligature/kerning program ends appropriately 145 ⟩; seven unsafe ← false; for c ← 0 to 255 do

if char wd [c] ≠ 0 then ⟨ For all characters g generated by c, make sure that char wd [g] is nonzero,

and set seven unsafe if c < 128 ≤ g 140 ⟩;

if bchar label < ´ 77777 then begin c ← 256; ⟨ Check ligature program of c 149 ⟩; end;

if seven bit safe flag ∧ seven unsafe then print ln(´ ␣ ␣ ␣ ␣ ␣ ´ ); ⟨ Check for infinite ligature loops 154 ⟩; ⟨ Doublecheck the lig/kern commands and the extensible recipes 155 ⟩; for c ← 0 to 255 do ⟨ Make sure that c is not the largest element of a charlist cycle 142 ⟩; ⟨ Put the width, height, depth, and italic lists into final form 144 ⟩

This code is used in section 180.

140. The checking that we need in several places is accomplished by three macros that are only slightly tricky.

define existence tail (#) ≡ begin char wd [g] ← sort in(width, 0); print (#, ´ ␣´ ); print octal (c); print ln(´ ␣ ␣ ␣ ␣ ´ ); end; end

define check existence and safety (#) ≡ begin g ← #; if (g ≥ 128) ∧ (c < 128) then seven unsafe ← true; if char wd [g] = 0 then existence tail

define check existence(#) ≡ begin g ← #; if char wd [g] = 0 then existence tail

⟨ For all characters g generated by c, make sure that char wd [g] is nonzero, and set seven unsafe if

c < 128 ≤ g 140 ⟩ ≡ case char tag [c] of no tag : do nothing ; lig tag : ⟨ Check ligature program of c 149 ⟩; list tag : check existence and safety (char remainder [c])(´ ␣ ␣ ␣ ´ ); ext tag : ⟨ Check the pieces of exten[c] 141 ⟩; end

This code is used in section 139.

252  THE CHECKING AND MASSAGING PHASE  VPtoVF §141

141. ⟨ Check the pieces of exten[c] 141 ⟩ ≡

begin if exten[char remainder [c]].b0 > 0 then

check existence and safety (exten[char remainder [c]].b0 )(´ ␣ ␣ ␣ ´ ); if exten[char remainder [c]].b1 > 0 then

check existence and safety (exten[char remainder [c]].b1 )(´ ␣ ␣ ␣ ´ ); if exten[char remainder [c]].b2 > 0 then

check existence and safety (exten[char remainder [c]].b2 )(´ ␣ ␣ ␣ ´ ); check existence and safety (exten[char remainder [c]].b3 )(´ ␣ ␣ ␣ ´ ); end

This code is used in section 140.

142. ⟨ Make sure that c is not the largest element of a charlist cycle 142 ⟩ ≡

if char tag [c] = list tag then begin g ← char remainder [c]; while (g < c) ∧ (char tag [g] = list tag ) do g ← char remainder [g]; if g = c then

begin char tag [c] ← no tag ;

print (´ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣´ ); print octal (c); print ln(´ ´ ); end;

end

This code is used in section 139.

143. ⟨ Globals in the outer block 5 ⟩ +≡ delta: fix word ; { size of the intervals needed for rounding }

144. define round message(#) ≡

if delta > 0 then

print ln(´ ␣ ␣ ␣ ␣ ␣´ , #, ´ ␣ ␣´ , (((delta +1)div2)/´ 4000000 ) : 1 : 7, ´ ␣ ´ )

⟨ Put the width, height, depth, and italic lists into final form 144 ⟩ ≡ delta ← shorten(width, 255); set indices (width, delta); round message(´ ´ ); delta ← shorten(height , 15); set indices (height , delta); round message(´ ´ ); delta ← shorten(depth, 15); set indices (depth, delta); round message(´ ´ ); delta ← shorten(italic, 63); set indices (italic, delta); round message(´ ␣ ´ );

This code is used in section 139.

145. define clear lig kern entry ≡ { make an unconditional } lig kern[nl ].b0 ← 255; lig kern[nl ].b1 ← 0; lig kern[nl ].b2 ← 0; lig kern[nl ].b3 ← 0

⟨ Make sure the ligature/kerning program ends appropriately 145 ⟩ ≡

begin if bchar label < ´ 77777 then { make room for it } begin clear lig kern entry ; incr (nl ); end; { bchar label will be stored later }

while min nl > nl do begin clear lig kern entry ; incr (nl ); end;

if lig kern[nl − 1].b0 = 0 then lig kern[nl − 1].b0 ← stop flag ; end

This code is used in section 139.

146. It’s not trivial to check for infinite loops generated by repeated insertion of ligature characters. But fortunately there is a nice algorithm for such testing, copied here from the program where it is explained further.

define simple = 0 { f(x, y) = z }

define left z = 1 { f(x, y) = f(z, y) }

define right z = 2 { f(x, y) = f(x, z) }

define both z = 3 { f(x, y) = f(f(x, z), y) } define pending = 4 { f(x, y) is being evaluated }

147. ⟨ Globals in the outer block 5 ⟩ +≡ lig ptr : 0 . . max lig steps ; { an index into lig kern } hash: array [0 . . hash size] of 0 . . 66048; { 256x + y + 1 for x ≤ 257 and y ≤ 255 } class : array [0 . . hash size] of simple . . pending ; lig z : array [0 . . hash size] of 0 . . 257; hash ptr : 0 . . hash size; { the number of nonzero entries in hash } hash list : array [0 . . hash size] of 0 . . hash size; { list of those nonzero entries } h, hh: 0 . . hash size; { indices into the hash table } tt : indx ; { temporary register } x lig cycle, y lig cycle: 0 . . 256; { problematic ligature pair }

148. ⟨ Set initial values 6 ⟩ +≡ hash ptr ← 0; y lig cycle ← 256; for k ← 0 to hash size do hash[k] ← 0;

149. define lig exam ≡ lig kern[lig ptr ].b1 define lig gen ≡ lig kern[lig ptr ].b3

⟨ Check ligature program of c 149 ⟩ ≡ begin lig ptr ← char remainder [c]; repeat if hash input (lig ptr , c) then

begin if lig kern[lig ptr ].b2 < kern flag then begin if lig exam ≠ bchar then check existence(lig exam)(´ ␣ ␣ ␣ ´ ); check existence(lig gen)(´ ␣ ␣ ␣ ´ ); if lig gen ≥ 128 then

if (c < 128) ∨ (c = 256) then

if (lig exam < 128) ∨ (lig exam = bchar ) then seven unsafe ← true; end

else if lig exam ≠ bchar then check existence(lig exam)(´ ␣ ␣ ␣ ´ ); end;

if lig kern[lig ptr ].b0 ≥ stop flag then lig ptr ← nl else lig ptr ← lig ptr + 1 + lig kern[lig ptr ].b0 ;

until lig ptr ≥ nl ;

end

This code is used in sections 139 and 140.

150. The hash input procedure is copied from , but it is made into a boolean function that returns false if the ligature command was masked by a previous one. function hash input (p, c : indx ): boolean;

{ enter data for character c and command in location p, unless it isn’t new } label 30; { go here for a quick exit } var cc: simple . . both z ; { class of data being entered }

zz : 0 . . 255; { function value or ligature character being entered } y: 0 . . 255; { the character after the cursor } key : integer ; { value to be stored in hash } t: integer ; { temporary register for swapping }

begin if hash ptr = hash size then

begin hash input ← false; goto 30; end; ⟨ Compute the command parameters y, cc, and zz 151 ⟩; key ← 256 ∗ c + y + 1; h ← (1009 ∗ key ) mod hash size; while hash[h] > 0 do

begin if hash[h] ≤ key then

begin if hash[h] = key then begin hash input ← false; goto 30; { unused ligature command } end;

t ← hash[h]; hash[h] ← key ; key ← t; { do ordered-hash-table insertion } t ← class [h]; class [h] ← cc; cc ← t; { namely, do a swap } t ← lig z [h]; lig z [h] ← zz ; zz ← t; end;

if h > 0 then decr (h) else h ← hash size; end;

hash[h] ← key ; class [h] ← cc; lig z [h] ← zz ; incr (hash ptr ); hash list [hash ptr ] ← h; hash input ← true;

30: end;

151. ⟨ Compute the command parameters y, cc, and zz 151 ⟩ ≡ y ← lig kern[p].b1 ; t ← lig kern[p].b2 ; cc ← simple; zz ← lig kern[p].b3 ; if t ≥ kern flag then zz ← y

else begin case t of

0, 6: do nothing ; { , }

5, 11: zz ← y; {  ,  }
1, 7: cc ← left z ; {  ,  }

2: cc ← right z ; { } 3: cc ← both z ; { } end; { there are no other cases } end

This code is used in section 150.

152. (More good stuff from .) function f(h, x, y : indx ): indx ; forward ; { compute f for arguments known to be in hash[h] } function eval (x, y : indx ): indx ; { compute f(x, y) with hashtable lookup }

var key : integer ; { value sought in hash table } begin key ← 256 ∗ x + y + 1; h ← (1009 ∗ key ) mod hash size; while hash[h] > key do

if h > 0 then decr (h) else h ← hash size; if hash[h] < key then eval ← y { not in ordered hash table } else eval ← f(h, x, y); end;

153. Pascal’s beastly convention for forward declarations prevents us from saying function f(h, x, y : indx ): indx here. function f;

begin case class [h] of simple: do nothing ; left z : begin class [h] ← pending ; lig z [h] ← eval (lig z [h], y); class [h] ← simple;

end; right z : begin class [h] ← pending ; lig z [h] ← eval (x, lig z [h]); class [h] ← simple;

end; both z : begin class [h] ← pending ; lig z [h] ← eval (eval (x, lig z [h]), y); class [h] ← simple;

end; pending : begin x lig cycle ← x; y lig cycle ← y; lig z [h] ← 257; class [h] ← simple;

end; { the value 257 will break all cycles, since it’s not in hash } end; { there are no other cases } f ← lig z [h]; end;

154. ⟨ Check for infinite ligature loops 154 ⟩ ≡

if hash ptr < hash size then

for hh ← 1 to hash ptr do begin tt ← hash list [hh]; if class [tt ] > simple then { make sure f is well defined } tt ← f(tt , (hash[tt ] − 1) div 256, (hash[tt ] − 1) mod 256);

end; if (hash ptr = hash size) ∨ (y lig cycle < 256) then

begin if hash ptr < hash size then begin print (´ ␣ ␣ ␣ ␣ ␣´ ); if x lig cycle = 256 then print (´ ´ ) else print octal (x lig cycle); print (´ ␣ ␣´ ); print octal (y lig cycle); print ln(´ ´ ); end

else print ln(´ ␣ ␣ ´ ´ ␣ ␣ ␣ ␣ ␣ ␣ ´ ); print ln(´ ␣ ␣ ␣ ␣ ´ ); for c ← 0 to 255 do

if char tag [c] = lig tag then begin char tag [c] ← no tag ; char remainder [c] ← 0; end;

nl ← 0; bchar ← 256; bchar label ← ´ 77777 ;

end

This code is used in section 139.

155. The lig/kern program may still contain references to nonexistent characters, if parts of that program are never used. Similarly, there may be extensible characters that are never used, because they were overridden by , say. This would produce an invalid file; so we must fix such errors.

define double check tail (#) ≡

if char wd [0] = 0 then char wd [0] ← sort in(width, 0); print (´ ␣´ , #, ´ ␣ ␣ ␣ ␣ ␣´ ); print octal (c); print ln(´ ´ ); end ; end

define double check lig (#) ≡ begin c ← lig kern[lig ptr ].#; if char wd [c] = 0 then

if c ≠ bchar then

begin lig kern[lig ptr ].# ← 0; double check tail

define double check ext (#) ≡ begin c ← exten[g].#; if c > 0 then

if char wd [c] = 0 then

begin exten[g].# ← 0; double check tail

define double check rep(#) ≡ begin c ← exten[g].#; if char wd [c] = 0 then

begin exten[g].# ← 0; double check tail

⟨ Doublecheck the lig/kern commands and the extensible recipes 155 ⟩ ≡

if nl > 0 then

for lig ptr ← 0 to nl − 1 do

if lig kern[lig ptr ].b2 < kern flag then

begin if lig kern[lig ptr ].b0 < 255 then begin double check lig (b1 )(´ ␣ ´ ); double check lig (b3 )(´ ␣ ´ ); end;

end else double check lig (b1 )(´ ␣ ´ );

if ne > 0 then

for g ← 0 to ne − 1 do begin double check ext (b0 )(´ ␣ ´ ); double check ext (b1 )(´ ␣ ´ ); double check ext (b2 )(´ ␣ ´ ); double check rep(b3 )(´ ␣ ´ ); end

This code is used in section 139.

§156  VPtoVF  THE TFM OUTPUT PHASE 257

156. The TFM output phase. Now that we know how to get all of the font data correctly stored in ’s memory, it only remains to write the answers out.

First of all, it is convenient to have an abbreviation for output to the file:

define out (#) ≡ write(tfm file, #)

157. The general plan for producing files is long but simple: ⟨ Do the output 157 ⟩ ≡

⟨ Compute the twelve subfile sizes 159 ⟩;

⟨ Output the twelve subfile sizes 160 ⟩;

⟨ Output the header block 162 ⟩;

⟨ Output the character info 164 ⟩;

⟨ Output the dimensions themselves 166 ⟩;

⟨ Output the ligature/kern program 171 ⟩;

⟨ Output the extensible character recipes 172 ⟩;

⟨ Output the parameters 173 ⟩

This code is used in section 181.

158. A file begins with 12 numbers that tell how big its subfiles are. We already know most of these numbers; for example, the number of distinct widths is memory [width] + 1, where the +1 accounts for the zero width that is always supposed to be present. But we still should compute the beginning and ending character codes (bc and ec), the number of header words (lh), and the total number of words in the file (lf ). ⟨ Globals in the outer block 5 ⟩ +≡ bc: byte; { the smallest character code in the font } ec: byte; { the largest character code in the font } lh: byte; { the number of words in the header block } lf : 0 . . 32767; { the number of words in the entire file } not found : boolean; { has a font character been found? } temp width: fix word ; { width being used to compute a check sum }

159. It might turn out that no characters exist at all. But  keeps going and writes the  anyway.

In this case ec will be 0 and bc will be 1. ⟨ Compute the twelve subfile sizes 159 ⟩ ≡

lh ← header ptr div 4;

not found ← true; bc ← 0;

while not found do

if (char wd [bc] > 0) ∨ (bc = 255) then not found ← false else incr (bc);

not found ← true; ec ← 255;

while not found do

if (char wd [ec] > 0) ∨ (ec = 0) then not found ← false else decr (ec);

if bc > ec then bc ← 1;

incr (memory [width]); incr (memory [height ]); incr (memory [depth]); incr (memory [italic]); ⟨ Compute the ligature/kern program offset 168 ⟩; lf ← 6 + lh + (ec − bc + 1) + memory [width] + memory [height ] + memory [depth] + memory [italic] + nl +

lk offset + nk + ne + np;

This code is used in section 157.

258  THE TFM OUTPUT PHASE  VPtoVF §160

160. define out size(#) ≡ out ((#) div 256); out ((#) mod 256) ⟨ Output the twelve subfile sizes 160 ⟩ ≡

out size(lf ); out size(lh); out size(bc); out size(ec); out size(memory [width]); out size(memory [height ]); out size(memory [depth]); out size(memory [italic]); out size(nl + lk offset ); out size(nk ); out size(ne); out size(np);

This code is used in section 157.

161. The routines that follow need a few temporary variables of different types. ⟨ Globals in the outer block 5 ⟩ +≡ j: 0 . . max header bytes ; { index into header bytes } p: pointer ; { index into memory } q: width . . italic; { runs through the list heads for dimensions } par ptr : 0 . . max param words ; { runs through the parameters }

162. The header block follows the subfile sizes. The necessary information all appears in header bytes , except that the design size and the seven-bit-safe flag must still be set. ⟨ Output the header block 162 ⟩ ≡

if ¬check sum specified then ⟨ Compute the check sum 163 ⟩; header bytes [design size loc] ← design size div ´ 100000000 ; { this works since design size > 0 } header bytes [design size loc + 1] ← (design size div ´ 200000 ) mod 256; header bytes [design size loc + 2] ← (design size div 256) mod 256; header bytes [design size loc + 3] ← design size mod 256; if ¬seven unsafe then header bytes [seven flag loc] ← 128; for j ← 0 to header ptr − 1 do out (header bytes [j]);

This code is used in section 157.

163. ⟨ Compute the check sum 163 ⟩ ≡ begin c0 ← bc; c1 ← ec; c2 ← bc; c3 ← ec; for c ← bc to ec do

if char wd [c] > 0 then begin temp width ← memory [char wd [c]]; if design units ≠ unity then temp width ← round ((temp width/design units ) ∗ 1048576.0); temp width ← temp width + (c + 4) ∗ ´ 20000000 ; { this should be positive } c0 ← (c0 + c0 + temp width) mod 255; c1 ← (c1 + c1 + temp width) mod 253; c2 ← (c2 + c2 + temp width) mod 251; c3 ← (c3 + c3 + temp width) mod 247; end;

header bytes [check sum loc] ← c0 ; header bytes [check sum loc + 1] ← c1 ; header bytes [check sum loc + 2] ← c2 ; header bytes [check sum loc + 3] ← c3 ; end

This code is used in section 162.

164. The next block contains packed char info. ⟨ Output the character info 164 ⟩ ≡

index [0] ← 0; for c ← bc to ec do

begin out (index [char wd [c]]); out (index [char ht [c]] ∗ 16 + index [char dp[c]]); out (index [char ic[c]] ∗ 4 + char tag [c]); out (char remainder [c]); end

This code is used in section 157.

165. When a scaled quantity is output, we may need to divide it by design units . The following subroutine takes care of this, using floating point arithmetic only if design units ≠ 1.0. procedure out scaled (x : fix word ); { outputs a scaled fix word }

var n: byte; { the first byte after the sign }

m: 0 . . 65535; { the two least significant bytes } begin if abs (x/design units ) ≥ 16.0 then

begin print ln(´ ␣ ␣ ␣´ , x/´ 4000000 : 1 : 3, ´ ␣ ␣ ␣ ´ ); print (´ ␣␣ ␣ ␣ ␣ ␣ ´ ); if design units ≠ unity then print (´ ␣ ´ , design units /´ 200000 : 1 : 3, ´ ␣ ´ ); print ln(´ ´ ); x ← 0; end;

if design units ≠ unity then x ← round ((x/design units ) ∗ 1048576.0);

if x < 0 then begin out (255); x ← x + ´ 100000000 ; if x ≤ 0 then x ← 1; end

else begin out (0); if x ≥ ´ 100000000 then x ← ´ 77777777 ; end;

n ← x div ´ 200000 ; m ← x mod ´ 200000 ; out (n); out (m div 256); out (m mod 256); end;

166. We have output the packed indices for individual characters. The scaled widths, heights, depths, and italic corrections are next. ⟨ Output the dimensions themselves 166 ⟩ ≡

for q ← width to italic do begin out (0); out (0); out (0); out (0); { output the zero word } p ← link [q]; { head of list } while p > 0 do

begin out scaled (memory [p]); p ← link [p]; end; end;

This code is used in section 157.

167. One embarrassing problem remains: The ligature/kern program might be very long, but the starting addresses in char remainder can be at most 255. Therefore we need to output some indirect address information; we want to compute lk offset so that addition of lk offset to all remainders makes all but lk offset distinct remainders less than 256.

For this we need a sorted table of all relevant remainders. ⟨ Globals in the outer block 5 ⟩ +≡ label table: array [0 . . 256] of record rr : −1 . . ´ 77777 ; { sorted label values }

cc: byte; { associated characters }

end; label ptr : 0 . . 256; { index of highest entry in label table } sort ptr : 0 . . 256; { index into label table } lk offset : 0 . . 256; { smallest offset value that might work } t: 0 . . ´ 77777 ; { label value that is being redirected } extra loc needed : boolean; { do we need a special word for bchar ? } 168. ⟨ Compute the ligature/kern program offset 168 ⟩ ≡

⟨ Insert all labels into label table 169 ⟩; if bchar < 256 then

begin extra loc needed ← true; lk offset ← 1; end

else begin extra loc needed ← false; lk offset ← 0;

end; ⟨ Find the minimum lk offset and adjust all remainders 170 ⟩; if bchar label < ´ 77777 then

begin lig kern[nl − 1].b2 ← (bchar label + lk offset ) div 256; lig kern[nl − 1].b3 ← (bchar label + lk offset ) mod 256; end

This code is used in section 159.

169. ⟨ Insert all labels into label table 169 ⟩ ≡ label ptr ← 0; label table[0].rr ← −1; { sentinel } for c ← bc to ec do

if char tag [c] = lig tag then begin sort ptr ← label ptr ; { there’s a hole at position sort ptr + 1 } while label table[sort ptr ].rr > char remainder [c] do

begin label table[sort ptr + 1] ← label table[sort ptr ]; decr (sort ptr ); { move the hole } end;

label table[sort ptr + 1].cc ← c; label table[sort ptr + 1].rr ← char remainder [c]; incr (label ptr ); end

This code is used in section 168.

170. ⟨ Find the minimum lk offset and adjust all remainders 170 ⟩ ≡ begin sort ptr ← label ptr ; { the largest unallocated label } if label table[sort ptr ].rr + lk offset > 255 then

begin lk offset ← 0; extra loc needed ← false; { location 0 can do double duty } repeat char remainder [label table[sort ptr ].cc] ← lk offset ;

while label table[sort ptr − 1].rr = label table[sort ptr ].rr do begin decr (sort ptr ); char remainder [label table[sort ptr ].cc] ← lk offset ; end;

incr (lk offset ); decr (sort ptr ); until lk offset + label table[sort ptr ].rr < 256;

{ N.B.: lk offset = 256 satisfies this when sort ptr = 0 } end;

if lk offset > 0 then

while sort ptr > 0 do begin char remainder [label table[sort ptr ].cc] ← char remainder [label table[sort ptr ].cc] + lk offset ; decr (sort ptr ); end;

end

This code is used in section 168.

171. ⟨ Output the ligature/kern program 171 ⟩ ≡

if extra loc needed then { lk offset = 1 } begin out (255); out (bchar ); out (0); out (0); end

else for sort ptr ← 1 to lk offset do { output the redirection specs } begin t ← label table[label ptr ].rr ; if bchar < 256 then

begin out (255); out (bchar ); end

else begin out (254); out (0);

end; out size(t + lk offset ); repeat decr (label ptr ); until label table[label ptr ].rr < t; end;

if nl > 0 then

for lig ptr ← 0 to nl − 1 do begin out (lig kern[lig ptr ].b0 ); out (lig kern[lig ptr ].b1 ); out (lig kern[lig ptr ].b2 ); out (lig kern[lig ptr ].b3 ); end;

if nk > 0 then

for krn ptr ← 0 to nk − 1 do out scaled (kern[krn ptr ])

This code is used in section 157.

172. ⟨ Output the extensible character recipes 172 ⟩ ≡

if ne > 0 then

for c ← 0 to ne − 1 do begin out (exten[c].b0 ); out (exten[c].b1 ); out (exten[c].b2 ); out (exten[c].b3 ); end;

This code is used in section 157.

173. For our grand finale, we wind everything up by outputting the parameters. ⟨ Output the parameters 173 ⟩ ≡

for par ptr ← 1 to np do begin if par ptr = 1 then ⟨ Output the slant (param[1]) without scaling 174 ⟩ else out scaled (param[par ptr ]); end

This code is used in section 157.

174. ⟨ Output the slant (param[1]) without scaling 174 ⟩ ≡

begin if param[1] < 0 then begin param[1] ← param[1] + ´ 10000000000 ; out ((param[1] div ´ 100000000 ) + 256 − 64); end

else out (param[1] div ´ 100000000 ); out ((param[1] div ´ 200000 ) mod 256); out ((param[1] div 256) mod 256); out (param[1] mod 256); end

This code is used in section 173.

262  THE VF OUTPUT PHASE  VPtoVF §175

175. The VF output phase. Output to vf file is considerably simpler.

define id byte = 202 { current version of format } define vout (#) ≡ write(vf file, #)

⟨ Globals in the outer block 5 ⟩ +≡ vcount : integer ; { number of bytes written to vf file }

176. We need a routine to output integers as four bytes. Negative values will never be less than −2^{24}. procedure vout int (x : integer );

begin if x ≥ 0 then vout (x div ´ 100000000 ) else begin vout (255); x ← x + ´ 100000000 ;

end; vout ((x div ´ 200000 ) mod 256); vout ((x div ´ 400 ) mod 256); vout (x mod 256); end;

177. ⟨ Do the output 177 ⟩ ≡ vout (pre); vout (id byte); vout (vtitle length); for k ← 0 to vtitle length − 1 do vout (vf [vtitle start + k]); for k ← check sum loc to design size loc + 3 do vout (header bytes [k]); vcount ← vtitle length + 11; for cur font ← 0 to font ptr − 1 do ⟨ Output a local font definition 178 ⟩; for c ← bc to ec do

if char wd [c] > 0 then ⟨ Output a packet for character c 179 ⟩; repeat vout (post ); incr (vcount ); until vcount mod 4 = 0

This code is used in section 180.

178. ⟨ Output a local font definition 178 ⟩ ≡ begin vout (fnt def1 ); vout (cur font ); vout (font checksum[cur font ].b0 ); vout (font checksum[cur font ].b1 ); vout (font checksum[cur font ].b2 ); vout (font checksum[cur font ].b3 ); vout int (font at [cur font ]); vout int (font dsize[cur font ]); vout (farea length[cur font ]); vout (fname length[cur font ]); for k ← 0 to farea length[cur font ] − 1 do vout (vf [farea start [cur font ] + k]); if fname start [cur font ] = vf size then

begin vout ( ); vout ( ); vout ( ); vout ( );

end else for k ← 0 to fname length[cur font ] − 1 do vout (vf [fname start [cur font ] + k]); vcount ← vcount + 12 + farea length[cur font ] + fname length[cur font ]; end

This code is used in section 177.

§179  VPtoVF  THE VF OUTPUT PHASE 263

179. ⟨ Output a packet for character c 179 ⟩ ≡ begin x ← memory [char wd [c]]; if design units ≠ unity then x ← round ((x/design units ) ∗ 1048576.0); if (packet length[c] > 241) ∨ (x < 0) ∨ (x ≥ ´ 100000000 ) then

begin vout (242); vout int (packet length[c]); vout int (c); vout int (x); vcount ← vcount + 13 + packet length[c]; end

else begin vout (packet length[c]); vout (c); vout (x div ´ 200000 ); vout ((x div ´ 400 ) mod 256); vout (x mod 256); vcount ← vcount + 5 + packet length[c]; end;

if packet start [c] = vf size then begin if c ≥ 128 then vout (set1 ); vout (c); end

else for k ← 0 to packet length[c] − 1 do vout (vf [packet start [c] + k]); end

This code is used in section 177.

264  THE MAIN PROGRAM  VPtoVF §180

180. The main program. The routines sketched out so far need to be packaged into separate procedures, on some systems, since some Pascal compilers place a strict limit on the size of a routine. The packaging is done here in an attempt to avoid some system-dependent changes. procedure param enter ;

begin ⟨ Enter the parameter names 57 ⟩; end;

procedure vpl enter ; begin ⟨ Enter all the names 56 ⟩; end;

procedure name enter ; { enter all names and their equivalents } begin ⟨ Enter all the names and their equivalents, except the parameter names 55 ⟩; vpl enter ; param enter ; end;

procedure read lig kern;

var krn ptr : 0 . . max kerns ; { an index into kern }

c: byte; { runs through all character codes } begin ⟨ Read ligature/kern list 109 ⟩; end;

procedure read char info; var c: byte; { the char } begin ⟨ Read character info list 118 ⟩; end;

procedure read input ; var c: byte; { header or parameter index } begin ⟨ Read all the input 92 ⟩; end;

procedure corr and check ;

var c: 0 . . 256; { runs through all character codes } hh: 0 . . hash size; { an index into hash list } lig ptr : 0 . . max lig steps ; { an index into lig kern } g: byte; { a character generated by the current character c }

begin ⟨ Correct and check the information 139 ⟩ end;

procedure vf output ;

var c: byte; { runs through all character codes } cur font : 0 . . 256; { runs through all local fonts } k: integer ; { loop index }

begin ⟨ Do the output 177 ⟩; end;

181. Here is where begins and ends.

begin initialize; name enter ; read input ; print ln(´ ´ ); corr and check ; ⟨ Do the output 157 ⟩; vf output ; end.

§182  VPtoVF  SYSTEM-DEPENDENT CHANGES 265

182. System-dependent changes. This section should be replaced, if necessary, by changes to the program that are necessary to make work at a particular installation. It is usually best to design your change file so that all changes to previous sections preserve the section numbering; then everybody’s version will be consistent with the printed program. More extensive changes, which introduce new sections, can be inserted here; then only the index itself will get a new section number.

266  INDEX  VPtoVF §183

183. Index. Pointers to error messages appear here together with the section numbers where each identifier is used.

a: \underline{39}. : 142. abs : 165. acc: \underline{60}, 61, 62, 63, 64, 65, \underline{72}, 74, 76. : 72. ASCII code: \underline{23}, 24, 36, 44, 46, 60. : 120. backup: \underline{38}, 62, 63, 64, 112. bad indent : \underline{35}. banner : \underline{1}, 2. bc: \underline{158}, 159, 160, 163, 164, 169, 177. bchar : \underline{77}, 80, 95, 149, 154, 155, 167, 168, 171. bchar label : \underline{82}, 84, 112, 139, 145, 154, 168. boolean: 29, 41, 50, 72, 77, 113, 128, 138,

150, 158, 167. : 141. both z : \underline{146}, 150, 151, 153. boundary char code: \underline{52}, 55, 95. buf size: \underline{3}, 29, 33, 34. buffer : \underline{29}, 33, 34, 35, 37, 38, 40, 41, 61. byte: \underline{23}, 39, 52, 53, 60, 66, 77, 82, 83, 89, 90, 91,

97, 111, 124, 128, 136, 158, 165, 167, 180. b0 : \underline{66}, 67, 68, 104, 114, 115, 116, 117, 121, 141,

145, 149, 155, 171, 172, 178. b1 : \underline{66}, 67, 68, 104, 116, 117, 121, 141, 145, 149,

151, 155, 171, 172, 178. b2 : \underline{66}, 67, 68, 104, 116, 117, 121, 141, 145, 149,

151, 155, 168, 171, 172, 178. b3 : \underline{66}, 67, 68, 104, 116, 117, 121, 141, 145, 149,

151, 155, 168, 171, 172, 178. c: \underline{69}, \underline{83}, \underline{91}, \underline{124}, \underline{150}, \underline{180}. : 61. cc: \underline{124}, 127, \underline{150}, 151, \underline{167}, 169, 170. char : 24, 29. char dp: \underline{82}, 84, 119, 164. char dp code: \underline{52}, 55, 119. char ht : \underline{82}, 84, 119, 164. char ht code: \underline{52}, 55, 119. char ic: \underline{82}, 84, 119, 164. char ic code: \underline{52}, 55, 119. char info: 164. char info code: \underline{52}. char info word : 82. char remainder : \underline{82}, 84, 112, 119, 120, 140, 141,

142, 149, 154, 164, 167, 169, 170. char tag : \underline{82}, 84, 111, 112, 119, 120, 140, 142,

154, 164, 169. char wd : \underline{82}, 84, 85, 118, 119, 139, 140, 155,

159, 163, 164, 177, 179. char wd code: \underline{52}, 55, 103, 119.

: 127. character code: \underline{52}, 55, 94, 95. chars on line: \underline{31}, 32, 33, 137. check existence: \underline{140}, 149. check existence and safety : \underline{140}, 141. check sum code: \underline{52}, 55, 95. check sum loc: \underline{80}, 95, 163, 177. check sum specified : \underline{77}, 80, 95, 162. check tag : \underline{111}, 112, 119, 120. chr : 26, 34. class : \underline{147}, 150, 153, 154. clear lig kern entry : \underline{145}. coding scheme code: \underline{52}, 55, 95. coding scheme loc: \underline{80}, 95. comment code: \underline{52}, 55, 94, 103, 106, 110, 119,

121, 125. copy to end of item: \underline{41}, 95, 107, 108, 134. corr and check : \underline{180}, 181. cur bytes : 66, \underline{67}, 69, 70, 104, 106, 126. cur char : \underline{36}, 37, 38, 39, 40, 42, 43, 58, 60, 61, 62,

63, 64, 65, 69, 70, 72, 73, 74, 76, 92, 94, 97, 100, 102, 104, 109, 112, 118, 120, 124, 134.

cur code: \underline{52}, 58, 94, 95, 103, 106, 110, 116, 119,

121, 125, 130, 131, 134. cur font : \underline{77}, 104, 105, 106, 107, 108, 124, 126,

127, 177, 178, \underline{180}. cur hash: \underline{47}, 50, 51, 53. cur name: \underline{46}, 50, 51, 53, 54, 58. c0 : \underline{67}, 70, 96, 163. c1 : \underline{67}, 70, 96, 163. c2 : \underline{67}, 70, 96, 163. c3 : \underline{67}, 70, 96, 163. d: \underline{79}, \underline{85}, \underline{87}, \underline{88}, \underline{90}. : 69. decr : \underline{4}, 38, 40, 41, 50, 58, 76, 90, 97, 102, 117,

§183  VPtoVF  INDEX 267

124, 128, 133, 150, 152, 159, 169, 170, 171. delta: \underline{143}, 144. depth: \underline{52}, 84, 119, 144, 159, 160. design size: \underline{77}, 80, 98, 162. design size code: \underline{52}, 55, 95. design size loc: \underline{80}, 162, 177. design units : \underline{77}, 80, 99, 106, 128, 163, 165, 179. design units code: \underline{52}, 55, 95. dict ptr : \underline{44}, 45, 53. dictionary : \underline{44}, 50, 53. do nothing : \underline{4}, 111, 140, 151, 153. : 132. double check ext : \underline{155}. double check lig : \underline{155}. double check rep: \underline{155}. double check tail : \underline{155}. down1 : \underline{122}, 131. ec: \underline{158}, 159, 160, 163, 164, 169, 177. : 133. enter name: \underline{53}, 54. eof : 34. eoln: 34. equiv : \underline{52}, 53, 55, 58. err print : \underline{33}, 35, 38, 39, 40, 41, 42, 43, 58, 85, 92,

93, 95, 97, 98, 99, 100, 104, 107, 108, 111, 114, 115, 116, 117, 120, 124, 126, 127, 132, 133, 135.

eval : \underline{152}, 153. excess : 88, \underline{89}, 90. existence tail : \underline{140}. ext tag : \underline{82}, 111, 120, 140. exten: \underline{77}, 120, 121, 141, 155, 172. : 92. extra loc needed : \underline{167}, 168, 170, 171. f: \underline{152}, \underline{153}. face code: \underline{52}, 55, 95. face loc: \underline{80}, 95. false: 30, 34, 41, 50, 72, 80, 100, 112, 114, 115,

128, 139, 150, 159, 168, 170. family code: \underline{52}, 55, 95. family loc: \underline{80}, 95. farea length: \underline{77}, 105, 108, 178. farea start : \underline{77}, 105, 108, 178. : 40. fill buffer : \underline{34}, 35, 37, 38, 40, 41. finish inner property list : \underline{102}, 104, 109, 118,

120, 124. finish the property : \underline{43}, 94, 102, 103, 106, 110,

119, 121, 125. first ord : \underline{24}, 26. fix word : \underline{71}, 72, 77, 81, 82, 85, 86, 87, 88, 90, 91,

105, 123, 124, 128, 143, 158, 165. flush error : \underline{42}, 94, 103, 106, 110, 119, 121, 125. fname length: \underline{77}, 105, 107, 178. fname start : \underline{77}, 105, 107, 178. fnt def1 : 77, \underline{122}, 178. fnt num 0 : \underline{122}, 126. fnt1 : 77, \underline{122}, 126. font area code: \underline{52}, 56, 106. font at : \underline{77}, 105, 106, 178. font at code: \underline{52}, 56, 106. font checksum: \underline{77}, 105, 106, 178. font checksum code: \underline{52}, 56, 106. font dimen code: \underline{52}, 55, 95. font dsize: \underline{77}, 105, 106, 178. font dsize code: \underline{52}, 56, 106. font name code: \underline{52}, 56, 106. font number : \underline{77}, 104, 126. font ptr : \underline{77}, 80, 104, 105, 126, 127, 177. : 108. : 107. forward : 152, 153. four bytes : \underline{66}, 67, 69, 77. fraction digits : \underline{75}, 76. frozen du: \underline{77}, 80, 99, 106, 128. Fuchs, David Raymond: 1. g: \underline{180}. get byte: \underline{60}, 95, 101, 103, 112, 115, 116, 117,

118, 119, 121, 127. get fix : \underline{72}, 98, 99, 103, 106, 117, 119, 129,

130, 131. get four bytes : \underline{69}, 96, 104, 106, 126.

get hex : \underline{39}, 134.
get keyword char : \underline{37}, 58.

get name: \underline{58}, 94, 103, 106, 110, 119, 121, 125. get next : \underline{38}, 39, 42, 43, 58, 60, 61, 62, 63, 64, 65, 69, 70, 72, 73, 74, 76, 92, 97, 100, 102, 104, 109, 112, 118, 120, 124.

good indent : \underline{27}, 28, 35.

h: \underline{48}, \underline{85}, \underline{87}, \underline{88}, \underline{90}, \underline{124}, \underline{147}, \underline{152}. hash: \underline{147}, 148, 150, 152, 153, 154. hash input : 149, \underline{150}. hash list : \underline{147}, 150, 154, 180. hash prime: \underline{47}, 48, 49, 50, 51. hash ptr : \underline{147}, 148, 150, 154. hash size: \underline{3}, 147, 148, 150, 152, 154, 180. header : 10. : 101. header bytes : \underline{77}, 79, 80, 95, 96, 97, 101, 161,

162, 163, 177. header code: \underline{52}, 55, 95. header index : 77, \underline{78}, 79, 96, 97. header ptr : \underline{77}, 80, 101, 159, 162. height : \underline{52}, 81, 84, 119, 144, 159, 160. hh: \underline{147}, 154, \underline{180}. hstack : \underline{123}, 124, 132, 133. : 104. : 144. : 41. id byte: \underline{175}, 177. : 38, 41. : 70. : 65. : 39. incr : \underline{4}, 34, 35, 37, 38, 40, 41, 53, 58, 65, 76, 85, 87, 90, 92, 97, 101, 102, 103, 104, 105, 116, 117, 120, 126, 128, 132, 137, 145, 150, 159, 169, 170, 177.

indent : \underline{27}, 28, 35.

index : \underline{89}, 90, 164.

indx : \underline{78}, 147, 150, 152, 153. : 154. initialize: \underline{2}, 181. input has ended : \underline{29}, 30, 34, 40, 92. int part : \underline{72}. integer : 25, 27, 39, 40, 41, 60, 69, 71, 72, 75, 77,

87, 88, 91, 128, 150, 152, 175, 176, 180. invalid code: \underline{26}, 38, 41. italic: \underline{52}, 81, 84, 119, 144, 159, 160, 161, 166. j: \underline{50}, \underline{72}, \underline{161}. : 43. junk error : 92, \underline{93}, 102, 104, 109, 118, 120, 124. k: \underline{25}, \underline{33}, \underline{50}, \underline{53}, \underline{88}, \underline{91}, \underline{97}, \underline{124}, \underline{128}, \underline{180}. kern: \underline{77}, 113, 117, 171, 180. kern flag : \underline{113}, 117, 149, 151, 155. key : \underline{150}, \underline{152}. : 149. krn code: \underline{52}, 55, 110. krn ptr : \underline{113}, 117, 171, \underline{180}. l: \underline{40}, \underline{41}, \underline{87}, \underline{90}. label code: \underline{52}, 55, 110. label ptr : \underline{167}, 169, 170, 171. label table: \underline{167}, 169, 170, 171. last ord : \underline{24}, 26. left ln: \underline{29}, 30, 33, 34. left z : \underline{146}, 151, 153. level : \underline{27}, 28, 35, 40, 41, 58, 102, 104, 109,

118, 120, 124. lf : \underline{158}, 159, 160. lh: \underline{158}, 159, 160. : 149. : 149. lig code: \underline{52}, 55, 110, 116. lig exam: \underline{149}. lig gen: \underline{149}. lig kern: \underline{77}, 114, 115, 116, 117, 145, 147, 149,

151, 155, 168, 171, 180. lig ptr : \underline{147}, 149, 155, 171, \underline{180}. lig table code: \underline{52}, 55, 95. lig tag : \underline{82}, 111, 112, 140, 154, 169. lig z : \underline{147}, 150, 153. limit : \underline{29}, 30, 33, 34, 35, 37, 38, 40, 41. line: \underline{27}, 28, 33, 34. link : 81, \underline{82}, 84, 85, 87, 90, 166. list tag : \underline{82}, 111, 119, 140, 142. lk offset : 159, 160, \underline{167}, 168, 170, 171. lk step ended : 112, \underline{113}, 114, 115, 116, 117. load10 : \underline{54}, 55, 56, 57. load11 : \underline{54}, 55. load12 : \underline{54}, 55, 56. load13 : \underline{54}, 57. load14 : \underline{54}.

load15 : \underline{54}.
load16 : \underline{54}, 55.
load17 : \underline{54}.
load18 : \underline{54}.
load19 : \underline{54}.
load20 : \underline{54}, 57.
load3 : \underline{54}, 55, 56.
load4 : \underline{54}, 55, 56, 57.
load5 : \underline{54}, 55, 57.
load6 : \underline{54}, 55, 56, 57.
load7 : \underline{54}, 55, 56, 57.
load8 : \underline{54}, 55, 56.
load9 : \underline{54}, 55, 56.
loc: \underline{29}, 30, 33, 34, 35, 37, 38, 40, 41, 58, 61,

92, 102. longest name: \underline{46}, 50, 53, 58. lookup: \underline{50}, 53, 58. m: \underline{87}, \underline{90}, \underline{165}. map code: \underline{52}, 56, 119. map font code: \underline{52}, 56, 95. max header bytes : \underline{3}, 10, 78, 101, 161. max kerns : \underline{3}, 77, 113, 117, 180. max letters : \underline{44}, 50. max lig steps : \underline{3}, 77, 115, 116, 117, 147, 180. max name index : \underline{44}, 46, 47, 52. max param words : \underline{3}, 12, 77, 103, 161. max stack : \underline{3}, 123, 132. : 115. mem ptr : \underline{82}, 84, 85. mem size: \underline{81}, 85. memory : 81, \underline{82}, 84, 85, 87, 88, 89, 90, 158, 159,

160, 161, 163, 166, 179. : 85. : 141. min cover : \underline{87}, 88. min nl : \underline{77}, 80, 112, 115, 145. : 124. move down code: \underline{52}, 56, 125, 131. move right code: \underline{52}, 56, 125, 130. n: \underline{165}. name enter : \underline{180}, 181. name length: \underline{46}, 50, 51, 53, 54, 58. name ptr : \underline{46}, 50, 58. ne: \underline{77}, 80, 120, 121, 155, 159, 160, 172. negative: \underline{72}, 73, \underline{128}. next d : \underline{86}, 87, 88, 98, 99. next larger code: \underline{52}, 55, 119. nhash: \underline{47}, 49, 50, 53. nk : \underline{77}, 80, 117, 159, 160, 171. nl : \underline{77}, 80, 112, 114, 115, 116, 117, 139, 145, 149,

154, 155, 159, 160, 168, 171. no tag : \underline{82}, 84, 111, 140, 142, 154. nonblank found : \underline{41}. not found : \underline{50}, \underline{158}, 159. np: \underline{77}, 80, 103, 159, 160, 173. numbers differ : \underline{104}, 126. opcode: \underline{128}. out : \underline{156}, 160, 162, 164, 165, 166, 171, 172, 174. out scaled : \underline{165}, 166, 171, 173. out size: \underline{160}, 171. output : \underline{2}. p: \underline{85}, \underline{87}, \underline{90}, \underline{150}, \underline{161}. packet length: \underline{77}, 80, 124, 179. packet start : \underline{77}, 80, 124, 179. par ptr : \underline{161}, 173. param: \underline{77}, 103, 173, 174. param enter : \underline{180}. : 103. parameter code: \underline{52}, 55, 57, 103. pending : \underline{146}, 147, 153. pointer : \underline{81}, 82, 85, 87, 88, 89, 90, 161. pop: \underline{122}, 124, 133. pop code: \underline{52}, 56, 125. post : \underline{122}, 177. pre: \underline{122}, 177. print : \underline{2}, 33, 136, 137, 140, 142, 154, 155, 165. print ln: \underline{2}, 33, 85, 137, 139, 140, 142, 144, 154,

155, 165, 181. print octal : \underline{136}, 137, 140, 142, 154, 155. push: \underline{122}, 132. push code: \underline{52}, 56, 125. q: \underline{90}, \underline{161}. r: \underline{69}. read : 34. read BCPL: 95, \underline{97}. read char info: 95, \underline{180}. read four bytes : 95, \underline{96}, 101. read input : \underline{180}, 181. read lig kern: 95, \underline{180}. read ln: 34. read packet : 119, \underline{124}. : 72, 74. : 141. reset : 6. rewrite: 22. right ln: \underline{29}, 30, 33, 34, 37. right z : \underline{146}, 151, 153. right1 : \underline{122}, 130. round : 106, 128, 163, 165, 179. round message: \underline{144}. rr : \underline{167}, 169, 170, 171. select font code: \underline{52}, 56, 125. set char code: \underline{52}, 56, 125. set char 0 : \underline{122}. set indices : \underline{90}, 144. set rule: \underline{122}, 129. set rule code: \underline{52}, 56, 125. set1 : \underline{122}, 127, 179. seven bit safe flag : \underline{77}, 80, 100, 139. seven bit safe flag code: \underline{52}, 55, 95. seven flag loc: \underline{80}, 162. seven unsafe: \underline{138}, 139, 140, 149, 162. shorten: \underline{88}, 144. show error context : \underline{33}. simple: \underline{146}, 147, 150, 151, 153, 154. : 115. skip code: \underline{52}, 55, 110. skip error : \underline{42}, 60, 61, 62, 63, 64, 65, 69, 70,

72, 74, 101. skip to end of item: \underline{40}, 42, 43, 94, 102, 103, 104, 106, 109, 110, 118, 119, 120, 121, 124, 125.

skip to paren: \underline{42}, 93, 100, 112. : 58. : 154. : 99. : 115, 116, 117. : 70. : 117. sort in: \underline{85}, 118, 119, 140, 155. sort ptr : \underline{167}, 169, 170, 171. : 135. special code: \underline{52}, 56, 125, 134. special hex code: \underline{52}, 56, 125. special start : \underline{124}, 134, 135. stack ptr : \underline{123}, 124, 130, 131, 132, 133. start : \underline{44}, 45, 46, 47, 50, 52, 53. start ptr : \underline{44}, 45, 53. : 114. stop code: \underline{52}, 55, 110. stop flag : \underline{113}, 114, 145, 149. : 97. system dependencies: 2, 22, 24, 34, 182. t: \underline{60}, \underline{128}, \underline{150}, \underline{167}. tail : \underline{54}. temp width: \underline{158}, 163. text : 5. tfm file: \underline{2}, \underline{21}, 22, 156. : 140. : 98. : 100. : 139. : 99. : 165. : 93. : 111. : 101.

: 103. : 94,

103, 106, 110, 119, 121, 125. : 62, 63, 64. : 141. true: 30, 34, 41, 50, 73, 95, 100, 106, 116, 117,

128, 140, 149, 150, 159, 168. tt : \underline{147}, 154. t1 : \underline{54}. t10 : \underline{54}. t11 : \underline{54}. t12 : \underline{54}. t13 : \underline{54}. t14 : \underline{54}. t15 : \underline{54}. t16 : \underline{54}. t17 : \underline{54}. t18 : \underline{54}. t19 : \underline{54}. t2 : \underline{54}. t20 : \underline{54}. t3 : \underline{54}. t4 : \underline{54}. t5 : \underline{54}. t6 : \underline{54}. t7 : \underline{54}. t8 : \underline{54}. t9 : \underline{54}. : 126. unity : \underline{71}, 72, 80, 98, 106, 128, 163, 165, 179. : 80. : 155. : 155. : 155. v: \underline{124}. var char code: \underline{52}, 55, 119, 121. vcount : \underline{175}, 177, 178, 179. vf : 3, 41, \underline{77}, 134, 135, 177, 178, 179. vf file: \underline{2}, \underline{21}, 22, 175. vf fix : \underline{128}, 129, 130, 131. vf output : \underline{180}, 181. vf ptr : 41, \underline{77}, 80, 95, 107, 108, 124, 134, 135. vf size: \underline{3}, 41, 77, 80, 105, 124, 135, 178, 179. vf store: \underline{41}, 124, 126, 127, 128, 129, 130, 131,

132, 133, 134. virtual title code: \underline{52}, 56, 95. vout : \underline{175}, 176, 177, 178, 179. vout int : \underline{176}, 178, 179. vpl enter : \underline{180}. vpl file: \underline{2}, \underline{5}, 6, 34. VPtoVF : \underline{2}. vstack : \underline{123}, 124, 132, 133.

: 95. vtitle length: \underline{77}, 80, 95, 177. vtitle start : \underline{77}, 80, 95, 177. : 35. : 35. width: \underline{52}, 81, 84, 85, 118, 119, 140, 144, 155,

158, 159, 160, 161, 166. write: 2, 156, 175. write ln: 2. wstack : \underline{123}, 130. w0 : \underline{122}, 130. w1 : \underline{122}, 130. x: \underline{91}, \underline{124}, \underline{128}, \underline{152}, \underline{176}. x lig cycle: \underline{147}, 153, 154. xord : \underline{24}, 26, 34, 37, 38, 41, 61. xstack : \underline{123}, 130. xxx1 : \underline{122}, 124, 134. xxx4 : \underline{122}, 135. x0 : \underline{122}, 130. x1 : \underline{122}, 130. y: \underline{150}, \underline{152}. y lig cycle: \underline{147}, 148, 153, 154. : 60. ystack : \underline{123}, 131. y0 : \underline{122}, 131. y1 : \underline{122}, 131. zero bytes : \underline{67}, 68, 69, 70, 105, 120. zstack : \underline{123}, 131. zz : \underline{150}, 151. z0 : \underline{122}, 131. z1 : \underline{122}, 131.

§183  VPtoVF  NAMES OF THE SECTIONS 271

⟨ Assemble a font selection 126 ⟩ Used in section 125. ⟨ Assemble a horizontal movement 130 ⟩ Used in section 125. ⟨ Assemble a rulesetting instruction 129 ⟩ Used in section 125. ⟨ Assemble a special command 134 ⟩ Used in section 125.

⟨ Assemble a stack pop 133 ⟩ Used in section 125.

⟨ Assemble a stack push 132 ⟩ Used in section 125. ⟨ Assemble a typesetting instruction 127 ⟩ Used in section 125. ⟨ Assemble a vertical movement 131 ⟩ Used in section 125. ⟨ Check for infinite ligature loops 154 ⟩ Used in section 139.

⟨ Check ligature program of c 149 ⟩ Used in sections 139 and 140.

⟨ Check the pieces of exten[c] 141 ⟩ Used in section 140. ⟨ Compute the check sum 163 ⟩ Used in section 162. ⟨ Compute the command parameters y, cc, and zz 151 ⟩ Used in section 150. ⟨ Compute the hash code, cur hash, for cur name 51 ⟩ Used in section 50. ⟨ Compute the ligature/kern program offset 168 ⟩ Used in section 159. ⟨ Compute the twelve subfile sizes 159 ⟩ Used in section 157. ⟨ Constants in the outer block 3 ⟩ Used in section 2.

⟨ Convert xxx1 command to xxx4 135 ⟩ Used in section 134.

⟨ Correct and check the information 139 ⟩ Used in section 180. ⟨ Declare the vf fix procedure 128 ⟩ Used in section 124.

⟨ Do the output 157 ⟩ Used in section 181. ⟨ Do the output 177 ⟩ Used in section 180.

⟨ Doublecheck the lig/kern commands and the extensible recipes 155 ⟩ Used in section 139. ⟨ Enter all the names and their equivalents, except the parameter names 55 ⟩ Used in section 180.

⟨ Enter all the names 56 ⟩ Used in section 180.

⟨ Enter the parameter names 57 ⟩ Used in section 180. ⟨ Find the minimum lk offset and adjust all remainders 170 ⟩ Used in section 168. ⟨ For all characters g generated by c, make sure that char wd [g] is nonzero, and set seven unsafe if

c < 128 ≤ g 140 ⟩ Used in section 139. ⟨ Globals in the outer block 5, 21, 24, 27, 29, 31, 36, 44, 46, 47, 52, 67, 75, 77, 82, 86, 89, 91, 113, 123, 138, 143, 147, 158,

161, 167, 175 ⟩ Used in section 2.

⟨ Initialize a new local font 105 ⟩ Used in section 104. ⟨ Insert all labels into label table 169 ⟩ Used in section 168. ⟨ Local variables for initialization 25, 48, 79, 83 ⟩ Used in section 2. ⟨ Make sure that c is not the largest element of a charlist cycle 142 ⟩ Used in section 139. ⟨ Make sure the ligature/kerning program ends appropriately 145 ⟩ Used in section 139. ⟨ Multiply by 10, add cur char − , and get next 74 ⟩ Used in section 72. ⟨ Multiply by r, add cur char − , and get next 70 ⟩ Used in section 69. ⟨ Output a local font definition 178 ⟩ Used in section 177. ⟨ Output a packet for character c 179 ⟩ Used in section 177. ⟨ Output the character info 164 ⟩ Used in section 157. ⟨ Output the dimensions themselves 166 ⟩ Used in section 157. ⟨ Output the extensible character recipes 172 ⟩ Used in section 157. ⟨ Output the header block 162 ⟩ Used in section 157. ⟨ Output the ligature/kern program 171 ⟩ Used in section 157. ⟨ Output the parameters 173 ⟩ Used in section 157. ⟨ Output the slant (param[1]) without scaling 174 ⟩ Used in section 173. ⟨ Output the twelve subfile sizes 160 ⟩ Used in section 157. ⟨ Print c in octal notation 137 ⟩ Used in section 118. ⟨ Put the width, height, depth, and italic lists into final form 144 ⟩ Used in section 139. ⟨ Read a character property 119 ⟩ Used in section 118. ⟨ Read a font property value 94 ⟩ Used in section 92.

272  NAMES OF THE SECTIONS  VPtoVF §183

⟨ Read a kerning step 117 ⟩ Used in section 110. ⟨ Read a label step 112 ⟩ Used in section 110. ⟨ Read a ligature step 116 ⟩ Used in section 110.

⟨ Read a ligature/kern command 110 ⟩ Used in section 109. ⟨ Read a local font area 108 ⟩ Used in section 106. ⟨ Read a local font list 104 ⟩ Used in section 95. ⟨ Read a local font name 107 ⟩ Used in section 106. ⟨ Read a local font property 106 ⟩ Used in section 104. ⟨ Read a parameter value 103 ⟩ Used in section 102.

⟨ Read a skip step 115 ⟩ Used in section 110. ⟨ Read a stop step 114 ⟩ Used in section 110. ⟨ Read all the input 92 ⟩ Used in section 180.

⟨ Read an extensible piece 121 ⟩ Used in section 120. ⟨ Read an extensible recipe for c 120 ⟩ Used in section 119. ⟨ Read an indexed header word 101 ⟩ Used in section 95. ⟨ Read and assemble a list of commands 125 ⟩ Used in section 124. ⟨ Read character info list 118 ⟩ Used in section 180. ⟨ Read font parameter list 102 ⟩ Used in section 95. ⟨ Read ligature/kern list 109 ⟩ Used in section 180. ⟨ Read the design size 98 ⟩ Used in section 95. ⟨ Read the design units 99 ⟩ Used in section 95. ⟨ Read the font property value specified by cur code 95 ⟩ Used in section 94. ⟨ Read the seven-bit-safe flag 100 ⟩ Used in section 95.

⟨ Scan a face code 65 ⟩ Used in section 60.

⟨ Scan a small decimal number 62 ⟩ Used in section 60. ⟨ Scan a small hexadecimal number 64 ⟩ Used in section 60. ⟨ Scan a small octal number 63 ⟩ Used in section 60. ⟨ Scan an ASCII character code 61 ⟩ Used in section 60. ⟨ Scan the blanks and/or signs after the type code 73 ⟩ Used in section 72. ⟨ Scan the fraction part and put it in acc 76 ⟩ Used in section 72.

⟨ Set initial values 6, 22, 26, 28, 30, 32, 45, 49, 68, 80, 84, 148 ⟩ Used in section 2.

⟨ Set loc to the number of leading blanks in the buffer, and check the indentation 35 ⟩ Used in section 34.

⟨ Types in the outer block 23, 66, 71, 78, 81 ⟩ Used in section 2.

The VPtoVF processor

(Version 1.3, March 1991)

Section Page

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 202 Property list description of font metric data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 203 Basic input routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 212 Basic scanning routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 216 Scanning property names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 219 Scanning numeric data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 227 Storing the property values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 232 The input phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 237 Assembling the mappings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 246 The checking and massaging phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 251 The TFM output phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 257 The VF output phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 262 The main program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 264 System-dependent changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 265 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 266

The preparation of this program was supported in part by the National Science Foundation and by the System Development Foundation. ‘TEX’ is a trademark of the American Mathematical Society.