2 static char rcsid[] =
"$Id: dvirle1.c,v 3.0.1.3 1992/02/28 22:12:53 spencer Exp $";
62 #define InitialChars 4000
89 #define ABS(n) ((n) >= 0
? (n) : -(n))
97 register struct font *f;
99 register struct glyph *g;
102 for (i = 0; i < 128; i++) {
105 g->g_pixwidth = fromSP(g->g_tfmwidth);
115 register unsigned newsize;
119 if ((
yx = (
int *) realloc((
char *)
yx, newsize)) == NULL)
120 GripeOutOfMemory(newsize,
"yx array");
121 if ((
fcp = (
int *) realloc((
char *)
fcp, newsize)) == NULL)
122 GripeOutOfMemory(newsize,
"fcp array");
136 register int i, j, k, delta, *y, *f;
145 while (9 * delta + 4 <
Chars)
146 delta = 3 * delta + 1;
148 for (i = delta; i <
Chars; i++) {
149 if (y[j = i - delta] < y[i]) {
150 register int t1 = y[i];
151 register int t2 = f[i];
159 }
while (j >= 0 && y[j] < t1);
173 DefineFont(name, dvimag, dvidsz)
177 register struct font *f;
183 error(1, 0,
"too many fonts (%d) used", next);
185 f = GetRasterlessFont(name, dvimag, dvidsz,
"versatec", &path);
187 GripeCannotGetFont(name, dvimag, dvidsz,
"versatec", path);
191 (
void) fprintf(stderr,
"[%s -> %s]\n", Font_TeXName(f), path);
192 (
void) fflush(stderr);
199 PutLong(stdout, 300);
200 PutLong(stdout, ds.ds_usermag);
201 PutLong(stdout, ds.ds_num);
202 PutLong(stdout, ds.ds_denom);
203 PutLong(stdout, ds.ds_dvimag);
206 PutLong(stdout, f->f_checksum);
207 PutLong(stdout, dvimag);
208 PutLong(stdout, dvidsz);
210 PutLong(stdout, len);
211 (
void) fputs(name, stdout);
213 f->f_un.f_int = next++;
227 (
void) putc(
' ', stderr);
228 (
void) fprintf(stderr,
"[%d", (
int)count[0]);
229 (
void) fflush(stderr);
250 register int i, *y, *f, t, v, oldv;
259 (
void) fflush(stderr);
269 fprintf( stderr,
"oldv: %ld, yx: %lx (%d,%d), fcp: %lx\n",
270 oldv, *y, (*y >> 16), (*y & 0xffff), *f );
274 t = (t << 16) | (*y++ & 0xffff);
285 t = *f++ & 0x7fffffff;
314 error(0, 0,
"warning: ignoring \\special");
315 (
void) fseek(ds.ds_fp, (
long) len, 1);
353 if (ymax > MaxPageHeight)
354 ymax = MaxPageHeight, anybad++;
364 error(0, 0,
"WARNING: rule(s) off page edge; clipped to fit");
367 for (y = ymax; y > ymin; y -= h) {
368 for (x = xmin; x < xmax; x += w) {
375 *
nextyx++ = (y << 16) | x;
376 *
nextfcp++ = (1 << 31) | (x << 16) | (h << 8) | w;
392 error(0, 0,
"Warning: character code %ld too big",
406 static struct font NoFont;
409 register struct font *f = &NoFont;
410 register FILE *fp = ds.ds_fp;
411 int doingpage = 0, advance;
413 static char warn[] =
"\
414 WARNING: text object(s) run off %s of page; ignored";
415 #define CHECK(cond, msg, flag)
418 error(0
, 0
, warn, msg);
435 register struct glyph *g;
436 register int ulcx, ulcy, height;
447 ulcy = dvi_vv + g->g_height - g->g_yorigin;
448 ulcx = dvi_hh - g->g_xorigin;
449 height = g->g_height;
455 ulcy = dvi_hh + g->g_width - g->g_xorigin;
457 (dvi_vv + g->g_height - g->g_yorigin);
461 CHECK(ulcy + height >= MaxPageHeight,
468 for (c = 0; height > 0; c++) {
471 *
nextyx++ = (ulcy << 16) | ulcx;
472 *nextfcp++ = (f->f_un.f_int <<
FONTSHIFT) |
479 dvi_h += g->g_tfmwidth;
480 dvi_hh += g->g_pixwidth;
488 GripeUnexpectedDVIEOF();
493 switch (DVI_OpLen(c)) {
533 panic(
"DVI_OpLen(%d) = %d", c, DVI_OpLen(c));
567 GripeUnexpectedOp(
"BOP (already in page)");
568 DVIBeginPage(BeginPage);
574 GripeUnexpectedOp(
"EOP (no BOP)");
579 *ds.ds_sp++ = ds.ds_cur;
583 ds.ds_cur = *--ds.ds_sp;
605 if (F_SMALLH(f, p)) {
610 dvi_hh = fromSP(dvi_h);
632 if (F_SMALLV(f, p)) {
637 dvi_vv = fromSP(dvi_v);
641 f = DVIFindFont((i32)(c - DVI_FNTNUM0));
657 GripeUnexpectedOp(
"PRE");
662 GripeUnexpectedOp(
"POST (no EOP)");
668 GripeUnexpectedOp(
"POSTPOST");
676 panic(
"DVI_DT(%d) = %d", c, DVI_DT(c));
686 register char **argv;
696 ds.ds_usermag = 1000;
700 while ((c = getopt(argc, argv,
"cd:hm:sD")) != EOF) {
708 ds.ds_maxdrift = atoi(optarg);
716 ds.ds_usermag = atoi(optarg);
728 (
void) fprintf(stderr,
"\
729 Usage: %s [-c] [-h] [-m mag] [-s] [file]\n",
ProgName);
730 (
void) fflush(stderr);
737 error(1, -1,
"can't open %s", argv[
optind]);
740 if (MakeSeekable(stdin))
742 "unable to copy input to temp file (see the manual)");
745 if ((TeXFontDesc = getenv(CONFENV)) == NULL)
753 putbyte(stdout, *s++);
756 DVISetState(fp, DefineFont, 300, 0, 0);
758 TallestPageHeight = fromSP(ds.ds_maxheight);
759 WidestPageWidth = fromSP(ds.ds_maxwidth);
770 if (MaxPageWidth - MinimumLeftMargin < TallestPageHeight)
771 error(1, 0,
"text object too high!");
772 if (MaxPageHeight - MinimumTopMargin < WidestPageWidth)
773 error(1, 0,
"text object too wide!");
775 if (MaxPageWidth - MinimumLeftMargin < WidestPageWidth)
776 error(1, 0,
"text object too wide!");
786 cannot center (page too wide); placing flush left instead");
810 "Page too high (%d bits), truncated to %d bits\n",
822 "Page too wide (%d bits), truncated to %d bits\n",
831 ds.ds_fresh.hh = lmargin;
832 ds.ds_fresh.vv = TopMargin;
833 ds.ds_fresh.h = toSP(ds.ds_fresh.hh);
834 ds.ds_fresh.v = toSP(ds.ds_fresh.vv);
857 return fcntl( fd1, F_DUPFD, fd2 );
void main(int argc, char **argv)
#define DefaultBottomMargin
#define MinimumLeftMargin
#define DefaultLeftMargin
#define CHECK(cond, msg, flag)