11 int vpos
= 0; /* absolute vertical position on page */
12 int hpos
= 0; /* ditto horizontal */
14 extern Font fonts
[MAXFONTS
+1];
35 setslant
= t_setslant
;
48 /* open table for device, */
49 /* read in resolution, size info, font info, etc., set params */
50 if ((p
= getenv("TYPESETTER")) != 0){
51 strncpy(devname
, p
, sizeof devname
);
52 devname
[sizeof devname
-1] = 0;
55 strcpy(termtab
, FONTDIR
);
57 strcpy(fontdir
, FONTDIR
);
59 strcpy(devname
, TDEVNAME
);
63 snprintf(buf
, sizeof buf
, "/dev%s/DESC", devname
);
65 if (getdesc(termtab
) < 0) {
66 ERROR
"can't open DESC file %s", termtab WARN
;
70 OUT
"x T %s\n", devname PUT
;
71 OUT
"x res %d %d %d\n", Inch
, Hor
, Vert PUT
;
74 for (i
= 1; i
<= nfonts
; i
++)
75 setfp(i
, fontlab
[i
], (char *) 0, 0);
76 sps
= EM
/3; /* space size */
77 ics
= EM
; /* insertion character space */
78 for (i
= 0; i
< (NTAB
- 1) && DTAB
* (i
+ 1) < TABMASK
; i
++)
79 tabtab
[i
] = DTAB
* (i
+ 1);
81 pl
= 11 * INCH
; /* paper length */
82 po
= PO
; /* page offset */
85 ll
= ll1
= lt
= lt1
= LL
;
86 t_specnames(); /* install names like "hyphen", etc. */
89 void t_specnames(void)
93 for (i
= 0; spnames
[i
].n
; i
++)
94 *spnames
[i
].n
= chadd(spnames
[i
].v
, Troffchar
, Install
);
104 if (cbits(i
) != '\n') {
105 if (olinep
>= oline
+ olnsize
) {
106 diff
= olinep
- oline
;
108 if ((oline
= (Tchar
*)realloc((char *)oline
, olnsize
* sizeof(Tchar
))) != NULL
) {
110 olinep
= oline
+ diff
;
112 ERROR
"Output line overflow." WARN
;
119 if (olinep
== oline
) {
126 ptesc(); /* the problem is to get back to the left end of the line */
128 for (k
= oline
; k
< olinep
; k
++) {
129 if (ismot(*k
) && isvmot(*k
)) {
138 *olinep
++ = makem(-dv
);
143 lead
+= dip
->blss
+ lss
;
145 for (k
= oline
; k
< olinep
; )
146 k
+= ptout0(k
); /* now passing a pointer! */
152 OUT "x xxx end of line: hpos=%d, vpos=%d\n", hpos, vpos PUT;
154 OUT
"n%d %d\n", b
, a PUT
; /* be nice to chuck */
157 int ptout0(Tchar
*pi
)
160 int z
, dx
, dy
, dx2
, dy2
, n
;
162 int outsize
; /* size of object being printed */
164 outsize
= 1; /* default */
178 xpts
= fbits(i
); /* sneaky, font bits as size bits */
181 OUT
"x H %d\n", sbits(i
) PUT
;
185 OUT
"x S %d\n", sfbits(i
)-180 PUT
;
192 if (sfbits(i
) == oldbits
) {
199 ptflush(); /* guarantee that everything is out */
210 for (j
= 1; cbits(pi
[j
]) != XOFF
; j
++)
216 if (k
< 040 && k
!= DRAWFCN
)
220 if (widcache
[k
].fontpts
== (xfont
<<8) + xpts
&& !setwdf
) {
221 w
= widcache
[k
].width
;
249 /* put out the real character here */
260 switch (cbits(pi
[1])) {
261 case DRAWCIRCLE
: /* circle */
262 OUT
"D%c %d\n", DRAWCIRCLE
, dx PUT
; /* dx is diameter */
266 OUT
"D%c %d %d\n", DRAWELLIPSE
, dx
, dy PUT
;
271 OUT
"D%c %d ", DRAWBUILD
, dx PUT
;
278 case DRAWLINE
: /* line */
280 OUT
"D%c %d %d ", DRAWLINE
, dx
, dy PUT
;
288 case DRAWARC
: /* arc */
295 OUT
"D%c %d %d %d %d\n", DRAWARC
,
296 dx
, dy
, dx2
, dy2 PUT
;
301 case 's': /* using 's' internally to avoid .tr ~ */
303 case DRAWSPLINE
: /* spline */
304 default: /* something else; copy it like spline */
305 OUT
"D%c %d %d", cbits(pi
[1]), dx
, dy PUT
;
308 if (cbits(pi
[3]) == DRAWFCN
|| cbits(pi
[4]) == DRAWFCN
) {
309 /* it was somehow defective */
313 for (n
= 5; cbits(pi
[n
]) != DRAWFCN
; n
+= 2) {
317 dy
= absmot(pi
[n
+1]);
320 OUT
" %d %d", dx
, dy PUT
;
327 for (n
= 3; cbits(pi
[n
]) != DRAWFCN
; n
++)
330 } else if (k
< ALPHABET
) {
331 /* try to go faster and compress output */
332 /* by printing nnc for small positive motion followed by c */
333 /* kludgery; have to make sure set all the vars too */
334 if (esc
> 0 && esc
< 100) {
335 oput(esc
/ 10 + '0');
336 oput(esc
% 10 + '0');
369 char *chn
= chname(k
);
373 OUT
"c%s\n", chn
+1 PUT
; /* \n not needed? */
376 OUT
"N%s\n", chn
+1 PUT
;
379 OUT
"C%s\n", chn
+1 PUT
;
382 ERROR
"illegal char type %s", chn WARN
;
387 void ptflush(void) /* get us to a clean output state */
390 /* ptesc(); but always H, no h */
392 OUT
"\nH%d\n", hpos PUT
;
405 for (j
= 0; i
> (k
= pstab
[j
]); j
++)
411 OUT
"s%d\n", k PUT
; /* really should put out string rep of size */
420 if (xfont
> nfonts
) {
421 ptfpcmd(0, fonts
[xfont
].longname
, 0); /* Put the desired font in the
422 * fontcache of the filter */
423 OUT
"f0\n" PUT
; /* make sure that it gets noticed */
425 OUT
"f%d\n", xfont PUT
;
428 void ptfpcmd(int f
, char *s
, char *longname
)
430 if (f
> nfonts
) /* a bit risky? */
433 OUT
"x font %d %s %s\n", f
, s
, longname PUT
;
435 OUT
"x font %d %s\n", f
, s PUT
;
437 /* OUT "f%d\n", xfont PUT; /* need this for buggy version of adobe transcript */
438 /* which apparently believes that x font means */
439 /* to set the font, not just the position. */
446 OUT
"V%d\n", vpos PUT
;
456 if (esc
>=10 && esc
<100) {
462 OUT
"H%d\n", hpos PUT
;
466 void ptpage(int n
) /* called at end of each output page, we hope */
476 OUT
"p%d\n", n PUT
; /* new page */
477 for (i
= 0; i
<= nfonts
; i
++)
479 if (fonts
[i
].truename
)
480 OUT
"x font %d %s %s\n", i
, fonts
[i
].longname
, fonts
[i
].truename PUT
;
482 OUT
"x font %d %s\n", i
, fonts
[i
].longname PUT
;
491 OUT
"x trailer\n" PUT
;
513 hpos
= vpos
= 0; /* probably in wrong place */