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
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.
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]
23 * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #pragma ident "%Z%%M% %I% %E% SMI"
48 * typesetter interface
51 int vpos
= 0; /* absolute vertical position on page */
52 int hpos
= 0; /* ditto horizontal */
56 char *fontab
[NFONT
+1];
57 char *kerntab
[NFONT
+1];
59 char *codetab
[NFONT
+1];
69 /* these characters are used as various signals or values
70 * in miscellaneous places.
71 * values are set in specnames in t10.c
93 struct Font
*fontbase
[NFONT
+1];
102 char *setbrk(), *filebase
, *p
;
104 /* open table for device,
105 * read in resolution, size info, font info, etc.
108 strcat(termtab
, "/dev");
109 strcat(termtab
, devname
);
110 strcat(termtab
, "/DESC.out"); /* makes "..../devXXX/DESC.out" */
111 if ((fin
= open(termtab
, 0)) < 0) {
112 errprint(gettext("can't open tables for %s"), termtab
);
115 read(fin
, (char *) &dev
, sizeof(struct dev
));
119 Unitwidth
= dev
.unitwidth
;
123 if (nchtab
>= NCHARS
- 128) {
124 errprint(gettext("too many special characters in file %s"),
128 filebase
= setbrk(dev
.filesize
+ 2*EXTRAFONT
); /* enough room for whole file */
129 read(fin
, filebase
, dev
.filesize
); /* all at once */
130 pstab
= (short *) filebase
;
131 chtab
= pstab
+ nsizes
+ 1;
132 chname
= (char *) (chtab
+ dev
.nchtab
);
133 p
= chname
+ dev
.lchname
;
134 for (i
= 1; i
<= nfonts
; i
++) {
135 fontbase
[i
] = (struct Font
*) p
;
136 nw
= *p
& BYTEMASK
; /* 1st thing is width count */
137 fontlab
[i
] = PAIR(fontbase
[i
]->namefont
[0], fontbase
[i
]->namefont
[1]);
138 /* for now, still 2 char names */
139 if (smnt
== 0 && fontbase
[i
]->specfont
== 1)
140 smnt
= i
; /* first special font */
141 p
+= sizeof(struct Font
); /* that's what's on the beginning */
144 codetab
[i
] = p
+ 2 * nw
;
145 fitab
[i
] = p
+ 3 * nw
; /* skip width, kern, code */
146 p
+= 3 * nw
+ dev
.nchtab
+ 128 - 32;
148 fontbase
[0] = (struct Font
*) p
; /* the last shall be first */
149 fontbase
[0]->nwfont
= EXTRAFONT
- dev
.nchtab
- (128-32) - sizeof (struct Font
);
150 fontab
[0] = p
+ sizeof (struct Font
);
152 /* there are a lot of things that used to be constant
153 * that now require code to be executed.
157 for (i
= 0; i
< 16; i
++)
158 tabtab
[i
] = DTAB
* (i
+ 1);
163 ll
= ll1
= lt
= lt1
= LL
;
164 specnames(); /* install names like "hyphen", etc. */
167 fdprintf(ptid
, "x T %s\n", devname
);
168 fdprintf(ptid
, "x res %d %d %d\n", Inch
, Hor
, Vert
);
169 fdprintf(ptid
, "x init\n"); /* do initialization for particular device */
171 for (i = 1; i <= nfonts; i++)
172 fdprintf(ptid, "x font %d %s\n", i, fontbase[i]->namefont);
173 fdprintf(ptid, "x xxx fonts=%d sizes=%d unit=%d\n", nfonts, nsizes, Unitwidth);
174 fdprintf(ptid, "x xxx nchtab=%d lchname=%d nfitab=%d\n",
175 dev.nchtab, dev.lchname, dev.nchtab+128-32);
176 fdprintf(ptid, "x xxx sizes:\nx xxx ");
177 for (i = 0; i < nsizes; i++)
178 fdprintf(ptid, " %d", pstab[i]);
179 fdprintf(ptid, "\nx xxx chars:\nx xxx ");
180 for (i = 0; i < dev.nchtab; i++)
181 fdprintf(ptid, " %s", &chname[chtab[i]]);
182 fdprintf(ptid, "\nx xxx\n");
215 for (i
= 0; spnames
[i
].n
; i
++)
216 *spnames
[i
].n
= findch(spnames
[i
].v
);
222 findch(s
) /* find char s in chname */
227 for (i
= 0; i
< nchtab
; i
++)
228 if (strcmp(s
, &chname
[chtab
[i
]]) == 0)
241 if (cbits(i
) != '\n') {
245 if (olinep
== oline
) {
252 ptesc(); /* the problem is to get back to the left end of the line */
254 for (k
= oline
; k
< olinep
; k
++) {
255 if (ismot(*k
) && isvmot(*k
)) {
264 *olinep
++ = makem(-dv
);
269 lead
+= dip
->blss
+ lss
;
271 for (k
= oline
; k
< olinep
; )
272 k
= ptout0(k
); /* now passing a pointer! */
278 fdprintf(ptid, "x xxx end of line: hpos=%d, vpos=%d\n", hpos, vpos);
280 fdprintf(ptid
, "n%d %d\n", b
, a
); /* be nice to chuck */
290 short z
, dx
, dy
, dx2
, dy2
, n
;
292 int outsize
; /* size of object being printed */
294 outsize
= 1; /* default */
314 fdprintf(ptid
, "x X ");
316 * not guaranteed of finding a XOFF if a word overflow
317 * error occured, so also bound this loop by olinep
320 while( cbits(*pi
) != XOFF
&& pi
< olinep
)
323 if ( cbits(*pi
) == XOFF
)
331 fdprintf(ptid
, "x H %d\n", sbits(i
));
335 fdprintf(ptid
, "x S %d\n", sfbits(i
)-180);
345 temp
[0] = n
& BYTEMASK
;
351 if (sfbits(i
) == oldbits
) {
356 if (k
< 040 && k
!= DRAWFCN
)
359 if (widcache
[k
-32].fontpts
== (xfont
<<8) + xpts
&& !setwdf
) {
360 w
= widcache
[k
-32].width
;
391 /* put out the real character here */
401 switch (cbits(pi
[1])) {
402 case DRAWCIRCLE
: /* circle */
403 fdprintf(ptid
, "D%c %d\n", DRAWCIRCLE
, dx
); /* dx is diameter */
408 fdprintf(ptid
, "D%c %d %d\n", DRAWELLIPSE
, dx
, dy
);
412 case DRAWLINE
: /* line */
414 fdprintf(ptid
, "D%c %d %d ", DRAWLINE
, dx
, dy
);
416 fdprintf(ptid
, "%c\n", k
);
418 fdprintf(ptid
, "%s\n", &chname
[chtab
[k
- 128]]);
423 case DRAWARC
: /* arc */
430 fdprintf(ptid
, "D%c %d %d %d %d\n", DRAWARC
,
436 case DRAWSPLINE
: /* spline */
437 default: /* something else; copy it like spline */
438 fdprintf(ptid
, "D%c %d %d", cbits(pi
[1]), dx
, dy
);
442 if (cbits(pi
[3]) == DRAWFCN
|| cbits(pi
[4]) == DRAWFCN
) {
443 /* it was somehow defective */
444 fdprintf(ptid
, "\n");
447 for (n
= 5; cbits(pi
[n
]) != DRAWFCN
; n
+= 2) {
451 dy
= absmot(pi
[n
+1]);
454 fdprintf(ptid
, " %d %d", dx
, dy
);
458 fdprintf(ptid
, "\n");
461 for (n
= 3; cbits(pi
[n
]) != DRAWFCN
; n
++)
464 } else if (k
< 128) {
465 /* try to go faster and compress output */
466 /* by printing nnc for small positive motion followed by c */
467 /* kludgery; have to make sure set all the vars too */
468 if (esc
> 0 && esc
< 100) {
469 oput(esc
/ 10 + '0');
470 oput(esc
% 10 + '0');
484 if (k
>= nchtab
+ 128)
485 fdprintf(ptid
, "N%d\n", k
- (nchtab
+128));
487 fdprintf(ptid
, "C%s\n", &chname
[chtab
[k
- 128]]);
494 fdprintf(ptid
, "c%c\n", k
);
495 } else if (k
>= nchtab
+ 128) {
496 fdprintf(ptid
, "N%d\n", k
- (nchtab
+128));
498 fdprintf(ptid
, "C%s\n", &chname
[chtab
[k
- 128]]);
512 for (j
= 0; i
> (k
= pstab
[j
]); j
++)
517 fdprintf(ptid
, "s%d\n", k
); /* really should put out string rep of size */
527 fdprintf(ptid
, "f%d\n", xfont
);
539 fdprintf(ptid
, "x font %d %s\n", f
, s
);
540 ptfont(); /* make sure that it gets noticed */
550 fdprintf(ptid
, "V%d\n", vpos
);
563 if (esc
>=10 && esc
<100) {
567 fdprintf(ptid
, "%d", esc
);
569 fdprintf(ptid
, "H%d\n", hpos
);
577 newpage(n
) /* called at end of each output page (we hope) */
585 fdprintf(ptid
, "p%d\n", n
); /* new page */
586 for (i
= 0; i
<= nfonts
; i
++)
587 if (fontbase
[i
]->namefont
&& fontbase
[i
]->namefont
[0])
588 fdprintf(ptid
, "x font %d %s\n", i
, fontbase
[i
]->namefont
);
598 fdprintf(ptid
, "x trailer\n");
606 fdprintf(ptid
, "x stop\n");
618 /* fdprintf(ptid, "x xxx end of page\n");*/
622 fdprintf(ptid
, "x pause\n");
627 hpos
= vpos
= 0; /* probably in wrong place */