font(5) font(5)NAME font - description files for device-independent troff SYNOPSIS troff -Ttty-type ... DESCRIPTION For each phototypesetter that troff(1) supports and that is available on your system, there is a directory containing files describing the device and its fonts. This directory is named /usr/lib/font/devtty-type where tty-type is the name of the phototypesetter. Currently, the supported dev- ices are aps for the Autologic APS-5, psc for a POSTSCRIPT(Reg.) device such as the Apple LaserWriter(Reg.), and iw for the Apple ImageWriter(Reg.) II. For a particular phototypesetter, tty-type, the ASCII file DESC in the directory /usr/lib/font/devtty-type describes its characteristics. A binary version of the file (described later in this section) is found in the file /usr/lib/font/devtty-type/DESC.out. Each line of this ASCII file starts with a word that identifies the characteristic which is followed by appropriate specifiers. Blank lines and lines beginning with the # character are ignored. The legal lines for DESC are: res num Resolution of device in basic increments per inch. hor num Smallest unit of horizontal motion. vert num Smallest unit of vertical motion. unitwidth num Point size in which widths are speci- fied. sizescale num Scaling for fractional point sizes. paperwidth num Width of paper in basic increments. paperlength num Length of paper in basic increments. biggestfont num Maximum size of a font. sizes num num ... List of point sizes available on the typesetter. fonts num name ... Number of initial fonts followed by the names of the fonts. For example fonts 4 R I B S April, 1990 1
font(5) font(5)charset This always comes last in the file and is on a line by itself. Following it is the list of special character names for this device. Names are separated by a space or a newline. The list can be as long as necessary. Names not in this list are not allowed in the font description files. res is the basic resolution of the device in increments per inch. hor and vert describe the relationships between mo- tions in the horizontal and vertical directions. If the device is capable of moving in single basic increments in both directions, both hor and vert would have values of 1. If the vertical motions only take place in multiples of two basic units while the horizontal motions take place in the basic increments, then hor would be 1, while vert would be 2. unitwidth is the point size in which all width tables in the font description files are given. troff automatically scales the widths from the unitwidth size to the point size it is working with. sizescale is not currently used and is 1. paperwidth is the width of the paper in basic incre- ments. The APS-5 is 6120 increments wide. paperlength is the length of a sheet of paper in the basic increments. biggestfont is the maximum number of characters on a font. For each font supported by the phototypesetter, there is also an ASCII file with the same name as the font (for exam- ple, R, I, CW). The format for a font description file is name name Name of the font, such as R or CW. internalname name Internal name of the font. special Sets a flag indicating that the font is special. ligatures name...0 Sets a flag indicating font has liga- tures. The list of ligatures follows and is terminated by a zero. Accepted ligatures are: ff, fi, fl, ffi, and ffl. spacewidth num Specifies width of space if something other than default (1/3 of em) is desired. charset The charset must come at the end. Each line following the word charset describes one character in the font. Each line has one of two formats: 2 April, 1990
font(5) font(5)name width kerning code name " where name is either a single ASCII character or a special character name from the list found in DESC. The width is in basic increments. The kerning in- formation is 1 if the character descends below the line, 2 if it rises above the letter ``a,'' and 3 if it both rises and descends. The kerning information for special characters is not used and so may be 0. The code is the number sent to the typesetter to produce the charac- ter. The second format is used to indi- cate that the character has more than one name. The double quote indicates that this name has the same values as the preceding line. The kerning and code fields are not used if the width field is a double quote character. The total number of different characters in this list should not be greater than the value of biggestfont in the DESC file (as described earlier). troff and its postprocessors read this information from binary files produced from the ASCII files by a program dis- tributed with troff called makedev. For those with a need to know, a description of the format of these files follows. The file DESC.out starts with the dev structure, defined by dev.h. /* dev.h: characteristics of a typesetter */ struct dev { short filesize; /* number of bytes in file, */ /* excluding dev part */ short res; /* basic resolution in goobies per inch */ short hor; /* goobies horizontally */ short vert; short unitwidth; /* size at which widths are given*/ short nfonts; /* number fonts physically available */ short nsizes; /* number of pointsizes */ short sizescale; /* scaling for fractional point sizes */ April, 1990 3
font(5) font(5)short paperwidth; /* max line length in units */ short paperlength; /* max paper length in units */ short nchtab; /* number of funny names in chtab */ short lchname; /* length of chname table */ short biggestfont; /* max # of chars in a font */ short spare2; /* in case of expansion */ }; filesize is merely the size of everything in DESC.out ex- cluding the dev structure. nfonts is the number of dif- ferent font positions available. nsizes is the number of different point sizes supported by this typesetter. nchtab is the number of special character names. lchname is the total number of characters, including nulls, needed to list all the special character names. At the end of the struc- ture are two spares for later expansion. Immediately following the dev structure are a number of tables. First is the sizes table, which contains nsizes+1 shorts (a null at the end), describing the point sizes of text available on this device. The second table is the funny_char_index_table. It contains indexes for the the table which follows it, the funny_char_strings. The indexes point to the beginning of each special character name which is stored in the funny_char_strings table. The funny_char_strings table is lchname characters long, while the funny_char_index_table is nchtab shorts long. Following the dev structure will occur nfonts {font}.out files, which are used to initialize the font positions. These {font}.out files, which also exist as separate files, begin with a font structure and then are followed by four character arrays. struct Font { /* characteristics of a font */ char nwfont; /* number of width entries */ char specfont; /* 1 == special font */ char ligfont; /* 1 == ligatures exist on this font */ char namefont[10]; /* name of this font, e.g., R */ char intname[10]; /* internal name of font, in ASCII */ }; The font structure tells how many defined characters there are in the font, whether the font is a ``special'' font and if it contains ligatures. It also has the ASCII name of the font, which should match the name of the file it appears in, and the internal name of the font located on the typesetting device (intname). The internal name is independent of the 4 April, 1990
font(5) font(5)font position and name that troff knows about. For example, you might say ``mount R in position 4'', but when asking the typesetter to actually produce a character from the R font, the postprocessor which instructs the typesetter would use intname. The first three character arrays are specific for the font and run in parallel. The first array, widths, contains the width of each character relative to unitwidth. unitwidth is defined in DESC. The second array, kerning, contains kern- ing information. If a character rises above the letter ``a,'' 02 is set. If it descends below the line, 01 is set. The third array, codes, contains the code that is sent to the typesetter to produce the character. The fourth array is defined by the device description in DESC. It is the font_index_table. This table contains in- dices into the width, kerning, and code tables for each character. The order that characters appear in these three tables is arbitrary and changes from one font to the next. In order for troff to be able to translate from ASCII and the special character names to these arbitrary tables, the font_index_table is created with an order which is constant for each device. The number of entries in this table is 96 plus the number of special character names for this device. The value 96 is 128-32, the number of printable characters in the ASCII alphabet. To determine whether a normal ASCII character exists, troff takes the ASCII value of the charac- ter, subtracts 32, and looks in the font_index_table. If it finds a 0, the character is not defined in this font. If it finds anything else, that is the index into widths, kerning, and codes tables that describe the character. To look up a special character name, (for example \(pl, the mathematical plus sign), and to determine whether it appears in a particular font or not, the following procedure is fol- lowed. A counter is set to 0 and an index to a special character name is picked out of the counter position in the funny_char_index_table. A string comparison is performed between the element in the array funny_char_strings [funny_char_index_table [counter]] and the special character name, in our example pl, and if it matches, then troff refers to this character as (96+counter). When it wants to determine whether a specific font supports this character, it looks in font_index_table[(96+counter)], to see whether there is a 0, meaning the character does not appear in this font, or number, which is the index into the widths, kerning, and codes tables. Notice that since a value of 0 in the font_index_table indi- cates that a character does not exist, the 0th element of April, 1990 5
font(5) font(5)the width, kerning, and codes arrays are not used. For this reason the 0th element of the width array can be used for a special purpose, defining the width of a space for a font. Normally a space is defined by troff to be 1/3 of the width of the \(em character, but if the 0th element of the width array is nonzero, then that value is used for the width of a space. SEE ALSO troff(1). FILES /usr/lib/font/devtty_type/DESC.out /usr/lib/font/devtty-type/font.out 6 April, 1990