17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988
327c478bd9Sstevel@tonic-gate * The Regents of the University of California
337c478bd9Sstevel@tonic-gate * All Rights Reserved
347c478bd9Sstevel@tonic-gate *
357c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from
367c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its
377c478bd9Sstevel@tonic-gate * contributors.
387c478bd9Sstevel@tonic-gate */
397c478bd9Sstevel@tonic-gate
40*e5190c10Smuffin #pragma ident "%Z%%M% %I% %E% SMI"
41*e5190c10Smuffin
427c478bd9Sstevel@tonic-gate #include "tdef.h"
437c478bd9Sstevel@tonic-gate #include <ctype.h>
447c478bd9Sstevel@tonic-gate #include "ext.h"
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate * troff10.c
477c478bd9Sstevel@tonic-gate *
487c478bd9Sstevel@tonic-gate * typesetter interface
497c478bd9Sstevel@tonic-gate */
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate int vpos = 0; /* absolute vertical position on page */
527c478bd9Sstevel@tonic-gate int hpos = 0; /* ditto horizontal */
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gate short *chtab;
557c478bd9Sstevel@tonic-gate char *chname;
567c478bd9Sstevel@tonic-gate char *fontab[NFONT+1];
577c478bd9Sstevel@tonic-gate char *kerntab[NFONT+1];
587c478bd9Sstevel@tonic-gate char *fitab[NFONT+1];
597c478bd9Sstevel@tonic-gate char *codetab[NFONT+1];
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate int Inch;
627c478bd9Sstevel@tonic-gate int Hor;
637c478bd9Sstevel@tonic-gate int Vert;
647c478bd9Sstevel@tonic-gate int Unitwidth;
657c478bd9Sstevel@tonic-gate int nfonts;
667c478bd9Sstevel@tonic-gate int nsizes;
677c478bd9Sstevel@tonic-gate int nchtab;
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gate /* these characters are used as various signals or values
707c478bd9Sstevel@tonic-gate * in miscellaneous places.
717c478bd9Sstevel@tonic-gate * values are set in specnames in t10.c
727c478bd9Sstevel@tonic-gate */
737c478bd9Sstevel@tonic-gate
747c478bd9Sstevel@tonic-gate int c_hyphen;
757c478bd9Sstevel@tonic-gate int c_emdash;
767c478bd9Sstevel@tonic-gate int c_rule;
777c478bd9Sstevel@tonic-gate int c_minus;
787c478bd9Sstevel@tonic-gate int c_fi;
797c478bd9Sstevel@tonic-gate int c_fl;
807c478bd9Sstevel@tonic-gate int c_ff;
817c478bd9Sstevel@tonic-gate int c_ffi;
827c478bd9Sstevel@tonic-gate int c_ffl;
837c478bd9Sstevel@tonic-gate int c_acute;
847c478bd9Sstevel@tonic-gate int c_grave;
857c478bd9Sstevel@tonic-gate int c_under;
867c478bd9Sstevel@tonic-gate int c_rooten;
877c478bd9Sstevel@tonic-gate int c_boxrule;
887c478bd9Sstevel@tonic-gate int c_lefthand;
897c478bd9Sstevel@tonic-gate int c_dagger;
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gate #include "dev.h"
927c478bd9Sstevel@tonic-gate struct dev dev;
937c478bd9Sstevel@tonic-gate struct Font *fontbase[NFONT+1];
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gate tchar *ptout0();
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate
98*e5190c10Smuffin int
ptinit()997c478bd9Sstevel@tonic-gate ptinit()
1007c478bd9Sstevel@tonic-gate {
1017c478bd9Sstevel@tonic-gate int i, fin, nw;
1027c478bd9Sstevel@tonic-gate char *setbrk(), *filebase, *p;
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gate /* open table for device,
1057c478bd9Sstevel@tonic-gate * read in resolution, size info, font info, etc.
1067c478bd9Sstevel@tonic-gate * and set params
1077c478bd9Sstevel@tonic-gate */
1087c478bd9Sstevel@tonic-gate strcat(termtab, "/dev");
1097c478bd9Sstevel@tonic-gate strcat(termtab, devname);
1107c478bd9Sstevel@tonic-gate strcat(termtab, "/DESC.out"); /* makes "..../devXXX/DESC.out" */
1117c478bd9Sstevel@tonic-gate if ((fin = open(termtab, 0)) < 0) {
1127c478bd9Sstevel@tonic-gate errprint(gettext("can't open tables for %s"), termtab);
1137c478bd9Sstevel@tonic-gate done3(1);
1147c478bd9Sstevel@tonic-gate }
1157c478bd9Sstevel@tonic-gate read(fin, (char *) &dev, sizeof(struct dev ));
1167c478bd9Sstevel@tonic-gate Inch = dev.res;
1177c478bd9Sstevel@tonic-gate Hor = dev.hor;
1187c478bd9Sstevel@tonic-gate Vert = dev.vert;
1197c478bd9Sstevel@tonic-gate Unitwidth = dev.unitwidth;
1207c478bd9Sstevel@tonic-gate nfonts = dev.nfonts;
1217c478bd9Sstevel@tonic-gate nsizes = dev.nsizes;
1227c478bd9Sstevel@tonic-gate nchtab = dev.nchtab;
1237c478bd9Sstevel@tonic-gate if (nchtab >= NCHARS - 128) {
1247c478bd9Sstevel@tonic-gate errprint(gettext("too many special characters in file %s"),
1257c478bd9Sstevel@tonic-gate termtab);
1267c478bd9Sstevel@tonic-gate done3(1);
1277c478bd9Sstevel@tonic-gate }
1287c478bd9Sstevel@tonic-gate filebase = setbrk(dev.filesize + 2*EXTRAFONT); /* enough room for whole file */
1297c478bd9Sstevel@tonic-gate read(fin, filebase, dev.filesize); /* all at once */
1307c478bd9Sstevel@tonic-gate pstab = (short *) filebase;
1317c478bd9Sstevel@tonic-gate chtab = pstab + nsizes + 1;
1327c478bd9Sstevel@tonic-gate chname = (char *) (chtab + dev.nchtab);
1337c478bd9Sstevel@tonic-gate p = chname + dev.lchname;
1347c478bd9Sstevel@tonic-gate for (i = 1; i <= nfonts; i++) {
1357c478bd9Sstevel@tonic-gate fontbase[i] = (struct Font *) p;
1367c478bd9Sstevel@tonic-gate nw = *p & BYTEMASK; /* 1st thing is width count */
1377c478bd9Sstevel@tonic-gate fontlab[i] = PAIR(fontbase[i]->namefont[0], fontbase[i]->namefont[1]);
1387c478bd9Sstevel@tonic-gate /* for now, still 2 char names */
1397c478bd9Sstevel@tonic-gate if (smnt == 0 && fontbase[i]->specfont == 1)
1407c478bd9Sstevel@tonic-gate smnt = i; /* first special font */
1417c478bd9Sstevel@tonic-gate p += sizeof(struct Font); /* that's what's on the beginning */
1427c478bd9Sstevel@tonic-gate fontab[i] = p;
1437c478bd9Sstevel@tonic-gate kerntab[i] = p + nw;
1447c478bd9Sstevel@tonic-gate codetab[i] = p + 2 * nw;
1457c478bd9Sstevel@tonic-gate fitab[i] = p + 3 * nw; /* skip width, kern, code */
1467c478bd9Sstevel@tonic-gate p += 3 * nw + dev.nchtab + 128 - 32;
1477c478bd9Sstevel@tonic-gate }
1487c478bd9Sstevel@tonic-gate fontbase[0] = (struct Font *) p; /* the last shall be first */
1497c478bd9Sstevel@tonic-gate fontbase[0]->nwfont = EXTRAFONT - dev.nchtab - (128-32) - sizeof (struct Font);
1507c478bd9Sstevel@tonic-gate fontab[0] = p + sizeof (struct Font);
1517c478bd9Sstevel@tonic-gate close(fin);
1527c478bd9Sstevel@tonic-gate /* there are a lot of things that used to be constant
1537c478bd9Sstevel@tonic-gate * that now require code to be executed.
1547c478bd9Sstevel@tonic-gate */
1557c478bd9Sstevel@tonic-gate sps = SPS;
1567c478bd9Sstevel@tonic-gate ics = ICS;
1577c478bd9Sstevel@tonic-gate for (i = 0; i < 16; i++)
1587c478bd9Sstevel@tonic-gate tabtab[i] = DTAB * (i + 1);
1597c478bd9Sstevel@tonic-gate pl = 11 * INCH;
1607c478bd9Sstevel@tonic-gate po = PO;
1617c478bd9Sstevel@tonic-gate spacesz = SS;
1627c478bd9Sstevel@tonic-gate lss = lss1 = VS;
1637c478bd9Sstevel@tonic-gate ll = ll1 = lt = lt1 = LL;
1647c478bd9Sstevel@tonic-gate specnames(); /* install names like "hyphen", etc. */
1657c478bd9Sstevel@tonic-gate if (ascii)
166*e5190c10Smuffin return (0);
1677c478bd9Sstevel@tonic-gate fdprintf(ptid, "x T %s\n", devname);
1687c478bd9Sstevel@tonic-gate fdprintf(ptid, "x res %d %d %d\n", Inch, Hor, Vert);
1697c478bd9Sstevel@tonic-gate fdprintf(ptid, "x init\n"); /* do initialization for particular device */
1707c478bd9Sstevel@tonic-gate /*
1717c478bd9Sstevel@tonic-gate for (i = 1; i <= nfonts; i++)
1727c478bd9Sstevel@tonic-gate fdprintf(ptid, "x font %d %s\n", i, fontbase[i]->namefont);
1737c478bd9Sstevel@tonic-gate fdprintf(ptid, "x xxx fonts=%d sizes=%d unit=%d\n", nfonts, nsizes, Unitwidth);
1747c478bd9Sstevel@tonic-gate fdprintf(ptid, "x xxx nchtab=%d lchname=%d nfitab=%d\n",
1757c478bd9Sstevel@tonic-gate dev.nchtab, dev.lchname, dev.nchtab+128-32);
1767c478bd9Sstevel@tonic-gate fdprintf(ptid, "x xxx sizes:\nx xxx ");
1777c478bd9Sstevel@tonic-gate for (i = 0; i < nsizes; i++)
1787c478bd9Sstevel@tonic-gate fdprintf(ptid, " %d", pstab[i]);
1797c478bd9Sstevel@tonic-gate fdprintf(ptid, "\nx xxx chars:\nx xxx ");
1807c478bd9Sstevel@tonic-gate for (i = 0; i < dev.nchtab; i++)
1817c478bd9Sstevel@tonic-gate fdprintf(ptid, " %s", &chname[chtab[i]]);
1827c478bd9Sstevel@tonic-gate fdprintf(ptid, "\nx xxx\n");
1837c478bd9Sstevel@tonic-gate */
184*e5190c10Smuffin
185*e5190c10Smuffin return (0);
1867c478bd9Sstevel@tonic-gate }
1877c478bd9Sstevel@tonic-gate
188*e5190c10Smuffin int
specnames()1897c478bd9Sstevel@tonic-gate specnames()
1907c478bd9Sstevel@tonic-gate {
1917c478bd9Sstevel@tonic-gate static struct {
1927c478bd9Sstevel@tonic-gate int *n;
1937c478bd9Sstevel@tonic-gate char *v;
1947c478bd9Sstevel@tonic-gate } spnames[] = {
1957c478bd9Sstevel@tonic-gate &c_hyphen, "hy",
1967c478bd9Sstevel@tonic-gate &c_emdash, "em",
1977c478bd9Sstevel@tonic-gate &c_rule, "ru",
1987c478bd9Sstevel@tonic-gate &c_minus, "\\-",
1997c478bd9Sstevel@tonic-gate &c_fi, "fi",
2007c478bd9Sstevel@tonic-gate &c_fl, "fl",
2017c478bd9Sstevel@tonic-gate &c_ff, "ff",
2027c478bd9Sstevel@tonic-gate &c_ffi, "Fi",
2037c478bd9Sstevel@tonic-gate &c_ffl, "Fl",
2047c478bd9Sstevel@tonic-gate &c_acute, "aa",
2057c478bd9Sstevel@tonic-gate &c_grave, "ga",
2067c478bd9Sstevel@tonic-gate &c_under, "ul",
2077c478bd9Sstevel@tonic-gate &c_rooten, "rn",
2087c478bd9Sstevel@tonic-gate &c_boxrule, "br",
2097c478bd9Sstevel@tonic-gate &c_lefthand, "lh",
2107c478bd9Sstevel@tonic-gate &c_dagger, "dg",
2117c478bd9Sstevel@tonic-gate 0, 0
2127c478bd9Sstevel@tonic-gate };
2137c478bd9Sstevel@tonic-gate int i;
2147c478bd9Sstevel@tonic-gate
2157c478bd9Sstevel@tonic-gate for (i = 0; spnames[i].n; i++)
2167c478bd9Sstevel@tonic-gate *spnames[i].n = findch(spnames[i].v);
217*e5190c10Smuffin
218*e5190c10Smuffin return (0);
2197c478bd9Sstevel@tonic-gate }
2207c478bd9Sstevel@tonic-gate
221*e5190c10Smuffin int
findch(s)2227c478bd9Sstevel@tonic-gate findch(s) /* find char s in chname */
223*e5190c10Smuffin char *s;
2247c478bd9Sstevel@tonic-gate {
225*e5190c10Smuffin int i;
2267c478bd9Sstevel@tonic-gate
2277c478bd9Sstevel@tonic-gate for (i = 0; i < nchtab; i++)
2287c478bd9Sstevel@tonic-gate if (strcmp(s, &chname[chtab[i]]) == 0)
2297c478bd9Sstevel@tonic-gate return(i + 128);
2307c478bd9Sstevel@tonic-gate return(0);
2317c478bd9Sstevel@tonic-gate }
2327c478bd9Sstevel@tonic-gate
233*e5190c10Smuffin int
ptout(i)2347c478bd9Sstevel@tonic-gate ptout(i)
235*e5190c10Smuffin tchar i;
2367c478bd9Sstevel@tonic-gate {
237*e5190c10Smuffin int dv;
238*e5190c10Smuffin tchar *k;
2397c478bd9Sstevel@tonic-gate int temp, a, b;
2407c478bd9Sstevel@tonic-gate
2417c478bd9Sstevel@tonic-gate if (cbits(i) != '\n') {
2427c478bd9Sstevel@tonic-gate *olinep++ = i;
243*e5190c10Smuffin return (0);
2447c478bd9Sstevel@tonic-gate }
2457c478bd9Sstevel@tonic-gate if (olinep == oline) {
2467c478bd9Sstevel@tonic-gate lead += lss;
247*e5190c10Smuffin return (0);
2487c478bd9Sstevel@tonic-gate }
2497c478bd9Sstevel@tonic-gate
2507c478bd9Sstevel@tonic-gate hpos = po; /* ??? */
2517c478bd9Sstevel@tonic-gate esc = 0; /* ??? */
2527c478bd9Sstevel@tonic-gate ptesc(); /* the problem is to get back to the left end of the line */
2537c478bd9Sstevel@tonic-gate dv = 0;
2547c478bd9Sstevel@tonic-gate for (k = oline; k < olinep; k++) {
2557c478bd9Sstevel@tonic-gate if (ismot(*k) && isvmot(*k)) {
2567c478bd9Sstevel@tonic-gate temp = absmot(*k);
2577c478bd9Sstevel@tonic-gate if (isnmot(*k))
2587c478bd9Sstevel@tonic-gate temp = -temp;
2597c478bd9Sstevel@tonic-gate dv += temp;
2607c478bd9Sstevel@tonic-gate }
2617c478bd9Sstevel@tonic-gate }
2627c478bd9Sstevel@tonic-gate if (dv) {
2637c478bd9Sstevel@tonic-gate vflag++;
2647c478bd9Sstevel@tonic-gate *olinep++ = makem(-dv);
2657c478bd9Sstevel@tonic-gate vflag = 0;
2667c478bd9Sstevel@tonic-gate }
2677c478bd9Sstevel@tonic-gate
2687c478bd9Sstevel@tonic-gate b = dip->blss + lss;
2697c478bd9Sstevel@tonic-gate lead += dip->blss + lss;
2707c478bd9Sstevel@tonic-gate dip->blss = 0;
2717c478bd9Sstevel@tonic-gate for (k = oline; k < olinep; )
2727c478bd9Sstevel@tonic-gate k = ptout0(k); /* now passing a pointer! */
2737c478bd9Sstevel@tonic-gate olinep = oline;
2747c478bd9Sstevel@tonic-gate lead += dip->alss;
2757c478bd9Sstevel@tonic-gate a = dip->alss;
2767c478bd9Sstevel@tonic-gate dip->alss = 0;
2777c478bd9Sstevel@tonic-gate /*
2787c478bd9Sstevel@tonic-gate fdprintf(ptid, "x xxx end of line: hpos=%d, vpos=%d\n", hpos, vpos);
2797c478bd9Sstevel@tonic-gate */
2807c478bd9Sstevel@tonic-gate fdprintf(ptid, "n%d %d\n", b, a); /* be nice to chuck */
281*e5190c10Smuffin
282*e5190c10Smuffin return (0);
2837c478bd9Sstevel@tonic-gate }
2847c478bd9Sstevel@tonic-gate
2857c478bd9Sstevel@tonic-gate tchar *
ptout0(pi)2867c478bd9Sstevel@tonic-gate ptout0(pi)
2877c478bd9Sstevel@tonic-gate tchar *pi;
2887c478bd9Sstevel@tonic-gate {
289*e5190c10Smuffin short j, k, w;
2907c478bd9Sstevel@tonic-gate short z, dx, dy, dx2, dy2, n;
291*e5190c10Smuffin tchar i;
2927c478bd9Sstevel@tonic-gate int outsize; /* size of object being printed */
2937c478bd9Sstevel@tonic-gate
2947c478bd9Sstevel@tonic-gate outsize = 1; /* default */
2957c478bd9Sstevel@tonic-gate i = *pi;
2967c478bd9Sstevel@tonic-gate k = cbits(i);
2977c478bd9Sstevel@tonic-gate if (ismot(i)) {
2987c478bd9Sstevel@tonic-gate j = absmot(i);
2997c478bd9Sstevel@tonic-gate if (isnmot(i))
3007c478bd9Sstevel@tonic-gate j = -j;
3017c478bd9Sstevel@tonic-gate if (isvmot(i))
3027c478bd9Sstevel@tonic-gate lead += j;
3037c478bd9Sstevel@tonic-gate else
3047c478bd9Sstevel@tonic-gate esc += j;
3057c478bd9Sstevel@tonic-gate return(pi+outsize);
3067c478bd9Sstevel@tonic-gate }
3077c478bd9Sstevel@tonic-gate if (k == XON) {
3087c478bd9Sstevel@tonic-gate if (xfont != mfont)
3097c478bd9Sstevel@tonic-gate ptfont();
3107c478bd9Sstevel@tonic-gate if (xpts != mpts)
3117c478bd9Sstevel@tonic-gate ptps();
3127c478bd9Sstevel@tonic-gate if (lead)
3137c478bd9Sstevel@tonic-gate ptlead();
3147c478bd9Sstevel@tonic-gate fdprintf(ptid, "x X ");
3157c478bd9Sstevel@tonic-gate /*
3167c478bd9Sstevel@tonic-gate * not guaranteed of finding a XOFF if a word overflow
3177c478bd9Sstevel@tonic-gate * error occured, so also bound this loop by olinep
3187c478bd9Sstevel@tonic-gate */
3197c478bd9Sstevel@tonic-gate pi++;
3207c478bd9Sstevel@tonic-gate while( cbits(*pi) != XOFF && pi < olinep )
3217c478bd9Sstevel@tonic-gate outascii(*pi++);
3227c478bd9Sstevel@tonic-gate oput('\n');
3237c478bd9Sstevel@tonic-gate if ( cbits(*pi) == XOFF )
3247c478bd9Sstevel@tonic-gate pi++;
3257c478bd9Sstevel@tonic-gate return pi;
3267c478bd9Sstevel@tonic-gate }
3277c478bd9Sstevel@tonic-gate ;
3287c478bd9Sstevel@tonic-gate if (k == CHARHT) {
3297c478bd9Sstevel@tonic-gate if (xpts != mpts)
3307c478bd9Sstevel@tonic-gate ptps();
3317c478bd9Sstevel@tonic-gate fdprintf(ptid, "x H %d\n", sbits(i));
3327c478bd9Sstevel@tonic-gate return(pi+outsize);
3337c478bd9Sstevel@tonic-gate }
3347c478bd9Sstevel@tonic-gate if (k == SLANT) {
3357c478bd9Sstevel@tonic-gate fdprintf(ptid, "x S %d\n", sfbits(i)-180);
3367c478bd9Sstevel@tonic-gate return(pi+outsize);
3377c478bd9Sstevel@tonic-gate }
3387c478bd9Sstevel@tonic-gate if (k == WORDSP) {
3397c478bd9Sstevel@tonic-gate oput('w');
3407c478bd9Sstevel@tonic-gate return(pi+outsize);
3417c478bd9Sstevel@tonic-gate }
3427c478bd9Sstevel@tonic-gate if (k == FONTPOS) {
3437c478bd9Sstevel@tonic-gate char temp[3];
3447c478bd9Sstevel@tonic-gate n = i >> 16;
3457c478bd9Sstevel@tonic-gate temp[0] = n & BYTEMASK;
3467c478bd9Sstevel@tonic-gate temp[1] = n >> BYTE;
3477c478bd9Sstevel@tonic-gate temp[2] = 0;
3487c478bd9Sstevel@tonic-gate ptfpcmd(0, temp);
3497c478bd9Sstevel@tonic-gate return(pi+outsize);
3507c478bd9Sstevel@tonic-gate }
3517c478bd9Sstevel@tonic-gate if (sfbits(i) == oldbits) {
3527c478bd9Sstevel@tonic-gate xfont = pfont;
3537c478bd9Sstevel@tonic-gate xpts = ppts;
3547c478bd9Sstevel@tonic-gate } else
3557c478bd9Sstevel@tonic-gate xbits(i, 2);
3567c478bd9Sstevel@tonic-gate if (k < 040 && k != DRAWFCN)
3577c478bd9Sstevel@tonic-gate return(pi+outsize);
3587c478bd9Sstevel@tonic-gate if (k >= 32) {
3597c478bd9Sstevel@tonic-gate if (widcache[k-32].fontpts == (xfont<<8) + xpts && !setwdf) {
3607c478bd9Sstevel@tonic-gate w = widcache[k-32].width;
3617c478bd9Sstevel@tonic-gate bd = 0;
3627c478bd9Sstevel@tonic-gate cs = 0;
3637c478bd9Sstevel@tonic-gate } else
3647c478bd9Sstevel@tonic-gate w = getcw(k-32);
3657c478bd9Sstevel@tonic-gate }
3667c478bd9Sstevel@tonic-gate j = z = 0;
3677c478bd9Sstevel@tonic-gate if (k != DRAWFCN) {
3687c478bd9Sstevel@tonic-gate if (cs) {
3697c478bd9Sstevel@tonic-gate if (bd)
3707c478bd9Sstevel@tonic-gate w += (bd - 1) * HOR;
3717c478bd9Sstevel@tonic-gate j = (cs - w) / 2;
3727c478bd9Sstevel@tonic-gate w = cs - j;
3737c478bd9Sstevel@tonic-gate if (bd)
3747c478bd9Sstevel@tonic-gate w -= (bd - 1) * HOR;
3757c478bd9Sstevel@tonic-gate }
3767c478bd9Sstevel@tonic-gate if (iszbit(i)) {
3777c478bd9Sstevel@tonic-gate if (cs)
3787c478bd9Sstevel@tonic-gate w = -j;
3797c478bd9Sstevel@tonic-gate else
3807c478bd9Sstevel@tonic-gate w = 0;
3817c478bd9Sstevel@tonic-gate z = 1;
3827c478bd9Sstevel@tonic-gate }
3837c478bd9Sstevel@tonic-gate }
3847c478bd9Sstevel@tonic-gate esc += j;
3857c478bd9Sstevel@tonic-gate if (xfont != mfont)
3867c478bd9Sstevel@tonic-gate ptfont();
3877c478bd9Sstevel@tonic-gate if (xpts != mpts)
3887c478bd9Sstevel@tonic-gate ptps();
3897c478bd9Sstevel@tonic-gate if (lead)
3907c478bd9Sstevel@tonic-gate ptlead();
3917c478bd9Sstevel@tonic-gate /* put out the real character here */
3927c478bd9Sstevel@tonic-gate if (k == DRAWFCN) {
3937c478bd9Sstevel@tonic-gate if (esc)
3947c478bd9Sstevel@tonic-gate ptesc();
3957c478bd9Sstevel@tonic-gate dx = absmot(pi[3]);
3967c478bd9Sstevel@tonic-gate if (isnmot(pi[3]))
3977c478bd9Sstevel@tonic-gate dx = -dx;
3987c478bd9Sstevel@tonic-gate dy = absmot(pi[4]);
3997c478bd9Sstevel@tonic-gate if (isnmot(pi[4]))
4007c478bd9Sstevel@tonic-gate dy = -dy;
4017c478bd9Sstevel@tonic-gate switch (cbits(pi[1])) {
4027c478bd9Sstevel@tonic-gate case DRAWCIRCLE: /* circle */
4037c478bd9Sstevel@tonic-gate fdprintf(ptid, "D%c %d\n", DRAWCIRCLE, dx); /* dx is diameter */
4047c478bd9Sstevel@tonic-gate w = 0;
4057c478bd9Sstevel@tonic-gate hpos += dx;
4067c478bd9Sstevel@tonic-gate break;
4077c478bd9Sstevel@tonic-gate case DRAWELLIPSE:
4087c478bd9Sstevel@tonic-gate fdprintf(ptid, "D%c %d %d\n", DRAWELLIPSE, dx, dy);
4097c478bd9Sstevel@tonic-gate w = 0;
4107c478bd9Sstevel@tonic-gate hpos += dx;
4117c478bd9Sstevel@tonic-gate break;
4127c478bd9Sstevel@tonic-gate case DRAWLINE: /* line */
4137c478bd9Sstevel@tonic-gate k = cbits(pi[2]);
4147c478bd9Sstevel@tonic-gate fdprintf(ptid, "D%c %d %d ", DRAWLINE, dx, dy);
4157c478bd9Sstevel@tonic-gate if (k < 128)
4167c478bd9Sstevel@tonic-gate fdprintf(ptid, "%c\n", k);
4177c478bd9Sstevel@tonic-gate else
4187c478bd9Sstevel@tonic-gate fdprintf(ptid, "%s\n", &chname[chtab[k - 128]]);
4197c478bd9Sstevel@tonic-gate w = 0;
4207c478bd9Sstevel@tonic-gate hpos += dx;
4217c478bd9Sstevel@tonic-gate vpos += dy;
4227c478bd9Sstevel@tonic-gate break;
4237c478bd9Sstevel@tonic-gate case DRAWARC: /* arc */
4247c478bd9Sstevel@tonic-gate dx2 = absmot(pi[5]);
4257c478bd9Sstevel@tonic-gate if (isnmot(pi[5]))
4267c478bd9Sstevel@tonic-gate dx2 = -dx2;
4277c478bd9Sstevel@tonic-gate dy2 = absmot(pi[6]);
4287c478bd9Sstevel@tonic-gate if (isnmot(pi[6]))
4297c478bd9Sstevel@tonic-gate dy2 = -dy2;
4307c478bd9Sstevel@tonic-gate fdprintf(ptid, "D%c %d %d %d %d\n", DRAWARC,
4317c478bd9Sstevel@tonic-gate dx, dy, dx2, dy2);
4327c478bd9Sstevel@tonic-gate w = 0;
4337c478bd9Sstevel@tonic-gate hpos += dx + dx2;
4347c478bd9Sstevel@tonic-gate vpos += dy + dy2;
4357c478bd9Sstevel@tonic-gate break;
4367c478bd9Sstevel@tonic-gate case DRAWSPLINE: /* spline */
4377c478bd9Sstevel@tonic-gate default: /* something else; copy it like spline */
4387c478bd9Sstevel@tonic-gate fdprintf(ptid, "D%c %d %d", cbits(pi[1]), dx, dy);
4397c478bd9Sstevel@tonic-gate w = 0;
4407c478bd9Sstevel@tonic-gate hpos += dx;
4417c478bd9Sstevel@tonic-gate vpos += dy;
4427c478bd9Sstevel@tonic-gate if (cbits(pi[3]) == DRAWFCN || cbits(pi[4]) == DRAWFCN) {
4437c478bd9Sstevel@tonic-gate /* it was somehow defective */
4447c478bd9Sstevel@tonic-gate fdprintf(ptid, "\n");
4457c478bd9Sstevel@tonic-gate break;
4467c478bd9Sstevel@tonic-gate }
4477c478bd9Sstevel@tonic-gate for (n = 5; cbits(pi[n]) != DRAWFCN; n += 2) {
4487c478bd9Sstevel@tonic-gate dx = absmot(pi[n]);
4497c478bd9Sstevel@tonic-gate if (isnmot(pi[n]))
4507c478bd9Sstevel@tonic-gate dx = -dx;
4517c478bd9Sstevel@tonic-gate dy = absmot(pi[n+1]);
4527c478bd9Sstevel@tonic-gate if (isnmot(pi[n+1]))
4537c478bd9Sstevel@tonic-gate dy = -dy;
4547c478bd9Sstevel@tonic-gate fdprintf(ptid, " %d %d", dx, dy);
4557c478bd9Sstevel@tonic-gate hpos += dx;
4567c478bd9Sstevel@tonic-gate vpos += dy;
4577c478bd9Sstevel@tonic-gate }
4587c478bd9Sstevel@tonic-gate fdprintf(ptid, "\n");
4597c478bd9Sstevel@tonic-gate break;
4607c478bd9Sstevel@tonic-gate }
4617c478bd9Sstevel@tonic-gate for (n = 3; cbits(pi[n]) != DRAWFCN; n++)
4627c478bd9Sstevel@tonic-gate ;
4637c478bd9Sstevel@tonic-gate outsize = n + 1;
4647c478bd9Sstevel@tonic-gate } else if (k < 128) {
4657c478bd9Sstevel@tonic-gate /* try to go faster and compress output */
4667c478bd9Sstevel@tonic-gate /* by printing nnc for small positive motion followed by c */
4677c478bd9Sstevel@tonic-gate /* kludgery; have to make sure set all the vars too */
4687c478bd9Sstevel@tonic-gate if (esc > 0 && esc < 100) {
4697c478bd9Sstevel@tonic-gate oput(esc / 10 + '0');
4707c478bd9Sstevel@tonic-gate oput(esc % 10 + '0');
4717c478bd9Sstevel@tonic-gate oput(k);
4727c478bd9Sstevel@tonic-gate hpos += esc;
4737c478bd9Sstevel@tonic-gate esc = 0;
4747c478bd9Sstevel@tonic-gate } else {
4757c478bd9Sstevel@tonic-gate if (esc)
4767c478bd9Sstevel@tonic-gate ptesc();
4777c478bd9Sstevel@tonic-gate oput('c');
4787c478bd9Sstevel@tonic-gate oput(k);
4797c478bd9Sstevel@tonic-gate oput('\n');
4807c478bd9Sstevel@tonic-gate }
4817c478bd9Sstevel@tonic-gate } else {
4827c478bd9Sstevel@tonic-gate if (esc)
4837c478bd9Sstevel@tonic-gate ptesc();
4847c478bd9Sstevel@tonic-gate if (k >= nchtab + 128)
4857c478bd9Sstevel@tonic-gate fdprintf(ptid, "N%d\n", k - (nchtab+128));
4867c478bd9Sstevel@tonic-gate else
4877c478bd9Sstevel@tonic-gate fdprintf(ptid, "C%s\n", &chname[chtab[k - 128]]);
4887c478bd9Sstevel@tonic-gate }
4897c478bd9Sstevel@tonic-gate if (bd) {
4907c478bd9Sstevel@tonic-gate bd -= HOR;
4917c478bd9Sstevel@tonic-gate if (esc += bd)
4927c478bd9Sstevel@tonic-gate ptesc();
4937c478bd9Sstevel@tonic-gate if (k < 128) {
4947c478bd9Sstevel@tonic-gate fdprintf(ptid, "c%c\n", k);
4957c478bd9Sstevel@tonic-gate } else if (k >= nchtab + 128) {
4967c478bd9Sstevel@tonic-gate fdprintf(ptid, "N%d\n", k - (nchtab+128));
4977c478bd9Sstevel@tonic-gate } else
4987c478bd9Sstevel@tonic-gate fdprintf(ptid, "C%s\n", &chname[chtab[k - 128]]);
4997c478bd9Sstevel@tonic-gate if (z)
5007c478bd9Sstevel@tonic-gate esc -= bd;
5017c478bd9Sstevel@tonic-gate }
5027c478bd9Sstevel@tonic-gate esc += w;
5037c478bd9Sstevel@tonic-gate return(pi+outsize);
5047c478bd9Sstevel@tonic-gate }
5057c478bd9Sstevel@tonic-gate
506*e5190c10Smuffin int
ptps()5077c478bd9Sstevel@tonic-gate ptps()
5087c478bd9Sstevel@tonic-gate {
509*e5190c10Smuffin int i, j, k;
5107c478bd9Sstevel@tonic-gate
5117c478bd9Sstevel@tonic-gate i = xpts;
5127c478bd9Sstevel@tonic-gate for (j = 0; i > (k = pstab[j]); j++)
5137c478bd9Sstevel@tonic-gate if (!k) {
5147c478bd9Sstevel@tonic-gate k = pstab[--j];
5157c478bd9Sstevel@tonic-gate break;
5167c478bd9Sstevel@tonic-gate }
5177c478bd9Sstevel@tonic-gate fdprintf(ptid, "s%d\n", k); /* really should put out string rep of size */
5187c478bd9Sstevel@tonic-gate mpts = i;
519*e5190c10Smuffin
520*e5190c10Smuffin return (0);
5217c478bd9Sstevel@tonic-gate }
5227c478bd9Sstevel@tonic-gate
523*e5190c10Smuffin int
ptfont()5247c478bd9Sstevel@tonic-gate ptfont()
5257c478bd9Sstevel@tonic-gate {
5267c478bd9Sstevel@tonic-gate mfont = xfont;
5277c478bd9Sstevel@tonic-gate fdprintf(ptid, "f%d\n", xfont);
528*e5190c10Smuffin
529*e5190c10Smuffin return (0);
5307c478bd9Sstevel@tonic-gate }
5317c478bd9Sstevel@tonic-gate
532*e5190c10Smuffin int
ptfpcmd(f,s)5337c478bd9Sstevel@tonic-gate ptfpcmd(f, s)
5347c478bd9Sstevel@tonic-gate int f;
5357c478bd9Sstevel@tonic-gate char *s;
5367c478bd9Sstevel@tonic-gate {
5377c478bd9Sstevel@tonic-gate if (ascii)
538*e5190c10Smuffin return (0);
5397c478bd9Sstevel@tonic-gate fdprintf(ptid, "x font %d %s\n", f, s);
5407c478bd9Sstevel@tonic-gate ptfont(); /* make sure that it gets noticed */
541*e5190c10Smuffin
542*e5190c10Smuffin return (0);
5437c478bd9Sstevel@tonic-gate }
5447c478bd9Sstevel@tonic-gate
545*e5190c10Smuffin int
ptlead()5467c478bd9Sstevel@tonic-gate ptlead()
5477c478bd9Sstevel@tonic-gate {
5487c478bd9Sstevel@tonic-gate vpos += lead;
5497c478bd9Sstevel@tonic-gate if (!ascii)
5507c478bd9Sstevel@tonic-gate fdprintf(ptid, "V%d\n", vpos);
5517c478bd9Sstevel@tonic-gate lead = 0;
552*e5190c10Smuffin
553*e5190c10Smuffin return (0);
5547c478bd9Sstevel@tonic-gate }
5557c478bd9Sstevel@tonic-gate
556*e5190c10Smuffin
557*e5190c10Smuffin int
ptesc()5587c478bd9Sstevel@tonic-gate ptesc()
5597c478bd9Sstevel@tonic-gate {
5607c478bd9Sstevel@tonic-gate hpos += esc;
5617c478bd9Sstevel@tonic-gate if (esc > 0) {
5627c478bd9Sstevel@tonic-gate oput('h');
5637c478bd9Sstevel@tonic-gate if (esc>=10 && esc<100) {
5647c478bd9Sstevel@tonic-gate oput(esc/10 + '0');
5657c478bd9Sstevel@tonic-gate oput(esc%10 + '0');
5667c478bd9Sstevel@tonic-gate } else
5677c478bd9Sstevel@tonic-gate fdprintf(ptid, "%d", esc);
5687c478bd9Sstevel@tonic-gate } else
5697c478bd9Sstevel@tonic-gate fdprintf(ptid, "H%d\n", hpos);
5707c478bd9Sstevel@tonic-gate esc = 0;
571*e5190c10Smuffin
572*e5190c10Smuffin return (0);
5737c478bd9Sstevel@tonic-gate }
5747c478bd9Sstevel@tonic-gate
575*e5190c10Smuffin
576*e5190c10Smuffin int
newpage(n)5777c478bd9Sstevel@tonic-gate newpage(n) /* called at end of each output page (we hope) */
5787c478bd9Sstevel@tonic-gate {
5797c478bd9Sstevel@tonic-gate int i;
5807c478bd9Sstevel@tonic-gate
5817c478bd9Sstevel@tonic-gate ptlead();
5827c478bd9Sstevel@tonic-gate vpos = 0;
5837c478bd9Sstevel@tonic-gate if (ascii)
584*e5190c10Smuffin return (0);
5857c478bd9Sstevel@tonic-gate fdprintf(ptid, "p%d\n", n); /* new page */
5867c478bd9Sstevel@tonic-gate for (i = 0; i <= nfonts; i++)
5877c478bd9Sstevel@tonic-gate if (fontbase[i]->namefont && fontbase[i]->namefont[0])
5887c478bd9Sstevel@tonic-gate fdprintf(ptid, "x font %d %s\n", i, fontbase[i]->namefont);
5897c478bd9Sstevel@tonic-gate ptps();
5907c478bd9Sstevel@tonic-gate ptfont();
591*e5190c10Smuffin
592*e5190c10Smuffin return (0);
5937c478bd9Sstevel@tonic-gate }
5947c478bd9Sstevel@tonic-gate
595*e5190c10Smuffin int
pttrailer()5967c478bd9Sstevel@tonic-gate pttrailer()
5977c478bd9Sstevel@tonic-gate {
5987c478bd9Sstevel@tonic-gate fdprintf(ptid, "x trailer\n");
599*e5190c10Smuffin
600*e5190c10Smuffin return (0);
6017c478bd9Sstevel@tonic-gate }
6027c478bd9Sstevel@tonic-gate
603*e5190c10Smuffin int
ptstop()6047c478bd9Sstevel@tonic-gate ptstop()
6057c478bd9Sstevel@tonic-gate {
6067c478bd9Sstevel@tonic-gate fdprintf(ptid, "x stop\n");
607*e5190c10Smuffin
608*e5190c10Smuffin return (0);
6097c478bd9Sstevel@tonic-gate }
6107c478bd9Sstevel@tonic-gate
611*e5190c10Smuffin int
dostop()6127c478bd9Sstevel@tonic-gate dostop()
6137c478bd9Sstevel@tonic-gate {
6147c478bd9Sstevel@tonic-gate if (ascii)
615*e5190c10Smuffin return (0);
6167c478bd9Sstevel@tonic-gate ptlead();
6177c478bd9Sstevel@tonic-gate vpos = 0;
6187c478bd9Sstevel@tonic-gate /* fdprintf(ptid, "x xxx end of page\n");*/
6197c478bd9Sstevel@tonic-gate if (!nofeed)
6207c478bd9Sstevel@tonic-gate pttrailer();
6217c478bd9Sstevel@tonic-gate ptlead();
6227c478bd9Sstevel@tonic-gate fdprintf(ptid, "x pause\n");
6237c478bd9Sstevel@tonic-gate flusho();
6247c478bd9Sstevel@tonic-gate mpts = mfont = 0;
6257c478bd9Sstevel@tonic-gate ptesc();
6267c478bd9Sstevel@tonic-gate esc = po;
6277c478bd9Sstevel@tonic-gate hpos = vpos = 0; /* probably in wrong place */
628*e5190c10Smuffin
629*e5190c10Smuffin return (0);
6307c478bd9Sstevel@tonic-gate }
631