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