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 /* 23*7c478bd9Sstevel@tonic-gate * Copyright 1989 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate /* 34*7c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 35*7c478bd9Sstevel@tonic-gate * The Regents of the University of California 36*7c478bd9Sstevel@tonic-gate * All Rights Reserved 37*7c478bd9Sstevel@tonic-gate * 38*7c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 39*7c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 40*7c478bd9Sstevel@tonic-gate * contributors. 41*7c478bd9Sstevel@tonic-gate */ 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #include "tdef.h" 44*7c478bd9Sstevel@tonic-gate #include <ctype.h> 45*7c478bd9Sstevel@tonic-gate #include "ext.h" 46*7c478bd9Sstevel@tonic-gate /* 47*7c478bd9Sstevel@tonic-gate * troff10.c 48*7c478bd9Sstevel@tonic-gate * 49*7c478bd9Sstevel@tonic-gate * typesetter interface 50*7c478bd9Sstevel@tonic-gate */ 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate int vpos = 0; /* absolute vertical position on page */ 53*7c478bd9Sstevel@tonic-gate int hpos = 0; /* ditto horizontal */ 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate short *chtab; 56*7c478bd9Sstevel@tonic-gate char *chname; 57*7c478bd9Sstevel@tonic-gate char *fontab[NFONT+1]; 58*7c478bd9Sstevel@tonic-gate char *kerntab[NFONT+1]; 59*7c478bd9Sstevel@tonic-gate char *fitab[NFONT+1]; 60*7c478bd9Sstevel@tonic-gate char *codetab[NFONT+1]; 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate int Inch; 63*7c478bd9Sstevel@tonic-gate int Hor; 64*7c478bd9Sstevel@tonic-gate int Vert; 65*7c478bd9Sstevel@tonic-gate int Unitwidth; 66*7c478bd9Sstevel@tonic-gate int nfonts; 67*7c478bd9Sstevel@tonic-gate int nsizes; 68*7c478bd9Sstevel@tonic-gate int nchtab; 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate /* these characters are used as various signals or values 71*7c478bd9Sstevel@tonic-gate * in miscellaneous places. 72*7c478bd9Sstevel@tonic-gate * values are set in specnames in t10.c 73*7c478bd9Sstevel@tonic-gate */ 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate int c_hyphen; 76*7c478bd9Sstevel@tonic-gate int c_emdash; 77*7c478bd9Sstevel@tonic-gate int c_rule; 78*7c478bd9Sstevel@tonic-gate int c_minus; 79*7c478bd9Sstevel@tonic-gate int c_fi; 80*7c478bd9Sstevel@tonic-gate int c_fl; 81*7c478bd9Sstevel@tonic-gate int c_ff; 82*7c478bd9Sstevel@tonic-gate int c_ffi; 83*7c478bd9Sstevel@tonic-gate int c_ffl; 84*7c478bd9Sstevel@tonic-gate int c_acute; 85*7c478bd9Sstevel@tonic-gate int c_grave; 86*7c478bd9Sstevel@tonic-gate int c_under; 87*7c478bd9Sstevel@tonic-gate int c_rooten; 88*7c478bd9Sstevel@tonic-gate int c_boxrule; 89*7c478bd9Sstevel@tonic-gate int c_lefthand; 90*7c478bd9Sstevel@tonic-gate int c_dagger; 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gate #include "dev.h" 93*7c478bd9Sstevel@tonic-gate struct dev dev; 94*7c478bd9Sstevel@tonic-gate struct Font *fontbase[NFONT+1]; 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate tchar *ptout0(); 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate ptinit() 100*7c478bd9Sstevel@tonic-gate { 101*7c478bd9Sstevel@tonic-gate int i, fin, nw; 102*7c478bd9Sstevel@tonic-gate char *setbrk(), *filebase, *p; 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate /* open table for device, 105*7c478bd9Sstevel@tonic-gate * read in resolution, size info, font info, etc. 106*7c478bd9Sstevel@tonic-gate * and set params 107*7c478bd9Sstevel@tonic-gate */ 108*7c478bd9Sstevel@tonic-gate strcat(termtab, "/dev"); 109*7c478bd9Sstevel@tonic-gate strcat(termtab, devname); 110*7c478bd9Sstevel@tonic-gate strcat(termtab, "/DESC.out"); /* makes "..../devXXX/DESC.out" */ 111*7c478bd9Sstevel@tonic-gate if ((fin = open(termtab, 0)) < 0) { 112*7c478bd9Sstevel@tonic-gate errprint(gettext("can't open tables for %s"), termtab); 113*7c478bd9Sstevel@tonic-gate done3(1); 114*7c478bd9Sstevel@tonic-gate } 115*7c478bd9Sstevel@tonic-gate read(fin, (char *) &dev, sizeof(struct dev )); 116*7c478bd9Sstevel@tonic-gate Inch = dev.res; 117*7c478bd9Sstevel@tonic-gate Hor = dev.hor; 118*7c478bd9Sstevel@tonic-gate Vert = dev.vert; 119*7c478bd9Sstevel@tonic-gate Unitwidth = dev.unitwidth; 120*7c478bd9Sstevel@tonic-gate nfonts = dev.nfonts; 121*7c478bd9Sstevel@tonic-gate nsizes = dev.nsizes; 122*7c478bd9Sstevel@tonic-gate nchtab = dev.nchtab; 123*7c478bd9Sstevel@tonic-gate if (nchtab >= NCHARS - 128) { 124*7c478bd9Sstevel@tonic-gate errprint(gettext("too many special characters in file %s"), 125*7c478bd9Sstevel@tonic-gate termtab); 126*7c478bd9Sstevel@tonic-gate done3(1); 127*7c478bd9Sstevel@tonic-gate } 128*7c478bd9Sstevel@tonic-gate filebase = setbrk(dev.filesize + 2*EXTRAFONT); /* enough room for whole file */ 129*7c478bd9Sstevel@tonic-gate read(fin, filebase, dev.filesize); /* all at once */ 130*7c478bd9Sstevel@tonic-gate pstab = (short *) filebase; 131*7c478bd9Sstevel@tonic-gate chtab = pstab + nsizes + 1; 132*7c478bd9Sstevel@tonic-gate chname = (char *) (chtab + dev.nchtab); 133*7c478bd9Sstevel@tonic-gate p = chname + dev.lchname; 134*7c478bd9Sstevel@tonic-gate for (i = 1; i <= nfonts; i++) { 135*7c478bd9Sstevel@tonic-gate fontbase[i] = (struct Font *) p; 136*7c478bd9Sstevel@tonic-gate nw = *p & BYTEMASK; /* 1st thing is width count */ 137*7c478bd9Sstevel@tonic-gate fontlab[i] = PAIR(fontbase[i]->namefont[0], fontbase[i]->namefont[1]); 138*7c478bd9Sstevel@tonic-gate /* for now, still 2 char names */ 139*7c478bd9Sstevel@tonic-gate if (smnt == 0 && fontbase[i]->specfont == 1) 140*7c478bd9Sstevel@tonic-gate smnt = i; /* first special font */ 141*7c478bd9Sstevel@tonic-gate p += sizeof(struct Font); /* that's what's on the beginning */ 142*7c478bd9Sstevel@tonic-gate fontab[i] = p; 143*7c478bd9Sstevel@tonic-gate kerntab[i] = p + nw; 144*7c478bd9Sstevel@tonic-gate codetab[i] = p + 2 * nw; 145*7c478bd9Sstevel@tonic-gate fitab[i] = p + 3 * nw; /* skip width, kern, code */ 146*7c478bd9Sstevel@tonic-gate p += 3 * nw + dev.nchtab + 128 - 32; 147*7c478bd9Sstevel@tonic-gate } 148*7c478bd9Sstevel@tonic-gate fontbase[0] = (struct Font *) p; /* the last shall be first */ 149*7c478bd9Sstevel@tonic-gate fontbase[0]->nwfont = EXTRAFONT - dev.nchtab - (128-32) - sizeof (struct Font); 150*7c478bd9Sstevel@tonic-gate fontab[0] = p + sizeof (struct Font); 151*7c478bd9Sstevel@tonic-gate close(fin); 152*7c478bd9Sstevel@tonic-gate /* there are a lot of things that used to be constant 153*7c478bd9Sstevel@tonic-gate * that now require code to be executed. 154*7c478bd9Sstevel@tonic-gate */ 155*7c478bd9Sstevel@tonic-gate sps = SPS; 156*7c478bd9Sstevel@tonic-gate ics = ICS; 157*7c478bd9Sstevel@tonic-gate for (i = 0; i < 16; i++) 158*7c478bd9Sstevel@tonic-gate tabtab[i] = DTAB * (i + 1); 159*7c478bd9Sstevel@tonic-gate pl = 11 * INCH; 160*7c478bd9Sstevel@tonic-gate po = PO; 161*7c478bd9Sstevel@tonic-gate spacesz = SS; 162*7c478bd9Sstevel@tonic-gate lss = lss1 = VS; 163*7c478bd9Sstevel@tonic-gate ll = ll1 = lt = lt1 = LL; 164*7c478bd9Sstevel@tonic-gate specnames(); /* install names like "hyphen", etc. */ 165*7c478bd9Sstevel@tonic-gate if (ascii) 166*7c478bd9Sstevel@tonic-gate return; 167*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x T %s\n", devname); 168*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x res %d %d %d\n", Inch, Hor, Vert); 169*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x init\n"); /* do initialization for particular device */ 170*7c478bd9Sstevel@tonic-gate /* 171*7c478bd9Sstevel@tonic-gate for (i = 1; i <= nfonts; i++) 172*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x font %d %s\n", i, fontbase[i]->namefont); 173*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x xxx fonts=%d sizes=%d unit=%d\n", nfonts, nsizes, Unitwidth); 174*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x xxx nchtab=%d lchname=%d nfitab=%d\n", 175*7c478bd9Sstevel@tonic-gate dev.nchtab, dev.lchname, dev.nchtab+128-32); 176*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x xxx sizes:\nx xxx "); 177*7c478bd9Sstevel@tonic-gate for (i = 0; i < nsizes; i++) 178*7c478bd9Sstevel@tonic-gate fdprintf(ptid, " %d", pstab[i]); 179*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "\nx xxx chars:\nx xxx "); 180*7c478bd9Sstevel@tonic-gate for (i = 0; i < dev.nchtab; i++) 181*7c478bd9Sstevel@tonic-gate fdprintf(ptid, " %s", &chname[chtab[i]]); 182*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "\nx xxx\n"); 183*7c478bd9Sstevel@tonic-gate */ 184*7c478bd9Sstevel@tonic-gate } 185*7c478bd9Sstevel@tonic-gate 186*7c478bd9Sstevel@tonic-gate specnames() 187*7c478bd9Sstevel@tonic-gate { 188*7c478bd9Sstevel@tonic-gate static struct { 189*7c478bd9Sstevel@tonic-gate int *n; 190*7c478bd9Sstevel@tonic-gate char *v; 191*7c478bd9Sstevel@tonic-gate } spnames[] = { 192*7c478bd9Sstevel@tonic-gate &c_hyphen, "hy", 193*7c478bd9Sstevel@tonic-gate &c_emdash, "em", 194*7c478bd9Sstevel@tonic-gate &c_rule, "ru", 195*7c478bd9Sstevel@tonic-gate &c_minus, "\\-", 196*7c478bd9Sstevel@tonic-gate &c_fi, "fi", 197*7c478bd9Sstevel@tonic-gate &c_fl, "fl", 198*7c478bd9Sstevel@tonic-gate &c_ff, "ff", 199*7c478bd9Sstevel@tonic-gate &c_ffi, "Fi", 200*7c478bd9Sstevel@tonic-gate &c_ffl, "Fl", 201*7c478bd9Sstevel@tonic-gate &c_acute, "aa", 202*7c478bd9Sstevel@tonic-gate &c_grave, "ga", 203*7c478bd9Sstevel@tonic-gate &c_under, "ul", 204*7c478bd9Sstevel@tonic-gate &c_rooten, "rn", 205*7c478bd9Sstevel@tonic-gate &c_boxrule, "br", 206*7c478bd9Sstevel@tonic-gate &c_lefthand, "lh", 207*7c478bd9Sstevel@tonic-gate &c_dagger, "dg", 208*7c478bd9Sstevel@tonic-gate 0, 0 209*7c478bd9Sstevel@tonic-gate }; 210*7c478bd9Sstevel@tonic-gate int i; 211*7c478bd9Sstevel@tonic-gate 212*7c478bd9Sstevel@tonic-gate for (i = 0; spnames[i].n; i++) 213*7c478bd9Sstevel@tonic-gate *spnames[i].n = findch(spnames[i].v); 214*7c478bd9Sstevel@tonic-gate } 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate findch(s) /* find char s in chname */ 217*7c478bd9Sstevel@tonic-gate register char *s; 218*7c478bd9Sstevel@tonic-gate { 219*7c478bd9Sstevel@tonic-gate register int i; 220*7c478bd9Sstevel@tonic-gate 221*7c478bd9Sstevel@tonic-gate for (i = 0; i < nchtab; i++) 222*7c478bd9Sstevel@tonic-gate if (strcmp(s, &chname[chtab[i]]) == 0) 223*7c478bd9Sstevel@tonic-gate return(i + 128); 224*7c478bd9Sstevel@tonic-gate return(0); 225*7c478bd9Sstevel@tonic-gate } 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate ptout(i) 228*7c478bd9Sstevel@tonic-gate register tchar i; 229*7c478bd9Sstevel@tonic-gate { 230*7c478bd9Sstevel@tonic-gate register dv; 231*7c478bd9Sstevel@tonic-gate register tchar *k; 232*7c478bd9Sstevel@tonic-gate int temp, a, b; 233*7c478bd9Sstevel@tonic-gate 234*7c478bd9Sstevel@tonic-gate if (cbits(i) != '\n') { 235*7c478bd9Sstevel@tonic-gate *olinep++ = i; 236*7c478bd9Sstevel@tonic-gate return; 237*7c478bd9Sstevel@tonic-gate } 238*7c478bd9Sstevel@tonic-gate if (olinep == oline) { 239*7c478bd9Sstevel@tonic-gate lead += lss; 240*7c478bd9Sstevel@tonic-gate return; 241*7c478bd9Sstevel@tonic-gate } 242*7c478bd9Sstevel@tonic-gate 243*7c478bd9Sstevel@tonic-gate hpos = po; /* ??? */ 244*7c478bd9Sstevel@tonic-gate esc = 0; /* ??? */ 245*7c478bd9Sstevel@tonic-gate ptesc(); /* the problem is to get back to the left end of the line */ 246*7c478bd9Sstevel@tonic-gate dv = 0; 247*7c478bd9Sstevel@tonic-gate for (k = oline; k < olinep; k++) { 248*7c478bd9Sstevel@tonic-gate if (ismot(*k) && isvmot(*k)) { 249*7c478bd9Sstevel@tonic-gate temp = absmot(*k); 250*7c478bd9Sstevel@tonic-gate if (isnmot(*k)) 251*7c478bd9Sstevel@tonic-gate temp = -temp; 252*7c478bd9Sstevel@tonic-gate dv += temp; 253*7c478bd9Sstevel@tonic-gate } 254*7c478bd9Sstevel@tonic-gate } 255*7c478bd9Sstevel@tonic-gate if (dv) { 256*7c478bd9Sstevel@tonic-gate vflag++; 257*7c478bd9Sstevel@tonic-gate *olinep++ = makem(-dv); 258*7c478bd9Sstevel@tonic-gate vflag = 0; 259*7c478bd9Sstevel@tonic-gate } 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate b = dip->blss + lss; 262*7c478bd9Sstevel@tonic-gate lead += dip->blss + lss; 263*7c478bd9Sstevel@tonic-gate dip->blss = 0; 264*7c478bd9Sstevel@tonic-gate for (k = oline; k < olinep; ) 265*7c478bd9Sstevel@tonic-gate k = ptout0(k); /* now passing a pointer! */ 266*7c478bd9Sstevel@tonic-gate olinep = oline; 267*7c478bd9Sstevel@tonic-gate lead += dip->alss; 268*7c478bd9Sstevel@tonic-gate a = dip->alss; 269*7c478bd9Sstevel@tonic-gate dip->alss = 0; 270*7c478bd9Sstevel@tonic-gate /* 271*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x xxx end of line: hpos=%d, vpos=%d\n", hpos, vpos); 272*7c478bd9Sstevel@tonic-gate */ 273*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "n%d %d\n", b, a); /* be nice to chuck */ 274*7c478bd9Sstevel@tonic-gate } 275*7c478bd9Sstevel@tonic-gate 276*7c478bd9Sstevel@tonic-gate tchar * 277*7c478bd9Sstevel@tonic-gate ptout0(pi) 278*7c478bd9Sstevel@tonic-gate tchar *pi; 279*7c478bd9Sstevel@tonic-gate { 280*7c478bd9Sstevel@tonic-gate register short j, k, w; 281*7c478bd9Sstevel@tonic-gate short z, dx, dy, dx2, dy2, n; 282*7c478bd9Sstevel@tonic-gate register tchar i; 283*7c478bd9Sstevel@tonic-gate int outsize; /* size of object being printed */ 284*7c478bd9Sstevel@tonic-gate 285*7c478bd9Sstevel@tonic-gate outsize = 1; /* default */ 286*7c478bd9Sstevel@tonic-gate i = *pi; 287*7c478bd9Sstevel@tonic-gate k = cbits(i); 288*7c478bd9Sstevel@tonic-gate if (ismot(i)) { 289*7c478bd9Sstevel@tonic-gate j = absmot(i); 290*7c478bd9Sstevel@tonic-gate if (isnmot(i)) 291*7c478bd9Sstevel@tonic-gate j = -j; 292*7c478bd9Sstevel@tonic-gate if (isvmot(i)) 293*7c478bd9Sstevel@tonic-gate lead += j; 294*7c478bd9Sstevel@tonic-gate else 295*7c478bd9Sstevel@tonic-gate esc += j; 296*7c478bd9Sstevel@tonic-gate return(pi+outsize); 297*7c478bd9Sstevel@tonic-gate } 298*7c478bd9Sstevel@tonic-gate if (k == XON) { 299*7c478bd9Sstevel@tonic-gate if (xfont != mfont) 300*7c478bd9Sstevel@tonic-gate ptfont(); 301*7c478bd9Sstevel@tonic-gate if (xpts != mpts) 302*7c478bd9Sstevel@tonic-gate ptps(); 303*7c478bd9Sstevel@tonic-gate if (lead) 304*7c478bd9Sstevel@tonic-gate ptlead(); 305*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x X "); 306*7c478bd9Sstevel@tonic-gate /* 307*7c478bd9Sstevel@tonic-gate * not guaranteed of finding a XOFF if a word overflow 308*7c478bd9Sstevel@tonic-gate * error occured, so also bound this loop by olinep 309*7c478bd9Sstevel@tonic-gate */ 310*7c478bd9Sstevel@tonic-gate pi++; 311*7c478bd9Sstevel@tonic-gate while( cbits(*pi) != XOFF && pi < olinep ) 312*7c478bd9Sstevel@tonic-gate outascii(*pi++); 313*7c478bd9Sstevel@tonic-gate oput('\n'); 314*7c478bd9Sstevel@tonic-gate if ( cbits(*pi) == XOFF ) 315*7c478bd9Sstevel@tonic-gate pi++; 316*7c478bd9Sstevel@tonic-gate return pi; 317*7c478bd9Sstevel@tonic-gate } 318*7c478bd9Sstevel@tonic-gate ; 319*7c478bd9Sstevel@tonic-gate if (k == CHARHT) { 320*7c478bd9Sstevel@tonic-gate if (xpts != mpts) 321*7c478bd9Sstevel@tonic-gate ptps(); 322*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x H %d\n", sbits(i)); 323*7c478bd9Sstevel@tonic-gate return(pi+outsize); 324*7c478bd9Sstevel@tonic-gate } 325*7c478bd9Sstevel@tonic-gate if (k == SLANT) { 326*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x S %d\n", sfbits(i)-180); 327*7c478bd9Sstevel@tonic-gate return(pi+outsize); 328*7c478bd9Sstevel@tonic-gate } 329*7c478bd9Sstevel@tonic-gate if (k == WORDSP) { 330*7c478bd9Sstevel@tonic-gate oput('w'); 331*7c478bd9Sstevel@tonic-gate return(pi+outsize); 332*7c478bd9Sstevel@tonic-gate } 333*7c478bd9Sstevel@tonic-gate if (k == FONTPOS) { 334*7c478bd9Sstevel@tonic-gate char temp[3]; 335*7c478bd9Sstevel@tonic-gate n = i >> 16; 336*7c478bd9Sstevel@tonic-gate temp[0] = n & BYTEMASK; 337*7c478bd9Sstevel@tonic-gate temp[1] = n >> BYTE; 338*7c478bd9Sstevel@tonic-gate temp[2] = 0; 339*7c478bd9Sstevel@tonic-gate ptfpcmd(0, temp); 340*7c478bd9Sstevel@tonic-gate return(pi+outsize); 341*7c478bd9Sstevel@tonic-gate } 342*7c478bd9Sstevel@tonic-gate if (sfbits(i) == oldbits) { 343*7c478bd9Sstevel@tonic-gate xfont = pfont; 344*7c478bd9Sstevel@tonic-gate xpts = ppts; 345*7c478bd9Sstevel@tonic-gate } else 346*7c478bd9Sstevel@tonic-gate xbits(i, 2); 347*7c478bd9Sstevel@tonic-gate if (k < 040 && k != DRAWFCN) 348*7c478bd9Sstevel@tonic-gate return(pi+outsize); 349*7c478bd9Sstevel@tonic-gate if (k >= 32) { 350*7c478bd9Sstevel@tonic-gate if (widcache[k-32].fontpts == (xfont<<8) + xpts && !setwdf) { 351*7c478bd9Sstevel@tonic-gate w = widcache[k-32].width; 352*7c478bd9Sstevel@tonic-gate bd = 0; 353*7c478bd9Sstevel@tonic-gate cs = 0; 354*7c478bd9Sstevel@tonic-gate } else 355*7c478bd9Sstevel@tonic-gate w = getcw(k-32); 356*7c478bd9Sstevel@tonic-gate } 357*7c478bd9Sstevel@tonic-gate j = z = 0; 358*7c478bd9Sstevel@tonic-gate if (k != DRAWFCN) { 359*7c478bd9Sstevel@tonic-gate if (cs) { 360*7c478bd9Sstevel@tonic-gate if (bd) 361*7c478bd9Sstevel@tonic-gate w += (bd - 1) * HOR; 362*7c478bd9Sstevel@tonic-gate j = (cs - w) / 2; 363*7c478bd9Sstevel@tonic-gate w = cs - j; 364*7c478bd9Sstevel@tonic-gate if (bd) 365*7c478bd9Sstevel@tonic-gate w -= (bd - 1) * HOR; 366*7c478bd9Sstevel@tonic-gate } 367*7c478bd9Sstevel@tonic-gate if (iszbit(i)) { 368*7c478bd9Sstevel@tonic-gate if (cs) 369*7c478bd9Sstevel@tonic-gate w = -j; 370*7c478bd9Sstevel@tonic-gate else 371*7c478bd9Sstevel@tonic-gate w = 0; 372*7c478bd9Sstevel@tonic-gate z = 1; 373*7c478bd9Sstevel@tonic-gate } 374*7c478bd9Sstevel@tonic-gate } 375*7c478bd9Sstevel@tonic-gate esc += j; 376*7c478bd9Sstevel@tonic-gate if (xfont != mfont) 377*7c478bd9Sstevel@tonic-gate ptfont(); 378*7c478bd9Sstevel@tonic-gate if (xpts != mpts) 379*7c478bd9Sstevel@tonic-gate ptps(); 380*7c478bd9Sstevel@tonic-gate if (lead) 381*7c478bd9Sstevel@tonic-gate ptlead(); 382*7c478bd9Sstevel@tonic-gate /* put out the real character here */ 383*7c478bd9Sstevel@tonic-gate if (k == DRAWFCN) { 384*7c478bd9Sstevel@tonic-gate if (esc) 385*7c478bd9Sstevel@tonic-gate ptesc(); 386*7c478bd9Sstevel@tonic-gate dx = absmot(pi[3]); 387*7c478bd9Sstevel@tonic-gate if (isnmot(pi[3])) 388*7c478bd9Sstevel@tonic-gate dx = -dx; 389*7c478bd9Sstevel@tonic-gate dy = absmot(pi[4]); 390*7c478bd9Sstevel@tonic-gate if (isnmot(pi[4])) 391*7c478bd9Sstevel@tonic-gate dy = -dy; 392*7c478bd9Sstevel@tonic-gate switch (cbits(pi[1])) { 393*7c478bd9Sstevel@tonic-gate case DRAWCIRCLE: /* circle */ 394*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "D%c %d\n", DRAWCIRCLE, dx); /* dx is diameter */ 395*7c478bd9Sstevel@tonic-gate w = 0; 396*7c478bd9Sstevel@tonic-gate hpos += dx; 397*7c478bd9Sstevel@tonic-gate break; 398*7c478bd9Sstevel@tonic-gate case DRAWELLIPSE: 399*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "D%c %d %d\n", DRAWELLIPSE, dx, dy); 400*7c478bd9Sstevel@tonic-gate w = 0; 401*7c478bd9Sstevel@tonic-gate hpos += dx; 402*7c478bd9Sstevel@tonic-gate break; 403*7c478bd9Sstevel@tonic-gate case DRAWLINE: /* line */ 404*7c478bd9Sstevel@tonic-gate k = cbits(pi[2]); 405*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "D%c %d %d ", DRAWLINE, dx, dy); 406*7c478bd9Sstevel@tonic-gate if (k < 128) 407*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "%c\n", k); 408*7c478bd9Sstevel@tonic-gate else 409*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "%s\n", &chname[chtab[k - 128]]); 410*7c478bd9Sstevel@tonic-gate w = 0; 411*7c478bd9Sstevel@tonic-gate hpos += dx; 412*7c478bd9Sstevel@tonic-gate vpos += dy; 413*7c478bd9Sstevel@tonic-gate break; 414*7c478bd9Sstevel@tonic-gate case DRAWARC: /* arc */ 415*7c478bd9Sstevel@tonic-gate dx2 = absmot(pi[5]); 416*7c478bd9Sstevel@tonic-gate if (isnmot(pi[5])) 417*7c478bd9Sstevel@tonic-gate dx2 = -dx2; 418*7c478bd9Sstevel@tonic-gate dy2 = absmot(pi[6]); 419*7c478bd9Sstevel@tonic-gate if (isnmot(pi[6])) 420*7c478bd9Sstevel@tonic-gate dy2 = -dy2; 421*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "D%c %d %d %d %d\n", DRAWARC, 422*7c478bd9Sstevel@tonic-gate dx, dy, dx2, dy2); 423*7c478bd9Sstevel@tonic-gate w = 0; 424*7c478bd9Sstevel@tonic-gate hpos += dx + dx2; 425*7c478bd9Sstevel@tonic-gate vpos += dy + dy2; 426*7c478bd9Sstevel@tonic-gate break; 427*7c478bd9Sstevel@tonic-gate case DRAWSPLINE: /* spline */ 428*7c478bd9Sstevel@tonic-gate default: /* something else; copy it like spline */ 429*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "D%c %d %d", cbits(pi[1]), dx, dy); 430*7c478bd9Sstevel@tonic-gate w = 0; 431*7c478bd9Sstevel@tonic-gate hpos += dx; 432*7c478bd9Sstevel@tonic-gate vpos += dy; 433*7c478bd9Sstevel@tonic-gate if (cbits(pi[3]) == DRAWFCN || cbits(pi[4]) == DRAWFCN) { 434*7c478bd9Sstevel@tonic-gate /* it was somehow defective */ 435*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "\n"); 436*7c478bd9Sstevel@tonic-gate break; 437*7c478bd9Sstevel@tonic-gate } 438*7c478bd9Sstevel@tonic-gate for (n = 5; cbits(pi[n]) != DRAWFCN; n += 2) { 439*7c478bd9Sstevel@tonic-gate dx = absmot(pi[n]); 440*7c478bd9Sstevel@tonic-gate if (isnmot(pi[n])) 441*7c478bd9Sstevel@tonic-gate dx = -dx; 442*7c478bd9Sstevel@tonic-gate dy = absmot(pi[n+1]); 443*7c478bd9Sstevel@tonic-gate if (isnmot(pi[n+1])) 444*7c478bd9Sstevel@tonic-gate dy = -dy; 445*7c478bd9Sstevel@tonic-gate fdprintf(ptid, " %d %d", dx, dy); 446*7c478bd9Sstevel@tonic-gate hpos += dx; 447*7c478bd9Sstevel@tonic-gate vpos += dy; 448*7c478bd9Sstevel@tonic-gate } 449*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "\n"); 450*7c478bd9Sstevel@tonic-gate break; 451*7c478bd9Sstevel@tonic-gate } 452*7c478bd9Sstevel@tonic-gate for (n = 3; cbits(pi[n]) != DRAWFCN; n++) 453*7c478bd9Sstevel@tonic-gate ; 454*7c478bd9Sstevel@tonic-gate outsize = n + 1; 455*7c478bd9Sstevel@tonic-gate } else if (k < 128) { 456*7c478bd9Sstevel@tonic-gate /* try to go faster and compress output */ 457*7c478bd9Sstevel@tonic-gate /* by printing nnc for small positive motion followed by c */ 458*7c478bd9Sstevel@tonic-gate /* kludgery; have to make sure set all the vars too */ 459*7c478bd9Sstevel@tonic-gate if (esc > 0 && esc < 100) { 460*7c478bd9Sstevel@tonic-gate oput(esc / 10 + '0'); 461*7c478bd9Sstevel@tonic-gate oput(esc % 10 + '0'); 462*7c478bd9Sstevel@tonic-gate oput(k); 463*7c478bd9Sstevel@tonic-gate hpos += esc; 464*7c478bd9Sstevel@tonic-gate esc = 0; 465*7c478bd9Sstevel@tonic-gate } else { 466*7c478bd9Sstevel@tonic-gate if (esc) 467*7c478bd9Sstevel@tonic-gate ptesc(); 468*7c478bd9Sstevel@tonic-gate oput('c'); 469*7c478bd9Sstevel@tonic-gate oput(k); 470*7c478bd9Sstevel@tonic-gate oput('\n'); 471*7c478bd9Sstevel@tonic-gate } 472*7c478bd9Sstevel@tonic-gate } else { 473*7c478bd9Sstevel@tonic-gate if (esc) 474*7c478bd9Sstevel@tonic-gate ptesc(); 475*7c478bd9Sstevel@tonic-gate if (k >= nchtab + 128) 476*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "N%d\n", k - (nchtab+128)); 477*7c478bd9Sstevel@tonic-gate else 478*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "C%s\n", &chname[chtab[k - 128]]); 479*7c478bd9Sstevel@tonic-gate } 480*7c478bd9Sstevel@tonic-gate if (bd) { 481*7c478bd9Sstevel@tonic-gate bd -= HOR; 482*7c478bd9Sstevel@tonic-gate if (esc += bd) 483*7c478bd9Sstevel@tonic-gate ptesc(); 484*7c478bd9Sstevel@tonic-gate if (k < 128) { 485*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "c%c\n", k); 486*7c478bd9Sstevel@tonic-gate } else if (k >= nchtab + 128) { 487*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "N%d\n", k - (nchtab+128)); 488*7c478bd9Sstevel@tonic-gate } else 489*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "C%s\n", &chname[chtab[k - 128]]); 490*7c478bd9Sstevel@tonic-gate if (z) 491*7c478bd9Sstevel@tonic-gate esc -= bd; 492*7c478bd9Sstevel@tonic-gate } 493*7c478bd9Sstevel@tonic-gate esc += w; 494*7c478bd9Sstevel@tonic-gate return(pi+outsize); 495*7c478bd9Sstevel@tonic-gate } 496*7c478bd9Sstevel@tonic-gate 497*7c478bd9Sstevel@tonic-gate ptps() 498*7c478bd9Sstevel@tonic-gate { 499*7c478bd9Sstevel@tonic-gate register i, j, k; 500*7c478bd9Sstevel@tonic-gate 501*7c478bd9Sstevel@tonic-gate i = xpts; 502*7c478bd9Sstevel@tonic-gate for (j = 0; i > (k = pstab[j]); j++) 503*7c478bd9Sstevel@tonic-gate if (!k) { 504*7c478bd9Sstevel@tonic-gate k = pstab[--j]; 505*7c478bd9Sstevel@tonic-gate break; 506*7c478bd9Sstevel@tonic-gate } 507*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "s%d\n", k); /* really should put out string rep of size */ 508*7c478bd9Sstevel@tonic-gate mpts = i; 509*7c478bd9Sstevel@tonic-gate } 510*7c478bd9Sstevel@tonic-gate 511*7c478bd9Sstevel@tonic-gate ptfont() 512*7c478bd9Sstevel@tonic-gate { 513*7c478bd9Sstevel@tonic-gate mfont = xfont; 514*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "f%d\n", xfont); 515*7c478bd9Sstevel@tonic-gate } 516*7c478bd9Sstevel@tonic-gate 517*7c478bd9Sstevel@tonic-gate ptfpcmd(f, s) 518*7c478bd9Sstevel@tonic-gate int f; 519*7c478bd9Sstevel@tonic-gate char *s; 520*7c478bd9Sstevel@tonic-gate { 521*7c478bd9Sstevel@tonic-gate if (ascii) 522*7c478bd9Sstevel@tonic-gate return; 523*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x font %d %s\n", f, s); 524*7c478bd9Sstevel@tonic-gate ptfont(); /* make sure that it gets noticed */ 525*7c478bd9Sstevel@tonic-gate } 526*7c478bd9Sstevel@tonic-gate 527*7c478bd9Sstevel@tonic-gate ptlead() 528*7c478bd9Sstevel@tonic-gate { 529*7c478bd9Sstevel@tonic-gate vpos += lead; 530*7c478bd9Sstevel@tonic-gate if (!ascii) 531*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "V%d\n", vpos); 532*7c478bd9Sstevel@tonic-gate lead = 0; 533*7c478bd9Sstevel@tonic-gate } 534*7c478bd9Sstevel@tonic-gate 535*7c478bd9Sstevel@tonic-gate ptesc() 536*7c478bd9Sstevel@tonic-gate { 537*7c478bd9Sstevel@tonic-gate hpos += esc; 538*7c478bd9Sstevel@tonic-gate if (esc > 0) { 539*7c478bd9Sstevel@tonic-gate oput('h'); 540*7c478bd9Sstevel@tonic-gate if (esc>=10 && esc<100) { 541*7c478bd9Sstevel@tonic-gate oput(esc/10 + '0'); 542*7c478bd9Sstevel@tonic-gate oput(esc%10 + '0'); 543*7c478bd9Sstevel@tonic-gate } else 544*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "%d", esc); 545*7c478bd9Sstevel@tonic-gate } else 546*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "H%d\n", hpos); 547*7c478bd9Sstevel@tonic-gate esc = 0; 548*7c478bd9Sstevel@tonic-gate } 549*7c478bd9Sstevel@tonic-gate 550*7c478bd9Sstevel@tonic-gate newpage(n) /* called at end of each output page (we hope) */ 551*7c478bd9Sstevel@tonic-gate { 552*7c478bd9Sstevel@tonic-gate int i; 553*7c478bd9Sstevel@tonic-gate 554*7c478bd9Sstevel@tonic-gate ptlead(); 555*7c478bd9Sstevel@tonic-gate vpos = 0; 556*7c478bd9Sstevel@tonic-gate if (ascii) 557*7c478bd9Sstevel@tonic-gate return; 558*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "p%d\n", n); /* new page */ 559*7c478bd9Sstevel@tonic-gate for (i = 0; i <= nfonts; i++) 560*7c478bd9Sstevel@tonic-gate if (fontbase[i]->namefont && fontbase[i]->namefont[0]) 561*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x font %d %s\n", i, fontbase[i]->namefont); 562*7c478bd9Sstevel@tonic-gate ptps(); 563*7c478bd9Sstevel@tonic-gate ptfont(); 564*7c478bd9Sstevel@tonic-gate } 565*7c478bd9Sstevel@tonic-gate 566*7c478bd9Sstevel@tonic-gate pttrailer() 567*7c478bd9Sstevel@tonic-gate { 568*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x trailer\n"); 569*7c478bd9Sstevel@tonic-gate } 570*7c478bd9Sstevel@tonic-gate 571*7c478bd9Sstevel@tonic-gate ptstop() 572*7c478bd9Sstevel@tonic-gate { 573*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x stop\n"); 574*7c478bd9Sstevel@tonic-gate } 575*7c478bd9Sstevel@tonic-gate 576*7c478bd9Sstevel@tonic-gate dostop() 577*7c478bd9Sstevel@tonic-gate { 578*7c478bd9Sstevel@tonic-gate if (ascii) 579*7c478bd9Sstevel@tonic-gate return; 580*7c478bd9Sstevel@tonic-gate ptlead(); 581*7c478bd9Sstevel@tonic-gate vpos = 0; 582*7c478bd9Sstevel@tonic-gate /* fdprintf(ptid, "x xxx end of page\n");*/ 583*7c478bd9Sstevel@tonic-gate if (!nofeed) 584*7c478bd9Sstevel@tonic-gate pttrailer(); 585*7c478bd9Sstevel@tonic-gate ptlead(); 586*7c478bd9Sstevel@tonic-gate fdprintf(ptid, "x pause\n"); 587*7c478bd9Sstevel@tonic-gate flusho(); 588*7c478bd9Sstevel@tonic-gate mpts = mfont = 0; 589*7c478bd9Sstevel@tonic-gate ptesc(); 590*7c478bd9Sstevel@tonic-gate esc = po; 591*7c478bd9Sstevel@tonic-gate hpos = vpos = 0; /* probably in wrong place */ 592*7c478bd9Sstevel@tonic-gate } 593