1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23 /* All Rights Reserved */ 24 25 26 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ 27 28 /* 29 * 30 * Definitions used by the troff post-processor for PostScript printers. 31 * 32 * DEVNAME should be the name of a device whose font files accurately describe 33 * what's available on the target printer. It's a string that's combined with 34 * "/usr/lib/font/dev" to locate the final font directory. It can be changed 35 * using the -T option, but you may end up getting garbage - the character code 36 * field must agree with PostScript's character encoding scheme for each font and 37 * troff's one or two character font names must be mapped into the appropriate 38 * PostScript font names (typically in the prologue) 39 * 40 * 41 */ 42 43 #define DEVNAME "post" /* name of the target printer */ 44 45 /* 46 * 47 * NFONT is the most font positions we'll allow. It's set ridiculously high for no 48 * good reason. 49 * 50 */ 51 52 #define NFONT 60 /* max number of font positions */ 53 54 /* 55 * 56 * SLOP controls how much horizontal positioning error we'll accept and primarily 57 * helps when we're emulating another device. It's used when we output characters 58 * in oput() to check if troff and the printer have gotten too far out of sync. 59 * Given in units of points and can be changed using the -S option. Converted to 60 * machine units in t_init() after the resolution is known. 61 * 62 */ 63 64 #define SLOP .2 /* horizontal error - in points */ 65 66 /* 67 * 68 * Fonts are assigned unique internal numbers (positive integers) in their ASCII 69 * font files. MAXINTERNAL is the largest internal font number that lets the host 70 * resident and DOCUMENTFONTS stuff work. Used to allocate space for an array that 71 * keeps track of what fonts we've seen and perhaps downloaded - could be better! 72 * 73 */ 74 75 #define MAXINTERNAL 256 76 77 /* 78 * 79 * Several different text line encoding schemes are supported. Print time should 80 * decrease as the value assigned to encoding (in dpost.c) increases, although the 81 * only encoding that's well tested is the lowest level one, which produces output 82 * essentially identical to the original version of dpost. Setting DFLTENCODING to 83 * 0 will give you the most stable (but slowest) encoding. The encoding scheme can 84 * also be set on the command line using the -e option. Faster methods are based 85 * on widthshow and may not place words exactly where troff wanted, but errors will 86 * usually not be noticeable. 87 * 88 */ 89 90 #define MAXENCODING 3 91 92 #ifndef DFLTENCODING 93 #define DFLTENCODING 0 94 #endif 95 96 /* 97 * 98 * The encoding scheme controls how lines of text are output. In the lower level 99 * schemes words and horizontal positions are put on the stack as they're read and 100 * when they're printed it's done in reverse order - the first string printed is 101 * the one on top of the stack and it's the last one on the line. Faster methods 102 * may be forced to reverse the order of strings on the stack, making the top one 103 * the first string on the line. STRINGSPACE sets the size of a character array 104 * that's used to save the strings that make up a line of text so they can be 105 * output in reverse order or perhaps combined in groups for widthshow. 106 * 107 * MAXSTACK controls how far we let PostScript's operand stack grow and determines 108 * the number of strings we'll save before printing all or part of a line of text. 109 * The internal limit in PostScript printers built by Adobe is 500, so MAXSTACK 110 * should never be bigger than about 240! 111 * 112 * Line is a structure used to keep track of the words (or rather strings) on the 113 * current line that have been read but not printed. dx is the width troff wants 114 * to use for a space in the current string. start is where the string began, width 115 * is the total width of the string, and spaces is the number of space characters 116 * in the current string. *str points to the start of the string in the strings[] 117 * array. The Line structure is only used in the higher level encoding schemes. 118 * 119 */ 120 121 #define MAXSTACK 50 /* most strings we'll save at once */ 122 #define STRINGSPACE 2000 /* bytes available for string storage */ 123 124 typedef struct { 125 126 char *str; /* where the string is stored */ 127 int dx; /* width of a space */ 128 int spaces; /* number of space characters */ 129 int start; /* horizontal starting position */ 130 int width; /* and its total width */ 131 132 } Line; 133 134 /* 135 * 136 * Simple stuff used to map unrecognized font names into something reasonable. The 137 * mapping array is initialized using FONTMAP and used in loadfont() whenever the 138 * job tries to use a font that we don't recognize. Normally only needed when we're 139 * emulating another device. 140 * 141 */ 142 143 typedef struct { 144 145 char *name; /* font name we're looking for */ 146 char *use; /* and this is what we should use */ 147 148 } Fontmap; 149 150 #define FONTMAP \ 151 \ 152 { \ 153 "G", "H", \ 154 "LO", "S", \ 155 "S2", "S", \ 156 "GI", "HI", \ 157 "HM", "H", \ 158 "HK", "H", \ 159 "HL", "H", \ 160 "PA", "R", \ 161 "PI", "I", \ 162 "PB", "B", \ 163 "PX", "BI", \ 164 NULL, NULL, \ 165 } 166 167 /* 168 * 169 * The Fontmap stuff isn't quite enough if we expect to do a good job emulating 170 * other devices. A recognized font in *realdev's tables may be have a different 171 * name in *devname's tables, and using the *realdev font may not be the best 172 * choice. The fix is to use an optional lookup table for *devname that's used to 173 * map font names into something else before anything else is done. The table we 174 * use is /usr/lib/font/dev*realdev/fontmaps/devname and if it exists getdevmap() 175 * uses the file to fill in a Devfontmap array. Then whenever an "x font pos name" 176 * command is read mapdevfont() uses the lookup table to map name into something 177 * else before loadfont() is called. 178 * 179 */ 180 181 typedef struct { 182 183 char name[3]; /* map this font name */ 184 char use[3]; /* into this one */ 185 186 } Devfontmap; 187 188 /* 189 * 190 * Some of the non-integer valued functions in dpost.c. 191 * 192 */ 193 194 char *mapfont(); 195 char *mapdevfont(); 196 197