summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e49b41b)
algorithm, remove internal font "name", put options as #defines
SCCS-vsn: local/ditroff/ditroff.old.okeeffe/driver/dvar.c 1.6
*
* Varian driver for the new troff
*
*
* Varian driver for the new troff
*
-#define DEBUGABLE /* Yes, debugable... */
+/* #define DEBUGABLE /* No, not debugable... */
+#define DRIVER /* Yes, we're driving directly */
+/* #define FULLPAGE /* No, don't output full pages */
#define NFONTS 60 /* total number of fonts useable */
#define MAXSTATE 6 /* number of environments rememberable */
#define OPENREAD 0 /* mode for openning files */
#define NFONTS 60 /* total number of fonts useable */
#define MAXSTATE 6 /* number of environments rememberable */
#define OPENREAD 0 /* mode for openning files */
#define vmot(n) vgoto(vpos + n)
#define vmot(n) vgoto(vpos + n)
-char SccsId[]= "dvar.c 1.5 83/08/23";
+char SccsId[]= "dvar.c 1.6 83/10/06";
int output = 0; /* do we do output at all? */
int nolist = 0; /* output page list if > 0 */
int output = 0; /* do we do output at all? */
int nolist = 0; /* output page list if > 0 */
short * pstab; /* point size table pointer */
int nsizes; /* number of sizes device is capable of printing */
int nfonts; /* number of fonts device is capable of printing */
short * pstab; /* point size table pointer */
int nsizes; /* number of sizes device is capable of printing */
int nfonts; /* number of fonts device is capable of printing */
-int smnt; /* index of first special font */
int nchtab;
char * chname;
short * chtab;
int nchtab;
char * chname;
short * chtab;
char * codetab[NFONTS+1]; /* device codes */
char * fontdir = FONTDIR; /* place to find devxxx directories */
char * bitdir = BITDIR; /* place to find raster fonts and fontmap */
char * codetab[NFONTS+1]; /* device codes */
char * fontdir = FONTDIR; /* place to find devxxx directories */
char * bitdir = BITDIR; /* place to find raster fonts and fontmap */
-
-
-struct { /* table of what font */
- char *name; /* name is on what */
- int number; /* position in font tables */
-} fontname[NFONTS+1];
+char * fontname[NFONTS+1]; /* table of what font is on what position */
struct { /* table of what font */
char fname[3]; /* name maps to what */
char *ffile; /* filename in bitdirectory */
struct { /* table of what font */
char fname[3]; /* name maps to what */
char *ffile; /* filename in bitdirectory */
#define RASTER_LENGTH 2112 /* device line length */
#define BYTES_PER_LINE (RASTER_LENGTH/8)
#define RASTER_LENGTH 2112 /* device line length */
#define BYTES_PER_LINE (RASTER_LENGTH/8)
-#define NLINES 1700 /* page width, 8.5 inches */
+#ifndef FULLPAGE
+# define NLINES 1600 /* page width, 8 inches */
+#endif
+#ifdef FULLPAGE
+# define NLINES 1700 /* page width, 8.5 inches */
+#endif
#define BUFFER_SIZE (NLINES*BYTES_PER_LINE) /* number of chars in picture */
#define BUFFER_SIZE (NLINES*BYTES_PER_LINE) /* number of chars in picture */
while (--argc > 0 && **++argv == '-') {
switch ((*argv)[1]) {
case 'F':
while (--argc > 0 && **++argv == '-') {
switch ((*argv)[1]) {
case 'F':
- bitdir = operand(&argc, &argv));
+ bitdir = operand(&argc, &argv);
- fontdir = operand(&argc, &argv));
+ fontdir = operand(&argc, &argv);
break;
case 'o':
outlist(operand(&argc, &argv));
break;
case 'o':
outlist(operand(&argc, &argv));
ioctl(OUTFILE, VSETSTATE, pltmode);
ioctl(OUTFILE, VSETSTATE, pltmode);
if (argc < 1)
conv(stdin);
if (argc < 1)
conv(stdin);
for (i = 1; i <= nfonts; i++) {
fontbase[i] = (struct font *) p;
nw = *p & BMASK; /* 1st thing is width count */
for (i = 1; i <= nfonts; i++) {
fontbase[i] = (struct font *) p;
nw = *p & BMASK; /* 1st thing is width count */
- if (smnt == 0 && fontbase[i]->specfont == 1)
- smnt = i; /* first special font */
- p += sizeof(struct font); /* that is on the beginning */
+ p += sizeof(struct font);
widtab[i] = p;
codetab[i] = p + 2 * nw;
fitab[i] = p + 3 * nw;
widtab[i] = p;
codetab[i] = p + 2 * nw;
fitab[i] = p + 3 * nw;
fprintf(stderr, "dvar: ");
fprintf(stderr, s, a1, a2, a3, a4, a5, a6, a7);
fprintf(stderr, "\n");
fprintf(stderr, "dvar: ");
fprintf(stderr, s, a1, a2, a3, a4, a5, a6, a7);
fprintf(stderr, "\n");
scount = 0;
}
slop_lines(NLINES);
scount = 0;
}
slop_lines(NLINES);
ioctl(OUTFILE, VSETSTATE, prtmode);
if (write(OUTFILE, "\f", 2) != 2)
exit(RESTART);
ioctl(OUTFILE, VSETSTATE, pltmode);
ioctl(OUTFILE, VSETSTATE, prtmode);
if (write(OUTFILE, "\f", 2) != 2)
exit(RESTART);
ioctl(OUTFILE, VSETSTATE, pltmode);
break;
case 's':
slop_lines(NLINES);
break;
case 's':
slop_lines(NLINES);
ioctl(OUTFILE, VSETSTATE, prtmode);
if (write(OUTFILE, "\f", 2) != 2)
exit(RESTART);
ioctl(OUTFILE, VSETSTATE, prtmode);
if (write(OUTFILE, "\f", 2) != 2)
exit(RESTART);
break; /* no Return */
}
}
break; /* no Return */
}
}
if (i != 0) { /* it's on this font */
p = codetab[font]; /* get the printing value of ch */
pw = widtab[font]; /* get the width */
if (i != 0) { /* it's on this font */
p = codetab[font]; /* get the printing value of ch */
pw = widtab[font]; /* get the width */
- } else if (smnt > 0) { /* on special (we hope) */
- for (k=smnt, j=0; j <= nfonts; j++, k = (k+1) % (nfonts+1)){
+ } else /* on another font (we hope) */
+ for (k=font, j=0; j <= nfonts; j++, k = (k+1) % (nfonts+1)){
if (fitab[k] == 0)
continue;
if ((i = fitab[k][c] & BMASK) != 0) {
if (fitab[k] == 0)
continue;
if ((i = fitab[k][c] & BMASK) != 0) {
if (i == 0 || (code = p[i] & BMASK) == 0 || k > nfonts) {
#ifdef DEBUGABLE
if (dbg) fprintf(stderr,"not found 0%o\n", c+32);
if (i == 0 || (code = p[i] & BMASK) == 0 || k > nfonts) {
#ifdef DEBUGABLE
if (dbg) fprintf(stderr,"not found 0%o\n", c+32);
}
t_fp(n, s, si) /* font position n now contains font s, intname si */
}
t_fp(n, s, si) /* font position n now contains font s, intname si */
+int n; /* internal name is ignored */
char *s, *si;
{
register int i;
char *s, *si;
{
register int i;
- fontname[n].name = s;
- fontname[n].number = atoi(si);
for(i = 0;i < NFONTS;i++) /* free the bits of that font */
if (fontdes[i].fnum == n){
nfree(fontdes[i].bits);
for(i = 0;i < NFONTS;i++) /* free the bits of that font */
if (fontdes[i].fnum == n){
nfree(fontdes[i].bits);
}
}
/* this is a new font */
}
}
/* this is a new font */
- if (fnum < 0 || fnum > NFONTS || fontname[fnum].name == 0) {
+ if (fnum < 0 || fnum > NFONTS || fontname[fnum] == 0) {
fprintf(stderr, "Internal error: illegal font %d name %s size\n",
fprintf(stderr, "Internal error: illegal font %d name %s size\n",
- fontname[fnum].name, fnum, fsize);
+ fontname[fnum], fnum, fsize);
return(-1);
}
/* Need to verify the existance of that font/size here*/
return(-1);
}
/* Need to verify the existance of that font/size here*/
register int fsize;
register int fontd;
register int d;
register int fsize;
register int fontd;
register int d;
- register int savesize = size;
+ register int sizehunt = size;
char cbuf[BUFSIZ];
fnum = nfontnum;
fsize = npsize;
/* try to open font file - if unsuccessful, hunt for */
/* a file of same style, different size to substitute */
char cbuf[BUFSIZ];
fnum = nfontnum;
fsize = npsize;
/* try to open font file - if unsuccessful, hunt for */
/* a file of same style, different size to substitute */
- d = -1; /* direction to look in pstab (smaller first) */
+ d = -1; /* direction to look in pstab (smaller first) */
- sprintf(cbuf, "%s/%s.%dr", bitdir, fontname[fnum].name, fsize);
+ sprintf(cbuf, "%s/%s.%dr", bitdir, fontname[fnum], fsize);
fontd = open(cbuf, OPENREAD);
if (fontd == -1) { /* File wasn't found. Try another ps */
fontd = open(cbuf, OPENREAD);
if (fontd == -1) { /* File wasn't found. Try another ps */
- size += d;
- if (size < 0) { /* past beginning - look higher */
+ sizehunt += d;
+ if (sizehunt < 0) { /* past beginning - look higher */
- if (size > nsizes) { /* past top - forget it */
+ if (sizehunt > nsizes) { /* past top - forget it */
+ fsize = pstab[sizehunt];
}
}
} while (fontd == -1 && d != 0);
}
}
} while (fontd == -1 && d != 0);
if (fontd == -1) { /* completely unsuccessful */
perror(cbuf);
error(!FATAL,"fnum = %d, psize = %d, name = %s",
if (fontd == -1) { /* completely unsuccessful */
perror(cbuf);
error(!FATAL,"fnum = %d, psize = %d, name = %s",
- fnum, npsize, fontname[fnum].name);
+ fnum, npsize, fontname[fnum]);
fontwanted = 0;
return (-1);
}
fontwanted = 0;
return (-1);
}
cfont = relfont();
if ((bits=nalloc(header.size+DSIZ+1,1))== NULL)
if ((bits=allpanic(header.size+DSIZ+1))== NULL) {
cfont = relfont();
if ((bits=nalloc(header.size+DSIZ+1,1))== NULL)
if ((bits=allpanic(header.size+DSIZ+1))== NULL) {
- fprintf(stderr,"%s: ran out of memory\n", cbuf);
- exit(ABORT);
+ error(FATAL,"%s: ran out of memory", cbuf);
offset = off8 - 8;
for (i = 0; i < nlines; i++) {
if (scanp >= &buffer[BUFFER_SIZE])
offset = off8 - 8;
for (i = 0; i < nlines; i++) {
if (scanp >= &buffer[BUFFER_SIZE])
- scanp -= sizeof buffer;
- if (scanp + count <= &buffer[BUFFER_SIZE]) {
+ if (scanp + count < &buffer[BUFFER_SIZE]) {
do {
fontdata = *(unsigned *)addr;
addr += 4;
do {
fontdata = *(unsigned *)addr;
addr += 4;
usize = BYTES_PER_LINE * nlines;
vwrite(buf0p, usize);
vclear(buf0p, usize);
usize = BYTES_PER_LINE * nlines;
vwrite(buf0p, usize);
vclear(buf0p, usize);
ioctl(OUTFILE, VSETSTATE, pltmode);
ioctl(OUTFILE, VSETSTATE, pltmode);