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)
53
strcpy(termtab, DWBfontdir);
55
strcpy(fontdir, DWBfontdir);
57
strcpy(devname, TDEVNAME);
61
sprintf(buf, "/dev%s/DESC", devname);
63
if (getdesc(termtab) < 0) {
64
ERROR "can't open DESC file %s", termtab WARN;
68
OUT "x T %s\n", devname PUT;
69
OUT "x res %d %d %d\n", Inch, Hor, Vert PUT;
72
for (i = 1; i <= nfonts; i++)
73
setfp(i, fontlab[i], (char *) 0, 0);
74
sps = EM/3; /* space size */
75
ics = EM; /* insertion character space */
76
for (i = 0; i < (NTAB - 1) && DTAB * (i + 1) < TABMASK; i++)
77
tabtab[i] = DTAB * (i + 1);
79
pl = 11 * INCH; /* paper length */
80
po = PO; /* page offset */
83
ll = ll1 = lt = lt1 = LL;
84
t_specnames(); /* install names like "hyphen", etc. */
87
void t_specnames(void)
91
for (i = 0; spnames[i].n; i++)
92
*spnames[i].n = chadd(spnames[i].v, Troffchar, Install);
102
if (cbits(i) != '\n') {
103
if (olinep >= oline + olnsize) {
104
diff = olinep - oline;
106
if ((oline = (Tchar *)realloc((char *)oline, olnsize * sizeof(Tchar))) != NULL) {
108
olinep = oline + diff;
110
ERROR "Output line overflow." WARN;
117
if (olinep == oline) {
124
ptesc(); /* the problem is to get back to the left end of the line */
126
for (k = oline; k < olinep; k++) {
127
if (ismot(*k) && isvmot(*k)) {
136
*olinep++ = makem(-dv);
141
lead += dip->blss + lss;
143
for (k = oline; k < olinep; )
144
k += ptout0(k); /* now passing a pointer! */
150
OUT "x xxx end of line: hpos=%d, vpos=%d\n", hpos, vpos PUT;
152
OUT "n%d %d\n", b, a PUT; /* be nice to chuck */
155
int ptout0(Tchar *pi)
158
int z, dx, dy, dx2, dy2, n;
160
int outsize; /* size of object being printed */
163
outsize = 1; /* default */
177
xpts = fbits(i); /* sneaky, font bits as size bits */
180
OUT "x H %ld\n", sbits(i) PUT;
184
OUT "x S %ld\n", sfbits(i)-180 PUT;
191
if (sfbits(i) == oldbits) {
198
ptflush(); /* guarantee that everything is out */
209
for (j = 1; cbits(pi[j]) != XOFF; j++)
215
if (k < 040 && k != DRAWFCN)
219
if (widcache[k].fontpts == (xfont<<8) + xpts && !setwdf) {
220
w = widcache[k].width;
248
/* put out the real character here */
259
switch (cbits(pi[1])) {
260
case DRAWCIRCLE: /* circle */
261
OUT "D%c %d\n", DRAWCIRCLE, dx PUT; /* dx is diameter */
265
OUT "D%c %d %d\n", DRAWELLIPSE, dx, dy PUT;
270
OUT "D%c %d ", DRAWBUILD, dx PUT;
277
case DRAWLINE: /* line */
279
OUT "D%c %d %d ", DRAWLINE, dx, dy PUT;
287
case DRAWARC: /* arc */
294
OUT "D%c %d %d %d %d\n", DRAWARC,
295
dx, dy, dx2, dy2 PUT;
300
case 's': /* using 's' internally to avoid .tr ~ */
302
case DRAWSPLINE: /* spline */
303
default: /* something else; copy it like spline */
304
OUT "D%c %d %d", (char)cbits(pi[1]), dx, dy PUT;
307
if (cbits(pi[3]) == DRAWFCN || cbits(pi[4]) == DRAWFCN) {
308
/* it was somehow defective */
312
for (n = 5; cbits(pi[n]) != DRAWFCN; n += 2) {
316
dy = absmot(pi[n+1]);
319
OUT " %d %d", dx, dy PUT;
326
for (n = 3; cbits(pi[n]) != DRAWFCN; n++)
329
} else if (k < ALPHABET) {
330
/* try to go faster and compress output */
331
/* by printing nnc for small positive motion followed by c */
332
/* kludgery; have to make sure set all the vars too */
333
if (esc > 0 && esc < 100) {
334
oput(esc / 10 + '0');
335
oput(esc % 10 + '0');
368
char *chn = chname(k);
372
OUT "c%s\n", chn+1 PUT; /* \n not needed? */
375
OUT "N%s\n", chn+1 PUT;
378
OUT "C%s\n", chn+1 PUT;
381
ERROR "illegal char type %s", chn WARN;
386
void ptflush(void) /* get us to a clean output state */
389
/* ptesc(); but always H, no h */
391
OUT "\nH%d\n", hpos PUT;
404
for (j = 0; i > (k = pstab[j]); j++)
410
OUT "s%d\n", k PUT; /* really should put out string rep of size */
419
if (xfont > nfonts) {
420
ptfpcmd(0, fonts[xfont].longname, 0); /* Put the desired font in the
421
* fontcache of the filter */
422
OUT "f0\n" PUT; /* make sure that it gets noticed */
424
OUT "f%d\n", xfont PUT;
427
void ptfpcmd(int f, char *s, char *longname)
429
if (f > nfonts) /* a bit risky? */
432
OUT "x font %d %s %s\n", f, s, longname PUT;
434
OUT "x font %d %s\n", f, s PUT;
436
/* OUT "f%d\n", xfont PUT; /* need this for buggy version of adobe transcript */
437
/* which apparently believes that x font means */
438
/* to set the font, not just the position. */
445
OUT "V%d\n", vpos PUT;
455
if (esc>=10 && esc<100) {
461
OUT "H%d\n", hpos PUT;
465
void ptpage(int n) /* called at end of each output page, we hope */
475
OUT "p%d\n", n PUT; /* new page */
476
for (i = 0; i <= nfonts; i++)
478
if (fonts[i].truename)
479
OUT "x font %d %s %s\n", i, fonts[i].longname, fonts[i].truename PUT;
481
OUT "x font %d %s\n", i, fonts[i].longname PUT;
490
OUT "x trailer\n" PUT;
512
hpos = vpos = 0; /* probably in wrong place */