From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- dviware/kane/checkpage.h | 199 ++++++++ dviware/kane/dvifile_p.h | 313 ++++++++++++ dviware/kane/dvijep_p | 1189 ++++++++++++++++++++++++++++++++++++++++++++++ dviware/kane/gblvars.h | 357 ++++++++++++++ dviware/kane/prtpage_p.h | 307 ++++++++++++ dviware/kane/readme.txt | 20 + 6 files changed, 2385 insertions(+) create mode 100644 dviware/kane/checkpage.h create mode 100644 dviware/kane/dvifile_p.h create mode 100644 dviware/kane/dvijep_p create mode 100644 dviware/kane/gblvars.h create mode 100644 dviware/kane/prtpage_p.h create mode 100644 dviware/kane/readme.txt (limited to 'dviware/kane') diff --git a/dviware/kane/checkpage.h b/dviware/kane/checkpage.h new file mode 100644 index 0000000000..8deecaa9bc --- /dev/null +++ b/dviware/kane/checkpage.h @@ -0,0 +1,199 @@ + +Date: 20-MAR-1989 17:21:05 GMT +From: PHYOKANE@CS8700.UCG.IE +To: abbottp@ASTON.AC.UK +Subject: file checkpage.h +sender: hea"phyokane@cs8700.ucg.ie" + +/* -*-C-*- checkpage.h */ +/*-->checkpage*/ +/**********************************************************************/ +/***************************** checkpage ******************************/ +/**********************************************************************/ +void +checkpage(bytepos) /* check page whose BOP is at bytepos */ +long bytepos; + +{ + register BYTE command; /* current command */ + register INT16 i; /* command parameter; loop index */ + char tc; /* temporary character */ + INT32 k; /* temporary parameter */ + INT16 page_number; /* TeX's \count0 parameter */ + BOOLEAN seen_bop; /* flag for noting processing of BOP */ + +/*********************************************************************** +Check all commands between the BOP at bytepos and the next EOP, downloading +any characters not already loaded. +***********************************************************************/ + + seen_bop = FALSE; /* this is first time through */ + (void) FSEEK(dvifp,bytepos,0); /* start at the desired position */ + for (;;) /* "infinite" loop - exits when POST or second BOP met */ + { + command = (BYTE)nosignex(dvifp,(BYTE)1); + switch (command) + { + + case SET1: + case SET2: + case SET3: + case SET4: + (void)checkchldd((BYTE)nosignex(dvifp,(BYTE)(command-SET1+1))); + break; + + case SET_RULE: + (void) nosignex(dvifp,(BYTE)4); + (void) nosignex(dvifp,(BYTE)4); + break; + + case PUT1: + case PUT2: + case PUT3: + case PUT4: + (void)checkchldd((BYTE)nosignex(dvifp,(BYTE)(command-PUT1+1))); + break; + + case PUT_RULE: + (void) nosignex(dvifp,(BYTE)4); + (void) nosignex(dvifp,(BYTE)4); + break; + + case NOP: + break; + + case BOP: + if (seen_bop) + return; /* we have been here already */ + seen_bop = TRUE; + + for (i=0; i<=9; i++) + (void)(INT32)signex(dvifp,(BYTE)4); + if (!quiet) + (void)fprintf(stderr,"*"); + + (void) nosignex(dvifp,(BYTE)4); /* skip prev. page ptr */ + (void)bopact(); + fontptr = (struct font_entry*)NULL; + break; + + case EOP: + return; + + case PUSH: + break; + + case POP: + break; + + case RIGHT1: + case RIGHT2: + case RIGHT3: + case RIGHT4: + (void)signex(dvifp,(BYTE)(command-RIGHT1+1)); + break; + + case W0: + break; + + case W1: + case W2: + case W3: + case W4: + (void)signex(dvifp,(BYTE)(command-W1+1)); + break; + + case X0: + break; + + case X1: + case X2: + case X3: + case X4: + (void)signex(dvifp,(BYTE)(command-X1+1)); + break; + + case DOWN1: + case DOWN2: + case DOWN3: + case DOWN4: + (void)signex(dvifp,(BYTE)(command-DOWN1+1)); + break; + + case Y0: + break; + + case Y1: + case Y2: + case Y3: + case Y4: + (void)signex(dvifp,(BYTE)(command-Y1+1)); + break; + + case Z0: + break; + + case Z1: + case Z2: + case Z3: + case Z4: + (void) signex(dvifp,(BYTE)(command-Z1+1)); + break; + + case FNT1: + case FNT2: + case FNT3: + case FNT4: + (void)setfntnm((INT32)nosignex(dvifp, + (BYTE)(command-FNT1+1))); + break; + + case XXX1: + case XXX2: + case XXX3: + case XXX4: + k = (INT32)nosignex(dvifp,(BYTE)(command-XXX1+1)); + while (k--) + { + (void)nosignex(dvifp,(BYTE)1); + } + break; + + case FNT_DEF1: + case FNT_DEF2: + case FNT_DEF3: + case FNT_DEF4: + if (preload) + (void)skipfont ((INT32) nosignex(dvifp, + (BYTE)(command-FNT_DEF1+1))); + else + (void)readfont ((INT32) nosignex(dvifp, + (BYTE)(command-FNT_DEF1+1))); + break; + + case PRE: + (void)fatal("checkpage(): PRE occurs within file"); + break; + + case POST: + break; + + case POST_POST: + (void)fatal("checkpage(): POST_POST with no preceding POST"); + break; + + default: + if (command >= FONT_00 && command <= FONT_63) + (void)setfntnm((INT32)(command - FONT_00)); + else if (command >= SETC_000 && command <= SETC_127) + (void)checkchldd((BYTE)(command-SETC_000)); + else + { + (void)sprintf(message,"checkpage(): %d is an undefined command", + command); + (void)fatal(message); + } + break; + } + } + } diff --git a/dviware/kane/dvifile_p.h b/dviware/kane/dvifile_p.h new file mode 100644 index 0000000000..4070054b83 --- /dev/null +++ b/dviware/kane/dvifile_p.h @@ -0,0 +1,313 @@ + +Date: 20-MAR-1989 17:20:04 GMT +From: PHYOKANE@CS8700.UCG.IE +To: abbottp@ASTON.AC.UK +Subject: file dvifile_p.h +sender: hea"phyokane@cs8700.ucg.ie" + +/* -*-C-*- dvifile.h */ +/*-->dvifile*/ +/**********************************************************************/ +/****************************** dvifile *******************************/ +/**********************************************************************/ + +void +dvifile(argc,argv,filestr) +int argc; /* argument count */ +char* argv[]; /* argument strings */ +char* filestr; /* DVI filename to process */ + +{ + +#define PAGENUMBER(p) ((p) < 0 ? (page_count + 1 + (p)) : (p)) + + register INT16 i,j,m; /* loop indices */ + register INT16 swap; /* swap storage */ + register struct font_entry *p; + + INT16 m_begin,m_end,m_step; /* loop limits and increment */ + INT16 list[3]; /* index list for sort */ + char tempstr[MAXSTR]; /* temporary string storage */ + int the_char; + int s; + int slot; + int n_slots; + int fontsize; + int pfont_size; + int pfont_n; + struct font_entry *bigfont; + struct printer_font *pptr; + /* + Establish the default font file search order. This is done here + instead of in initglob() or option(), because both could set + fontlist[]. + + By default, the search list contains names for the PK, GF, and PXL + font files; that order corresponds to increasing size (and + therefore, presumably, increasing processing cost) of font raster + information. This search order may be overridden at run time by + defining an alternate one in the environment variable FONTLIST; the + order of the strings "PK", "GF", and "PXL" in that variable + determines the search order, and letter case is NOT significant. + The substrings may be separated by zero or more arbitrary + characters, so the values "PK-GF-PXL", "PK GF PXL", "PKGFPXL", + "PK;GF;PXL", "PK/GF/PXL" are all acceptable, and all choose the + default search order. This flexibility in separator character + choice is occasioned by the requirement on some systems that the + environment variable have the syntax of a file name, or be a single + "word". If any substring is omitted, then that font will be + excluded from consideration. Thus, "GF" permits the use only of GF + font files. + + The indexes gf_index, pk_index, and pxl_index are in -1 .. 2, and at + least one must be non-negative. A negative index excludes that font + file type from the search. + */ + + /* Note that non-negative entries in list[] are UNIQUE. */ + list[0] = gf_index = (INT16)strid2(fontlist,"GF"); + list[1] = pk_index = (INT16)strid2(fontlist,"PK"); + list[2] = pxl_index = (INT16)strid2(fontlist,"PXL"); + + for (i = 0; i < 3; ++i) /* put list in non-decreasing order */ + for (j = i+1; j < 3; ++j) + if (list[i] > list[j]) + { + swap = list[i]; + list[i] = list[j]; + list[j] = swap; + } + for (i = 0; i < 3; ++i) /* assign indexes 0,1,2 */ + if (list[i] >= 0) + { + if (list[i] == gf_index) + gf_index = i; + else if (list[i] == pk_index) + pk_index = i; + else if (list[i] == pxl_index) + pxl_index = i; + } + + if ((gf_index < 0) && (pk_index < 0) && (pxl_index < 0)) + (void)fatal("dvifile(): FONTLIST does not define at least one of \ +GF, PK, or PXL fonts"); + + (void)dviinit(filestr); /* initialize DVI file processing */ + + (void)devinit(argc,argv); /* initialize device output */ + + (void)readpost(); + (void)FSEEK(dvifp, 14L, 0); /* position past preamble */ + (void)getbytes(dvifp, tempstr, + (BYTE)nosignex(dvifp,(BYTE)1)); /* flush DVI comment */ + + cur_page_number = 0; + + +#if (HPLASERJET|HPJETPLUS|GOLDENDAWNGL100|POSTSCRIPT|IMPRESS|CANON_A2) + /* print pages in reverse order because of laser printer */ + /* page stacking */ + if (backwards) + { + m_begin = 1; + m_end = page_count; + m_step = 1; + } + else /* normal device order */ + { + m_begin = page_count; + m_end = 1; + m_step = -1; + } + +#else + /* NOT (HPLASERJET|HPJETPLUS|GOLDENDAWNGL100|POSTSCRIPT|IMPRESS|CANON_A2) */ + /* print pages in forward order for most devices */ + if (backwards) + { + m_begin = page_count; + m_end = 1; + m_step = -1; + } + else + { + m_begin = 1; + m_end = page_count; + m_step = 1; + } +#endif /* (HPLASERJET|HPJETPLUS|GOLDENDAWNGL100|POSTSCRIPT|IMPRESS|CANON_A2) */ + + for (i = 0; i < npage; ++i) /* make page numbers positive */ + { /* and order pairs non-decreasing */ + page_begin[i] = PAGENUMBER(page_begin[i]); + page_end[i] = PAGENUMBER(page_end[i]); + if (page_begin[i] > page_end[i]) + { + swap = page_begin[i]; + page_begin[i] = page_end[i]; + page_end[i] = swap; + } + } +/* First pass over pages and setup font download information */ + + for (m = m_begin; ; m += m_step) + { + for (i = 0; i < npage; ++i) /* search page list */ + if ( IN(page_begin[i],m,page_end[i]) && + (((m - page_begin[i]) % page_step[i]) == 0) ) + { + if (!quiet) /* start progress report */ + (void)fprintf(stderr,"[%d", m); + cur_page_number++;/* sequential page number 1..N */ + cur_index = m-1; /* remember index globally */ + checkpage(page_ptr[cur_index]); + if (!quiet) /* finish progress report */ + (void)fprintf(stderr,"] "); + break; + } + if (m == m_end) /* exit loop after last page */ + break; + } +if (!quiet) /* finish progress report */ + (void)fprintf(stderr,"\n"); + +/* Initialize the printer fonts */ +for (pf = FIRSTPRINTERFONT; pf <= LASTPRINTERFONT; pf++) +{ + printer_fonts[pf].slots_free = 190; + for (s = 0; s < 190; s++) + { + printer_fonts[pf].char_slots[s].tex_char = -1; + printer_fonts[pf].char_slots[s].tex_font = NULL; + } +} +/* Pack the TeX fonts into printer fonts + + WHILE there are unassigned TeX fonts + select the largest TeX font + if possible assign all of the TeX font + to the FIRST SMALLEST SPACE free in the printer fonts + else + find the FIRST LARGEST SPACE free and assign as much + of the TeX font as will fit +*/ +do { + /* First....find the largest TeX font left....*/ + fontsize = 0; + bigfont = NULL; + fontptr = hfontptr; + while ((fontptr != (struct font_entry *)NULL)) + { + if ((fontptr->used_chars - fontptr->assigned_chars) > fontsize) + { + fontsize = fontptr->used_chars - fontptr->assigned_chars; + bigfont = fontptr; + } + fontptr = fontptr->next; + } + if (bigfont == NULL) break; /* All TeX fonts assigned */ + fontptr = bigfont; + fontsize = (fontsize > 190) ? 190 : fontsize; + + /* Next... find a printer font to put it in.... */ + pfont_size = 1000; + for (pf = FIRSTPRINTERFONT; pf <= LASTPRINTERFONT; pf++) + { + if ((printer_fonts[pf].slots_free >= fontsize) && + (printer_fonts[pf].slots_free < pfont_size)) + { + pfont_size = printer_fonts[pf].slots_free; + pfont_n = pf; + } + } + /* ...if there is no big slot then split this font... */ + /* putting the first bit into the bigest free slot */ + if (pfont_size > 190) + { + pfont_size = 0; + for (pf = FIRSTPRINTERFONT; pf <= LASTPRINTERFONT; pf++) + { + if (printer_fonts[pf].slots_free > pfont_size) + { + pfont_size = printer_fonts[pf].slots_free; + pfont_n = pf; + } + } + } + if (pfont_size == 0) + (void)fatal( "dvifile(): Need more printer fonts"); + pf = pfont_n; +/* Printer font number pf has pfont_size slots available to take characters + from TeX font fontptr */ + (void)fprintf(stderr, +"[Assigning %d characters from %s (mag = %g) to printer font %d]\n", + (fontsize <= pfont_size) ? fontsize : pfont_size, + fontptr->n,(fontptr->font_mag)/1500.0,pf); + for (the_char = FIRSTPXLCHAR; the_char <= LASTPXLCHAR; the_char++) + { + if (printer_fonts[pf].slots_free == 0) + break; + if (fontptr->ch[the_char].isloaded == FALSE) /* Not used */ + continue; + if (fontptr->ch[the_char].lj_font != 65535)/* Already assigned */ + continue; + slot = 190 - printer_fonts[pf].slots_free--; + printer_fonts[pf].char_slots[slot].tex_char = the_char; + printer_fonts[pf].char_slots[slot].tex_font = fontptr; + fontptr->ch[the_char].lj_char = slot; + fontptr->ch[the_char].lj_font = pf; + fontptr->assigned_chars++; + } + if ( printer_fonts[pf].slots_free == pfont_size ) /* Nothing happened !!!*/ + fontptr->assigned_chars = fontptr->used_chars;/* Zero size font ?? */ +} while (TRUE); +/* .... and finally download the fonts to the printer.... */ +for (pf = FIRSTPRINTERFONT; pf <= LASTPRINTERFONT; pf++) +{ + pptr = &printer_fonts[pf]; + if (pptr->slots_free == 190) continue; + slot = 0; + n_slots = 190 - pptr->slots_free; + (void)fprintf(stderr,"[Loading printer font %d with %d characters]\n", + pf,n_slots); + (void)makefont(pptr,n_slots); + do { + fontptr = pptr->char_slots[slot].tex_font; + while ( (slot < n_slots) && + (pptr->char_slots[slot].tex_font == fontptr) ) + { + loadchar(pptr->char_slots[slot].tex_char,MAP_CHAR(slot)); + ++slot; + } + } while ( slot < n_slots ); +} + +#if (HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2) + pf = -1; +#endif + + +/* Finally pass over pages and print them */ + for (m = m_begin; ; m += m_step) + { + for (i = 0; i < npage; ++i) /* search page list */ + if ( IN(page_begin[i],m,page_end[i]) && + (((m - page_begin[i]) % page_step[i]) == 0) ) + { + if (!quiet) /* start progress report */ + (void)fprintf(stderr,"[%d", m); + cur_page_number++;/* sequential page number 1..N */ + cur_index = m-1; /* remember index globally */ + prtpage(page_ptr[cur_index]); + if (!quiet) /* finish progress report */ + (void)fprintf(stderr,"] "); + break; + } + if (m == m_end) /* exit loop after last page */ + break; + } + + (void)devterm(); /* terminate device output */ + + (void)dviterm(); /* terminate DVI file processing */ +} diff --git a/dviware/kane/dvijep_p b/dviware/kane/dvijep_p new file mode 100644 index 0000000000..da0d36a1fc --- /dev/null +++ b/dviware/kane/dvijep_p @@ -0,0 +1,1189 @@ + +Date: 20-MAR-1989 17:19:34 GMT +From: PHYOKANE@CS8700.UCG.IE +To: abbottp@ASTON.AC.UK +Subject: file dvijep_p +sender: hea"phyokane@cs8700.ucg.ie" + +/*-->dvipp8*/ +/**********************************************************************/ +/******************************* dvipp8 *******************************/ +/**********************************************************************/ + +#include "dvihead.h" + +/*********************************************************************** +***********************************************************************/ + +/**********************************************************************/ +/************************ Device Definitions ************************/ +/**********************************************************************/ + +/* All output-device-specific definitions go here. This section must +be changed when modifying a dvi driver for use on a new device */ + +#undef HPJETPLUS +#define HPJETPLUS 1 /* conditional compilation flag */ + +#define VERSION_NO "2.10" /* DVI driver version number */ + +#define DEVICE_ID "Hewlett Packard Laserjet+ laser printer" + /* this string is printed at runtime */ + +#define OUTFILE_EXT "jep" + +#define BYTE_SIZE 8 /* output file byte size */ + +#undef STDRES +#define STDRES 1 /* to get standard font resolution */ + +#define MAXLINE 4096 /* maximum input file line size */ + /* it is needed only in special() */ + +#define MAXPAGEFONTS 16 /* silly limit on fonts/page */ + +#define FIRSTPRINTERFONT 16 /* Lowest font number used */ +#define LASTPRINTERFONT 31 /* Highest font number used */ + +#define XDPI 300 /* horizontal dots/inch */ +#define XPSIZE 9 /* horizontal paper size in inches */ +#define XSIZE (((XDPI*XPSIZE+2*HOST_WORD_SIZE-1)/\ + (2*HOST_WORD_SIZE))*(2*HOST_WORD_SIZE)) + /* number of horizontal dots; */ + /* MUST BE multiple of */ + /* 2*HOST_WORD_SIZE */ + +#define YDPI 300 /* vertical dots/inch */ +#define YPSIZE 11 /* vertical paper size in inches */ +#define YSIZE 4096 /* number of vertical dots */ + +#define XORIGIN 60 /* measured pixel coordinates of */ +#define YORIGIN 15 /* page origin (should be at (0,0) */ + +/*********************************************************************** +Define some useful shorthand macros for all required LaserJet Plus +commands. With the exception of the CREATEFONT and DOWNLOADCHAR macros, +which require extra data, NO escape sequences appear anywhere else in +the text. + +The LaserJet Plus allows coordinates in dots as well as the decipoints +supported by the regular LaserJet. Dot coordinates are more convenient, +so we use them exclusively. The Plus puts the page origin in the upper- +left corner, while we have it in the lower-left corner, so MOVEY adjusts +the coordinate accordingly. + +With 7-bit fonts, only characters 33..127 are printable, and with 8-bit fonts, +33..127 and 160..255 are printable. Since TeX assumes characters 0..255 are +available, but 0..127 are used most often, we remap character numbers in 0..32 +to 191..223, and 128..159 to 224..255, and use 8-bit fonts. The macros +conceal the remapping. This means that 191..255 are not available for +downloading to: these characters are handles by raster graphics. + +Whenever possible, escape sequences are combined and 0 parameters +omitted, in order to compress the output. +***********************************************************************/ + +/* Begin raster graphics .. {transfer raster graphics} .. end raster graphics */ +#define BEGIN_RASTER_GRAPHICS OUTS("\033*t300R\033*r1A") + +/* CREATE_FONT must be followed by a 26-byte font header (see readfont) */ +#define CREATE_FONT OUTS("\033\051s26W") + +#define DELETE_ALL_FONTS OUTS("\033*c1F") + +#define SELECT_ROMAN8 + +/* DOWNLOAD_CHARACTER is not a complete specification---it must be followed by +two-byte values of xoff, yoff, width, height, deltax */ +#define DOWNLOAD_CHARACTER(nbytes) OUTF("\033\050s%dW",(nbytes)+16) + +/* End raster graphics */ +#define END_RASTER_GRAPHICS OUTS("\033*rB") + +/* Map characters */ +#define MAP_CHAR(c)\ + (((c) < 33) ? ((c) + 191) :\ + (((c) < 128) ? (c) :\ + (((c) < 160) ? ((c) + 96) : (c)))) + +#define BAD_CHAR(c) ((c) > 255) + +/* Move absolute to (x,y), page origin in lower left corner */ +#define MOVETO(x,y) OUTF2("\033*p%dx%dY",(x),YSIZE-(y)) + +/* Move absolute to (x,current y), page origin in lower left corner */ +#define MOVEX(x) OUTF("\033*p%dX",(x)) + +/* Move absolute to (current x,y), page origin in lower left corner */ +#define MOVEY(y) OUTF("\033*p%dY",YSIZE-(y)) + +/* Output TeX character number with mapping to HP LaserJet Plus number */ +#define OUT_CHAR(c) OUTC(MAP_CHAR(c)) + +/* Output a 16-bit binary number in two bytes */ +#define OUT16(n) {OUTC((n)>>8); OUTC((n));} + +/* Eject a page from the printer--this is the last command on each page */ +#define PAGEEJECT OUTC('\f') + +/* Reset printer at job start. E is global reset which clears +everything but permanent fonts, which we do not use. &l0E resets +left margin to 0. &a0L resets top margin to 0. Without these, +default margins are supplied which lie inside page. Unfortunately, +these do not permit negative values, so we have to further correct the +origin with (XORIGIN, YORIGIN) defined above; these bias (lmargin, +tmargin) set in dviinit(). */ +#define RESET_PRINTER OUTS("\033E\033&lE\033&aL") +#define RESET_PRINTER_END /* OUTS("\033E") */ + +/* Move relative by (delx,dely) from current point */ +#define RMOVETO(delx,dely) {\ +if ((delx) == 0)\ + RMOVEY(dely)\ +else if ((dely) == 0)\ + RMOVEX(delx)\ +else\ + OUTF2("\033*p%c%dx%c%dY",\ + ((delx) > 0 ? '+' : '-'),ABS(delx),\ + ((dely) < 0 ? '+' : '-'),ABS(dely));\ +} + +/* Move relative to (delx+currentx,currenty), page origin in lower left +corner */ +#define RMOVEX(delx) {\ +if ((delx) > 0)\ + OUTF("\033*p+%dX",(delx));\ +else if ((delx) < 0)\ + OUTF("\033*p%dX",(delx));\ +} + +/* Move relative to (currentx,dely+currenty), page origin in lower left +corner */ +#define RMOVEY(dely) {\ +if ((dely) > 0)\ + OUTF("\033*p%dY",-(dely));\ +else if ((dely) < 0)\ + OUTF("\033*p+%dY",-(dely));\ +} + +/* Round a POSITIVE floating-point value to the nearest integer */ +#define ROUND(x) ((int)(x + 0.5)) + +/* Output a new rule at TeX position (x,y). The device coordinates will +be changed on completion. The rule origin is the TeX convention of the +lower-left corner, while the LaserJet Plus uses the upper-left corner. +*/ +#define RULE(x,y,width,height) {\ + MOVETO(x,(y)+height-1);\ + OUTF2("\033*c%da%dbP",width,height);\ +} + +/* Set rule of same size as previous one at TeX position (x,y). The +device coordinates will be changed on completion. */ +#define RULE2(x,y) {\ + MOVETO(x,(y)+rule_height-1);\ + OUTS("\033*cP");\ +} + +/* Set the character in preparation for a DOWNLOAD_CHARACTER */ +#define SET_CHAR_CODE(ch)\ + OUTF("\033*c%dE",MAP_CHAR(ch)); + + +/* Set the number of copies of the current page (issue just before +PAGEEJECT) */ +#define SETCOPIES(n) OUTF("\033&l%dX",MAX(1,MIN(n,99))) + +/* Set the font number in preparation for a CREATE_FONT */ +#define SET_FONT_ID(fontnumber) OUTF("\033*c%dd4F",(fontnumber)); + +#define SET_CURRENT_FONT(fontnumber) OUTF("\033\050%dX",fontnumber); + + +#define TRANSFER_RASTER_GRAPHICS(nbytes) OUTF("\033*b%dW",(nbytes)); + +#define UNDEFINED_FONT 65535 /* fonts are numbered 0,1,2,... */ + +/* In order to handle the MAXPAGEFONTS restriction, we keep a set of the +fonts in use, accessing them with these two functions. If a later +printer model increases MAXFONTS beyond 32, we can transparently change +to another representation, but for now, we use an efficient bit +set implementation. */ + +UNSIGN32 page_members; /* the bit set for current page */ +#define ADD_MEMBER(set,member) {set |= (1 << (member));} +#define IS_MEMBER(set,member) (set & (1 << (member))) +#define EMPTY_SET(set) {set = 0L;} + + /* BIGCHAR() is used in setchar() and setstr(). BIGCHAR() + is TRUE if the character is too big to send as a downloaded font, or + if more than MAXPAGEFONTS have been used on this page, and the + required font's font_number is not in the page_members set, or if + more the font is not in the first MAXFONTS fonts. */ + +#define BIGCHAR(t) (((t->wp > (COORDINATE)size_limit) ||\ +(t->hp > (COORDINATE)size_limit)) || (fontptr->font_number >= MAXFONTS) ||\ +(t->istoobig)) + +#include "main.h" +void checkchldd(); +#include "abortrun.h" +#include "actfact.h" +#include "alldone.h" + +/*-->bopact*/ +/**********************************************************************/ +/******************************* bopact *******************************/ +/**********************************************************************/ + +void +bopact() /* beginning of page action */ +{ + page_fonts = 0; /* no fonts used on this page yet */ + EMPTY_SET(page_members); + + rule_height = -1; /* reset last rule parameters */ + rule_width = -1; + + str_ycp = -1; /* reset string y coordinate */ +} + +#include "chargf.h" +#include "charpk.h" +#include "charpxl.h" +void makefont1(); +/*-->checkchldd*/ +/**********************************************************************/ +/**************************** checkchldd ******************************/ +/**********************************************************************/ +void +checkchldd(c) +register BYTE c; +{ + register struct char_entry *tcharptr; /* temporary char_entry pointer */ + if (fontptr->font_number == UNDEFINED_FONT) + (void)makefont1(); + tcharptr = &(fontptr->ch[c]); + + if ((BIGCHAR(tcharptr)) || (BAD_CHAR(c))) + { /* we shall need to send a graphics bitmap */ + tcharptr->isloaded = FALSE; + } + else { + if (tcharptr->isloaded == FALSE) + { + fontptr->used_chars++; + tcharptr->isloaded = TRUE; + } + } +} + + + +#include "checkpage.h" +#include "clrrow.h" +#include "dbgopen.h" + +/*-->devinit*/ +/**********************************************************************/ +/****************************** devinit *******************************/ +/**********************************************************************/ + +void +devinit(argc,argv) /* initialize device */ +int argc; +char *argv[]; +{ + RESET_PRINTER; /* printer reset */ + DELETE_ALL_FONTS; /* delete all downloaded fonts */ + font_count = 0; /* no font numbers are assigned yet */ + pf = -1; +} + +/*-->devterm*/ +/**********************************************************************/ +/****************************** devterm *******************************/ +/**********************************************************************/ + +void +devterm() /* terminate device */ +{ + RESET_PRINTER_END; /* printer reset */ +} + +#include "dvifile_p.h" +#include "dviinit.h" +#include "dviterm.h" + +/*-->eopact*/ +/**********************************************************************/ +/******************************* eopact *******************************/ +/**********************************************************************/ + +void +eopact() /* end of page action */ +{ + if (copies > 1) + SETCOPIES(copies); + PAGEEJECT; +} + +#include "f20open.h" +#include "fatal.h" + +/*-->fillrect*/ +/**********************************************************************/ +/****************************** fillrect ******************************/ +/**********************************************************************/ + +void +fillrect(x,y,width,height) +COORDINATE x,y,width,height; /* lower left corner, size */ + +/*********************************************************************** +With the page origin (0,0) at the lower-left corner, draw a filled +rectangle at (x,y). + +For most TeX uses, rules are uncommon, and little optimization is +possible. However, for the LaTeX Bezier option, curves are simulated by +many small rules (typically 2 x 2) separated by positioning commands. +By remembering the size of the last rule set, we can test for the +occurrence of repeated rules of the same size, and reduce the output by +omitting the rule sizes. The last rule parameters are reset by the +begin-page action in prtpage(), so they do not carry across pages. + +It is not possible to use relative, instead of absolute, moves in these +sequences, without stacking rules for the whole page, because each rule +is separated in the DVI file by push, pop, and positioning commands, +making for an uncertain correspondence between internal (xcp,ycp) +pixel page coordinates and external device coordinates. + +The last string y coordinate, str_ycp, must be reset here to force any +later setstring() to reissue new absolute positioning commands. +***********************************************************************/ + +{ + str_ycp = -1; /* invalidate string y coordinate */ + + if ((height != rule_height) || (width != rule_width)) + { + RULE(x,y,width,height); + rule_width = width; /* save current rule parameters */ + rule_height = height; + } + else /* same size rule again */ + RULE2(x,y); +} + +#include "findpost.h" +#include "fixpos.h" +#include "fontfile.h" +#include "fontsub.h" +#include "getbytes.h" +#include "getfntdf.h" +#include "getpgtab.h" +#include "inch.h" +#include "initglob.h" + +/*-->loadbmap*/ +/**********************************************************************/ +/****************************** loadbmap ******************************/ +/**********************************************************************/ + +void +loadbmap(c) /* load big character as raster bitmap */ +register BYTE c; +{ + register struct char_entry *tcharptr; /* temporary char_entry pointer */ + void (*charyy)(); /* subterfuge to get around PCC-20 bug */ + + if (fontptr != pfontptr) + (void)openfont(fontptr->n); + if (fontfp == (FILE *)NULL) /* do nothing if no font file */ + return; + + tcharptr = &(fontptr->ch[c]); + + moveto(hh - tcharptr->xoffp,YSIZE-vv+tcharptr->yoffp); + + MOVETO(xcp,ycp); + BEGIN_RASTER_GRAPHICS; + + /* Bug fix: PCC-20 otherwise jumps to charxx instead of *charxx */ + charyy = fontptr->charxx; + (void)(*charyy)(c,outraster); /* load rasters into device */ + + END_RASTER_GRAPHICS; + str_ycp = -1; /* invalidate string y coordinate */ +} + +/*-->loadchar*/ +/**********************************************************************/ +/****************************** loadchar ******************************/ +/**********************************************************************/ + +void +loadchar(c,pc) +register BYTE c; +BYTE pc; +{ + void (*charyy)(); /* subterfuge to get around PCC-20 bug */ + register struct char_entry *tcharptr; /* temporary char_entry pointer */ + COORDINATE nbytes; /* number of bytes per row */ + float temp; + INT16 ntemp; + + if ((c < FIRSTPXLCHAR) || (LASTPXLCHAR < c)) /* check character range */ + return; + + tcharptr = &(fontptr->ch[c]); + + if (!VISIBLE(tcharptr)) + return; /* do nothing for invisible fonts */ + + if (fontptr != pfontptr) + openfont(fontptr->n); + + if (fontfp == (FILE *)NULL) /* do nothing if no font file */ + return; + + (void)clearerr(plotfp); + + tcharptr->isloaded = TRUE; + + SET_CHAR_CODE(pc); + + /* Number of bytes in bitmap, possibly reduced because of LaserJet Plus */ + /* limits. Large characters really need to be handled as bitmaps */ + /* instead of as downloaded characters. */ + + nbytes = ((tcharptr->wp) + 7) >> 3; /* wp div 8 */ + DOWNLOAD_CHARACTER(MIN(16,nbytes)*MIN(255,(tcharptr->hp))); + + OUTC(4); /* 4 0 14 1 is fixed sequence */ + OUTC(0); + + OUTC(14); + OUTC(1); + + OUTC(0); /* orientation = 0 ==> portrait */ + OUTC(0); + + /* Apologies for the temporary variables; the Sun OS 3.2 cc could + not compile the original expressions. */ + ntemp = MIN(-(tcharptr->xoffp),127); + ntemp = MAX(-128,ntemp); + OUT16(ntemp); + ntemp = MIN(tcharptr->yoffp,127); + ntemp = MAX(-128,ntemp); + OUT16(ntemp); + ntemp = MIN(128,tcharptr->wp); + OUT16(ntemp); + ntemp = MIN(255,tcharptr->hp); + OUT16(ntemp); + temp = (float)(tcharptr->tfmw); + temp = temp*conv; + ntemp = ROUND(temp); + OUT16(4*ntemp); /* delta x to nearest dot */ + + /* Bug fix: PCC-20 otherwise jumps to charxx instead of *charxx */ + charyy = fontptr->charxx; + (void)(*charyy)(c,outrow); /* output rasters */ + + if (DISKFULL(plotfp)) + (void)fatal("loadchar(): Output error -- disk storage probably full"); +} + +/*-->makefont1*/ +/**********************************************************************/ +/***************************** makefont1 *******************************/ +/**********************************************************************/ + +void +makefont1() +{ + register UNSIGN16 the_char; /* loop index */ + INT16 j; /* loop index */ + /* parameters of largest cell */ + COORDINATE cell_above; /* dots above baseline */ + COORDINATE cell_below; /* dots below baseline */ + COORDINATE char_below; /* dots below baseline */ + COORDINATE cell_height; /* total height */ + COORDINATE cell_left; /* dots left of character cell */ + COORDINATE cell_width; /* total width */ + COORDINATE cell_baseline; /* in 0..(cell_height-1) */ + + /******************************************************************* + Each LaserJet Plus font must be assigned a unique number in + 0..32767, and only 32 fonts can be active at one time. We keep a + table of font pointers for this purpose and store the corresponding + table index in font_number. Each time a new font is encountered, we + increment font_count and store it in that font's font_number. TeX + produces a unique font number as well, and TeX82 only uses values in + the range 0..255. The DVI file supports 32-bit font numbers, so it + is better to generate our own, because someday other programs may + produce DVI files too. + + If fonts are freed dynamically, the table entry must be invalidated + and a command sent to the printer to delete that font. At present, + font freeing happens only in dviterm() at the close of processing of + a single DVI file. A subsequent DVI file processed will result in + the invocation of devinit() which resets font_count to 0. It is not + possible to avoid downloading some fonts for subsequent files, + because we have no control over what order they are printed in, and + each output file must therefore be regarded as independent. + + In order to deal with the limit of MAXFONTS active fonts in the + LaserJet Plus, we have two choices. The first and best and most + difficult, is to entirely discard the matching of TeX fonts with + LaserJet Plus fonts---new characters would simply be assigned to the + next available entry in the current open font. The second choice is + less satisfactory---when MAXFONTS fonts have been downloaded, we + delete the last of them and reset the isloaded flags for all the + characters in that font. The Plus also allows deletion of + individual characters, so in the first case, we could delete + little-used characters to make room in the font tables on the + device; we do not use that approach here. One problem is that font + metrics must be assigned which match the largest character in the + font, so individual character deletion and later re-use of the + vacated slot is not in general possible. A second problem is the + bizarre behavior of the LaserJet Plus in response to a font + deletion--the current page is printed, and the all text following + the delete font command will appear on the next page. + + There is a silly restriction that only MAXPAGEFONTS fonts can be + used on a single page, where MAXPAGEFONTS < MAXFONTS. We handle + this by keeping a count, page_fonts, of the number of fonts in use + on the current page, and whenever a font is requested whose + font_number (0,1,...) reaches or exceeds MAXPAGEFONTS, then + setchar() and setstr() will not download the character as a font + character, but instead will set it as a raster bitmap, in the same + fashion that large characters are handled. + + We handle the font deletion misfeature by just not using it. If a + document requires more than MAXFONTS fonts, then the characters for + those additional fonts are sent as raster bitmaps, instead of + downloaded characters. + + These two actions completely remove any limitation on the size or + number of fonts in the LaserJet Plus. + + As an optimization to reduce the effort of font table searching, + each time a font is requested which has already been loaded, we move + that font to the front of font_table[]; the least popular fonts will + therefore be the ones that get deleted. The least recently used + priority mechanism is widely used in operating systems for buffer + management; the overhead of list rearrangement here is acceptable, + because font changing occurs relatively infrequently, compared to + character setting. + + <------wp------> + ^ ................ + | ................ + | ................ + | ................ + | ................ + | ................ + | ................ + hp ................ + | ................ + | ................ + | ................ + | .....o.......... <-- character reference point (xcp,ycp) at "o" + | ................ ^ + | ................ | + | ................ |--- (hp - yoffp - 1) + | ................ | + v +............... v <-- (xcorner,ycorner) at "+" + <---> + | + | + xoffp (negative if (xcp,ycp) left of bitmap) + + + The LaserJet Plus font mechanism requires the declaration of cell + height, width, and baseline in the CreateFont command. Experiments + show that these must be large enough to incorporate the maximum + extent above and below the baseline of any characters in the font. + The metric correspondences are as follows: + + ----- ------------- + TeX LaserJet Plus + ----- ------------- + xoffp -(left offset) + yoffp top offset + max(yoffp) + 1 cell baseline + max(wp) cell width + max(yoffp) + + max(hp-yoff,yoff-hp) + 1 cell height + + + *******************************************************************/ + + for (j = 0; j < (INT16)font_count; ++j) + if (font_table[j] == fontptr) /* then font already known */ + { + for (; j > 0; --j) /* LRU: move find to front */ + font_table[j] = font_table[j-1]; + font_table[0] = fontptr; + return; /* nothing more to do */ + } + + if (font_count >= MAXFONTS) /* then no more fonts can be downloaded */ + { + /* set up so BIGCHAR() recognizes the font as not downloadable + and sends bitmaps instead */ + fontptr->font_number = font_count; + for (the_char = FIRSTPXLCHAR; the_char <= LASTPXLCHAR; ++the_char) + { + fontptr->ch[the_char].isloaded = FALSE; + fontptr->ch[the_char].istoobig = TRUE; + } + return; + } + +/* new font */ + fontptr->font_number = font_count; + font_table[font_count] = fontptr; + font_count++; /* count the next font */ + fontptr->used_chars = 0; + fontptr->assigned_chars = 0; + + cell_above = 0; + cell_below = 0; + cell_left = 0; + cell_width = 0; + + for (the_char = FIRSTPXLCHAR; the_char <= LASTPXLCHAR; ++the_char) + { + char_below = fontptr->ch[the_char].yoffp - + fontptr->ch[the_char].hp; + char_below = ABS(char_below); + cell_height = 1 + fontptr->ch[the_char].yoffp + char_below; + fontptr->ch[the_char].isloaded = FALSE; + fontptr->ch[the_char].lj_char = -1; + fontptr->ch[the_char].lj_font = -1; + fontptr->ch[the_char].istoobig = (BOOLEAN)( + !IN(-128,-fontptr->ch[the_char].xoffp,127) || + !IN(-128, fontptr->ch[the_char].yoffp,127) || + !IN(1,fontptr->ch[the_char].wp,255) || + !IN(1,cell_height,255)); + } + +} +/*-->makefont*/ +/**********************************************************************/ +/***************************** makefont *******************************/ +/**********************************************************************/ + +void +makefont(pptr,n_slots) +struct printer_font *pptr; +int n_slots; +{ + register UNSIGN16 the_char; /* loop index */ + register the_slot; + INT16 j; /* loop index */ + /* parameters of largest cell */ + COORDINATE cell_above; /* dots above baseline */ + COORDINATE cell_below; /* dots below baseline */ + COORDINATE char_below; /* dots below baseline */ + COORDINATE cell_height; /* total height */ + COORDINATE cell_left; /* dots left of character cell */ + COORDINATE cell_width; /* total width */ + COORDINATE cell_baseline; /* in 0..(cell_height-1) */ + + + + cell_above = 0; + cell_below = 0; + cell_left = 0; + cell_width = 0; + + for (the_slot = 0; the_slot < n_slots; ++the_slot) + { + fontptr = pptr->char_slots[the_slot].tex_font; + the_char = pptr->char_slots[the_slot].tex_char; + char_below = fontptr->ch[the_char].yoffp - + fontptr->ch[the_char].hp; + char_below = ABS(char_below); + cell_height = 1 + fontptr->ch[the_char].yoffp + char_below; + fontptr->ch[the_char].istoobig = (BOOLEAN)( + !IN(-128,-fontptr->ch[the_char].xoffp,127) || + !IN(-128, fontptr->ch[the_char].yoffp,127) || + !IN(1,fontptr->ch[the_char].wp,255) || + !IN(1,cell_height,255)); + cell_above = MAX(cell_above,fontptr->ch[the_char].yoffp); + cell_below = MAX(cell_below,char_below); + cell_left = MAX(cell_left,-fontptr->ch[the_char].xoffp); + cell_width = MAX(cell_width,fontptr->ch[the_char].wp); + } + cell_baseline = cell_above + 1; + cell_height = (cell_above + cell_below) + 1; + + if ((cell_width > 255) || (cell_height > 255)) + { /* don't worry, big characters are handled specially later */ + cell_height = MIN(cell_height,255); + cell_width = MIN(cell_width,255); + } + cell_width = MAX(1,cell_width); + + SET_FONT_ID(pf); + + CREATE_FONT; + + OUTC(0); + OUTC(26); /* descriptor length */ + + OUTC(0); /* always 0 */ + OUTC(1); /* 8-bit font (for more than 95 characters) */ + + OUT16(0); /* always 0 */ + + OUT16(cell_baseline); /* baseline position (in 0..cell_height-1)*/ + + OUT16(cell_width); /* cell width */ + + OUT16(cell_height); /* cell height */ + + OUTC(0); /* orientation = 0 ==> portrait */ + OUTC(1); /* spacing = 1 ==> proportional */ + + OUT16(0); /* symbol set (arbitrary) */ + + OUT16(2); /* pitch (arbitrary in 2..1260) */ + + OUT16(cell_height); /* font height (arbitrary in 0..10922) */ + + OUT16(0); /* always 0 */ + + OUTC(0); /* always 0 */ + OUTC(0); /* style = 0 ==> upright */ + + OUTC(0); /* stroke weight = 0 ==> normal */ + OUTC(0); /* typeface = 0 (arbitrary) */ +} + +#include "movedown.h" +#include "moveover.h" +#include "moveto.h" + +/*-->newfont*/ +/**********************************************************************/ +/****************************** newfont *******************************/ +/**********************************************************************/ + +void +newfont() +{ + /******************************************************************* + Creating fonts immediately (usually at postamble read time, before + any pages have been printed), would exhaust the LaserJet Plus font + supply in a document with more than 32 fonts, requiring many fonts + to be sent as bitmaps, instead of as downloaded characters. If only + a few pages were selected for printing, it is unlikely that more + than 32 would actually be needed. With character bitmaps, the + output file is much larger than when downloaded characters are used, + and there is a likelihood of raising printer error code 21 (page too + complex to process), at least on the LaserJet Plus, which has rather + limited internal memory (about 512Kb). The HPLJ Series II can have + up to 4.5Mb of memory, and possibly would eliminate this error + condition. + + Instead, we simply mark the font as currently undefined. When it is + first referenced, setfont() will call makefont() to actually create + it in the printer. + *******************************************************************/ + + fontptr->font_number = UNDEFINED_FONT; +} + +#include "nosignex.h" +#include "openfont.h" +#include "option.h" + +/*-->outraster*/ +/**********************************************************************/ +/***************************** outraster ******************************/ +/**********************************************************************/ + +void +outraster(c,yoff)/* print single raster line in bitmap graphics mode */ +BYTE c; /* current character value */ +UNSIGN16 yoff; /* offset from top row (0,1,...,hp-1) */ +{ + UNSIGN16 bytes_per_row; /* number of raster bytes to copy */ + register UNSIGN16 k; /* loop index */ + register UNSIGN32 *p; /* pointer into img_row[] */ + struct char_entry *tcharptr;/* temporary char_entry pointer */ + register BYTE the_byte; /* unpacked raster byte */ + + tcharptr = &(fontptr->ch[c]);/* assume check for valid c has been done */ + bytes_per_row = (UNSIGN16)((tcharptr->wp) + 7) >> 3; /* wp div 8 */ + p = img_row; /* we step pointer p along img_row[] */ + + TRANSFER_RASTER_GRAPHICS(bytes_per_row); + + for (k = bytes_per_row; k > 0; ++p) + { + the_byte = (BYTE)((*p) >> 24); + OUTC(the_byte); + if ((--k) <= 0) + break; + + the_byte = (BYTE)((*p) >> 16); + OUTC(the_byte); + if ((--k) <= 0) + break; + + the_byte = (BYTE)((*p) >> 8); + OUTC(the_byte); + if ((--k) <= 0) + break; + + the_byte = (BYTE)(*p); + OUTC(the_byte); + if ((--k) <= 0) + break; + } +} + +/*-->outrow*/ +/**********************************************************************/ +/******************************* outrow *******************************/ +/**********************************************************************/ + +void +outrow(c,yoff) /* copy img_row[] into rasters[] if allocated, else no-op */ +BYTE c; /* current character value */ +UNSIGN16 yoff; /* offset from top row (0,1,...,hp-1) */ +{ + UNSIGN16 bytes_per_row; /* number of raster bytes to copy */ + register UNSIGN16 k; /* loop index */ + register UNSIGN32 *p; /* pointer into img_row[] */ + struct char_entry *tcharptr;/* temporary char_entry pointer */ + register BYTE the_byte; /* unpacked raster byte */ + + if (yoff > 255) /* LaserJet Plus cannot handle big characters */ + return; + + tcharptr = &(fontptr->ch[c]);/* assume check for valid c has been done */ + bytes_per_row = (UNSIGN16)((tcharptr->wp) + 7) >> 3; /* wp div 8 */ + bytes_per_row = MIN(16,bytes_per_row); /* limited to 128 bits/row */ + p = img_row; /* we step pointer p along img_row[] */ + + for (k = bytes_per_row; k > 0; ++p) + { + the_byte = (BYTE)((*p) >> 24); + OUTC(the_byte); + if ((--k) <= 0) + break; + + the_byte = (BYTE)((*p) >> 16); + OUTC(the_byte); + if ((--k) <= 0) + break; + + the_byte = (BYTE)((*p) >> 8); + OUTC(the_byte); + if ((--k) <= 0) + break; + + the_byte = (BYTE)(*p); + OUTC(the_byte); + if ((--k) <= 0) + break; + } +} + +#include "prtpage_p.h" +#include "readfont.h" +#include "readgf.h" +#include "readpk.h" +#include "readpost.h" +#include "readpxl.h" +#include "reldfont.h" +#include "rulepxl.h" + +/*-->setchar*/ +/**********************************************************************/ +/****************************** setchar *******************************/ +/**********************************************************************/ + +void +setchar(c, update_h) +register BYTE c; +register BOOLEAN update_h; +{ + register struct char_entry *tcharptr; /* temporary char_entry pointer */ + + /* ONPAGE() is used here and in setstr(). */ + +#define ONPAGE(t) (((hh - t->xoffp + t->pxlw) <= XSIZE) \ + && (hh >= 0)\ + && (vv <= YSIZE)\ + && (vv >= 0)) + + if (DBGOPT(DBG_SET_TEXT)) + { + (void)fprintf(stderr,"setchar('"); + if (isprint(c)) + (void)putc(c,stderr); + else + (void)fprintf(stderr,"\\%03o",(int)c); + (void)fprintf(stderr,"'<%d>) (hh,vv) = (%ld,%ld) font name <%s>", + (int)c, (long)hh, (long)vv, fontptr->n); + NEWLINE(stderr); + } + + tcharptr = &(fontptr->ch[c]); + + moveto(hh,(COORDINATE)(YSIZE-vv)); + if (ONPAGE(tcharptr)) + { /* character fits entirely on page */ + if (tcharptr->lj_font != pf) + { + (void)setfont(tcharptr->lj_font); + } + + if (VISIBLE(tcharptr)) + { + if ((BIGCHAR(tcharptr)) || (BAD_CHAR(c))) + loadbmap(c); + else + { + if (ycp != str_ycp) + { + MOVETO(xcp,ycp); + str_ycp = ycp; + } + else + MOVEX(xcp); + + c = tcharptr->lj_char; + OUT_CHAR(c); + } + } + } + else if (DBGOPT(DBG_OFF_PAGE) && !quiet) + { /* character is off page -- discard it */ + (void)fprintf(stderr, + "setchar(): Char %c [10#%3d 8#%03o 16#%02x] off page.", + isprint(c) ? c : '?',c,c,c); + NEWLINE(stderr); + } + + if (update_h) + { + h += (INT32)tcharptr->tfmw; + hh += (COORDINATE)tcharptr->pxlw; + hh = fixpos(hh-lmargin,h,conv) + lmargin; + } +} + +#include "setfntnm.h" + +/*-->setfont*/ +/**********************************************************************/ +/****************************** setfont *******************************/ +/**********************************************************************/ + +void +setfont(font) +{ + pf = font; + SET_CURRENT_FONT(pf); +} + +#include "setrule.h" + +/*-->setstr*/ +/**********************************************************************/ +/******************************* setstr *******************************/ +/**********************************************************************/ + +void +setstr(c) +register BYTE c; +{ + register struct char_entry *tcharptr; /* temporary char_entry pointer */ + register BOOLEAN inside; + COORDINATE hh_last; /* hh before call to fixpos() */ + register UNSIGN16 k; /* loop index */ + UNSIGN16 nstr; /* number of characters in str[] */ + BYTE str[MAXSTR+1]; /* string accumulator */ + BOOLEAN truncated; /* off-page string truncation flag */ + + /******************************************************************* + Set a sequence of characters in SETC_000 .. SETC_127 with a minimal + number of LaserJet Plus commands. These sequences tend to occur in + long clumps in a DVI file, and setting them together whenever + possible substantially decreases the overhead and the size of the + output file. A sequence can be set as a single string if + + * TeX and LaserJet Plus coordinates of each character agree (may + not be true, since device coordinates are in multiples of 1/4 + pixel; violation of this requirement can be detected if + fixpos() changes hh, or if ycp != str_ycp), AND + + * each character is in the same font (this will always be true + in a sequence from a DVI file), AND +[this needs looking at in PP8 version] + + * each character fits within the page boundaries, AND + + * each character definition is already loaded, AND + + * each character is from a visible font, AND + + * each character bitmap extent is smaller than the size_limit + (which is used to enable discarding large characters after + each use in order to conserve virtual memory storage on the + output device). + + Whenever any of these conditions does not hold, any string already + output is terminated, and a new one begun. + + Two output optimizations are implemented here. First, up to MAXSTR + (in practice more than enough) characters are collected in str[], + and any that require downloading are handled. Then the entire + string is set at once, subject to the above limitations. Second, by + recording the vertical page coordinate, ycp, in the global variable + str_ycp (reset in prtpage() at begin-page processing), it is + possible to avoid outputting y coordinates unnecessarily, since a + single line of text will generally result in many calls to this + function. + *******************************************************************/ + +#define BEGINSTRING {inside = TRUE;\ + if (ycp != str_ycp)\ + {\ + MOVETO(xcp,ycp);\ + str_ycp = ycp;\ + }\ + else\ + MOVEX(xcp);} + +#define ENDSTRING {inside = FALSE;} + +#define OFF_PAGE (-1) /* off-page coordinate value */ + + tcharptr = &(fontptr->ch[c]); + + if (tcharptr->lj_font != pf) /* output new font selection */ + { + (void)setfont(tcharptr->lj_font); + } + + inside = FALSE; + truncated = FALSE; + + nstr = 0; + while ((SETC_000 <= c) && (c <= SETC_127) && (nstr < MAXSTR)) + { /* loop over character sequence */ + str[nstr++] = c; /* save string character */ + + c = (BYTE)nosignex(dvifp,(BYTE)1); + } + + /* put back character which terminated the loop */ + (void)UNGETC((int)(c),dvifp); + + if (DBGOPT(DBG_SET_TEXT)) + { + (void)fprintf(stderr,"setstr(\""); + for (k = 0; k < nstr; ++k) + { + c = str[k]; + if (isprint(c)) + (void)putc(c,stderr); + else + (void)fprintf(stderr,"\\%03o",(int)c); + } + (void)fprintf(stderr,"\") (hh,vv) = (%ld,%ld) font name <%s>", + (long)hh, (long)vv, fontptr->n); + NEWLINE(stderr); + } + + for (k = 0; k < nstr; ++k) + { /* loop over character sequence */ + c = str[k]; + tcharptr = &(fontptr->ch[c]); + moveto(hh,YSIZE-vv); + + if (ONPAGE(tcharptr) && VISIBLE(tcharptr)) + { /* character fits entirely on page and is visible */ + /* We must check first for a big character. The character */ + /* may have been downloaded on a previous page, but if it is */ + /* not in the page_members font set, we must send it again */ + /* as a bitmap instead. */ + if (BIGCHAR(tcharptr)) /* BAD_CHAR(c)) cannot be true here */ + { + if (inside) + ENDSTRING; /* finish any open string */ + loadbmap(c); + } + else if (tcharptr->lj_font != pf) + { + if (inside) + ENDSTRING; + } + else + { + if (!inside) + BEGINSTRING; + c = tcharptr->lj_char; + OUT_CHAR(c); + } + } + else /* character does not fit on page -- output */ + { /* current string and discard the character */ + truncated = TRUE; + if (inside) + ENDSTRING; + } + /* update horizontal positions in TFM and pixel units */ + h += (INT32)tcharptr->tfmw; + hh += (COORDINATE)tcharptr->pxlw; + hh_last = hh; + hh = fixpos(hh-lmargin,h,conv) + lmargin; + if (DBGOPT(DBG_POS_CHAR)) + { + (void)fprintf(stderr, + "[%03o] xcp = %d\tycp = %d\thh = %d\thh_last = %d\n", + c,xcp,ycp,hh,hh_last); + } + + /* If fixpos() changed position, we need new string next time */ + /* around. Actually, since the LaserJet Plus stores character */ + /* widths in units of 1/4 dot, we could compute coordinates at */ + /* four times the precision, but for now, we start a new string */ + /* each time we have one or more dots of error. */ + + if ((hh != hh_last) && inside) + ENDSTRING; + } + if (truncated && DBGOPT(DBG_OFF_PAGE) && !quiet) + { + (void)fprintf(stderr,"setstr(): Text ["); + for (k = 0; k < nstr; ++k) + (void)fprintf(stderr,isprint(str[k]) ? "%c" : "\\%03o",str[k]); + (void)fprintf(stderr,"] truncated at page boundaries."); + NEWLINE(stderr); + } + if (inside) /* finish last string */ + ENDSTRING; +} + +#include "signex.h" +#include "skgfspec.h" +#include "skipfont.h" +#include "skpkspec.h" +#include "special.h" +#include "strchr.h" +#include "strcm2.h" +#include "strid2.h" +#include "strrchr.h" +#include "tctos.h" +#include "usage.h" +#include "warning.h" diff --git a/dviware/kane/gblvars.h b/dviware/kane/gblvars.h new file mode 100644 index 0000000000..b880032d9f --- /dev/null +++ b/dviware/kane/gblvars.h @@ -0,0 +1,357 @@ + +Date: 20-MAR-1989 17:20:25 GMT +From: PHYOKANE@CS8700.UCG.IE +To: abbottp@ASTON.AC.UK +Subject: file gblvars.h +sender: hea"phyokane@cs8700.ucg.ie" + +/* -*-C-*- gblvars.h */ +/*-->gblvars*/ +/**********************************************************************/ +/****************************** gblvars *******************************/ +/**********************************************************************/ + +/**********************************************************************/ +/********************* General Global Variables *********************/ +/**********************************************************************/ + +char curpath[MAXFNAME]; /* current file area */ +char curext[MAXFNAME]; /* current file extension */ +char curname[MAXFNAME]; /* current file name */ + +UNSIGN16 debug_code; /* 0 for no debug output */ + +char dviname[MAXFNAME]; /* DVI filespec */ +char dvoname[MAXFNAME]; /* device output filespec */ + +char fontlist[MAXSTR]; /* FONTLIST environment string */ +char fontpath[MAXFNAME]; /* font directory path */ + +char helpcmd[MAXSTR]; /* where to look for help */ + +char message[MAXMSG]; /* for formatting error messages */ + +/*********************************************************************** +Magnification table for 144dpi, 200dpi, and 300dpi devices, computed +to 20 figures and sorted by magnitude. + + Column 1 Column 2 Column 3 +0.72*sqrt(1.2)**i sqrt(1.2)**I 1.5*sqrt(1.2)**I (I = -16,16) + +***********************************************************************/ + +static float mag_table[] = + { + 0.16744898601451165028, 0.18343117374303022733, 0.20093878321741398034, + 0.22011740849163627280, 0.23256803936137783874, 0.24112653986089677641, + 0.25476552262595201888, 0.26414089018996352736, 0.27908164723365340649, + 0.28935184783307613169, 0.30571862715114242265, 0.31696906822795623283, + 0.33489797668038408779, 0.34722221739969135802, 0.34885205904206675812, + 0.36686235258137090718, 0.38036288187354747940, 0.38214828393892802832, + 0.40187757201646090535, 0.41666666087962962963, 0.41862247085048010974, + 0.44023482309764508862, 0.45643545824825697527, 0.45857794072671363398, + 0.48225308641975308642, 0.49999999305555555556, 0.50234696502057613169, + 0.52828178771717410634, 0.54772254989790837033, 0.55029352887205636077, + 0.57870370370370370370, 0.59999999166666666667, 0.60281635802469135802, + 0.63393814526060892761, 0.65726705987749004440, 0.66035223464646763293, + 0.69444444444444444444, 0.71999999000000000000, 0.72337962962962962963, + 0.76072577431273071313, 0.78872047185298805327, 0.79242268157576115952, + 0.83333333333333333333, 0.86399998800000000000, 0.86805555555555555556, + 0.91287092917527685576, 0.94646456622358566393, 0.95090721789091339142, + 1.00000000000000000000, 1.03679998560000000000, 1.04166666666666666670, + 1.09544511501033222690, 1.13575747946830279670, 1.14108866146909606970, + 1.20000000000000000000, 1.24415998272000000000, 1.25000000000000000000, + 1.31453413801239867230, 1.36290897536196335610, 1.36930639376291528360, + 1.44000000000000000000, 1.49299197926400000000, 1.50000000000000000000, + 1.57744096561487840680, 1.63549077043435602730, 1.64316767251549834040, + 1.72800000000000000000, 1.79159037511680000000, 1.80000000000000000000, + 1.89292915873785408810, 1.96258892452122723270, 1.97180120701859800840, + 2.07360000000000000000, 2.14990845014016000000, 2.16000000000000000000, + 2.27151499048542490570, 2.35510670942547267930, 2.36616144842231761010, + 2.48832000000000000000, 2.57989014016819200000, 2.59200000000000000000, + 2.72581798858250988690, 2.82612805131056721510, 2.83939373810678113220, + 2.98598400000000000000, 3.09586816820183040000, 3.11040000000000000000, + 3.27098158629901186430, 3.40727248572813735860, 3.58318080000000000000, + 3.73248000000000000000, 3.92517790355881423710, 4.08872698287376483030, + 4.29981696000000000000, 4.47897600000000000000, 4.90647237944851779640, + 5.37477120000000000000, 5.88776685533822135560, 6.44972544000000000000 + }; + +INT16 mag_index; /* set by actfact */ + +#define MAGTABSIZE (sizeof(mag_table) / sizeof(float)) + +int g_errenc = 0; /* has an error been encountered? */ +char g_logname[MAXSTR]; /* name of log file, if created */ +BOOLEAN g_dolog = TRUE; /* allow log file creation */ +FILE *g_logfp = (FILE*)NULL; /* log file pointer (for errors) */ +char g_progname[MAXSTR]; /* program name */ + +FILE *plotfp = (FILE*)NULL; /* plot file pointer */ + +struct char_entry +{ /* character entry */ + COORDINATE wp, hp; /* width and height in pixels */ + COORDINATE xoffp, yoffp; /* x offset and y offset in pixels */ + long fontrp; /* font file raster pointer */ + UNSIGN32 tfmw; /* TFM width */ + INT32 dx, dy; /* character escapements */ + UNSIGN16 pxlw; /* pixel width == round(TFM width in */ + /* pixels for .PXL files, or */ + /* float(char_dx)/65536.0 for .GF and .PK */ + /* files) */ + INT16 refcount; /* reference count for memory management */ + UNSIGN32 *rasters; /* raster description (dynamically loaded) */ + +#if (HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2) + BOOLEAN isloaded; /* is the character already downloaded? */ + BOOLEAN font_switched; +#endif /* (HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2) */ + +#if HPJETPLUS + BOOLEAN istoobig; /* Too big (or too odd) to be loaded */ + UNSIGN16 lj_char; /* Position in printer font */ + UNSIGN16 lj_font ; /* Printer font where loaded */ +#endif + +#if CANON_A2 + BOOLEAN isknown; /* Character is known */ + BOOLEAN istoobig; /* Too big to be loaded */ +#endif + +#if BBNBITGRAPH + BOOLEAN istoobig; /* is the character too big for BitGraph? */ + BOOLEAN isloaded; /* is the character loaded in the BitGraph?*/ + INT16 bgfont, bgchar; /* BitGraph font and character */ +#endif /* BBNBITGRAPH */ + +}; + +struct font_entry +{ + struct font_entry *next; /* pointer to next font entry */ + void (*charxx)(); /* pointer to chargf(), charpk(), charpxl()*/ + FILE *font_file_id; /* file identifier (NULL if none) */ + INT32 k; /* font number */ + UNSIGN32 c; /* checksum */ + UNSIGN32 d; /* design size */ + UNSIGN32 s; /* scale factor */ + INT32 font_space; /* computed from FNT_DEF s parameter */ + UNSIGN32 font_mag; /* computed from FNT_DEF s and d parameters*/ + UNSIGN32 magnification; /* magnification read from PXL file */ + UNSIGN32 designsize; /* design size read from PXL file */ + UNSIGN32 hppp; /* horizontal pixels/point * 2**16 */ + UNSIGN32 vppp; /* vertical pixels/point * 2**16 */ + INT32 min_m; /* GF bounding box values */ + INT32 max_m; + INT32 min_n; + INT32 max_n; + +#if (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) + UNSIGN16 font_number; /* font number (0..32767) */ + INT32 used_chars; /* Number of chars used in this font */ + INT32 assigned_chars; /* Number of chars assigned to printer font */ +#endif /* (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */ + +#if CANON_A2 + COORDINATE cell_w; + COORDINATE cell_h; + COORDINATE cell_d; + UNSIGN16 nloaded; + UNSIGN32 storage; +#endif /* CANON_A2 */ + + BYTE font_type; /* GF, PK, or PXL font file */ + BYTE a; /* length of font area in n[] */ + BYTE l; /* length of font name in n[] */ + char n[MAXSTR]; /* font area and name */ + char name[MAXSTR]; /* full name of PXL file */ + struct char_entry ch[NPXLCHARS];/* character information */ +}; + +struct font_list +{ + FILE *font_id; /* file identifier */ + INT16 use_count; /* count of "opens" */ +}; + +struct printer_font +{ + INT16 baseline; + INT16 cell_width; + INT16 cell_height; + BOOLEAN orientation; + BOOLEAN prop_spaceing; + INT16 symbol_set; + INT16 pitch; + INT16 height; + BOOLEAN style; + INT16 typeface; + INT32 slots_free; + BOOLEAN toutched; + struct { + INT32 tex_char; /* TeX character for this printer character */ + struct font_entry *tex_font; /* TeX font for this character */ + } char_slots[190]; +} printer_fonts[32]; + +INT32 cache_size; /* record of how much character raster */ + /* is actually used */ +float conv; /* converts DVI units to pixels */ +UNSIGN16 copies; /* number of copies to print of each page */ +INT16 cur_page_number; /* sequential output page number in 1..N */ +INT16 cur_index; /* current index in page_ptr[] */ + +COORDINATE xcp,ycp; /* current position */ +UNSIGN32 den; /* denominator specified in preamble */ +FILE *dvifp = (FILE*)NULL; /* DVI file pointer */ +struct font_entry *fontptr; /* font_entry pointer */ +struct font_entry *hfontptr = (struct font_entry *)NULL; + /* head font_entry pointer */ + +#if (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) +UNSIGN16 font_count; /* used to assign unique font numbers */ +struct font_entry *font_table[MAXFONTS]; +#endif /* (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */ + +#if (HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2) +int pf; /* current printer font */ +BOOLEAN font_switched; /* TeX font has changed */ +#endif /* (HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2) */ + +INT16 gf_index, pk_index, pxl_index; + /* indexes into filelist[] in fontfile(); */ + /* they define the search order, and are */ + /* in initglob(). */ +UNSIGN32 gpower[33]; /* gpower[k] = 2**k-1 (k = 0..32) */ +INT32 h; /* current horizontal position */ +COORDINATE hh; /* current horizontal position in pixels */ + +#if HPLASERJET +INT16 hpres; /* output resolution (75, 100, 150, 300 dpi) */ +#endif /* HPLASERJET */ + +UNSIGN32 img_mask[32]; /* initialized at run-time so that bit k */ + /* (counting from high end) is one */ +UNSIGN32 img_row[(MAX_M - MIN_M + 1 + 31) >> 5]; + /* current character image row of bits */ +INT16 max_m, min_m, max_n, min_n; + /* current character matrix extents */ +UNSIGN16 img_words; /* number of words in use in img_row[] */ +float leftmargin; /* left margin in inches */ +COORDINATE lmargin; /* left margin offset in pixels */ +INT16 nopen; /* number of open PXL files */ +INT16 page_count; /* number of entries in page_ptr[] */ + +#if HPJETPLUS +INT16 page_fonts; /* count of fonts used on current page */ +#endif /* HPJETPLUS */ + +long page_ptr[MAXPAGE+1]; /* byte pointers to pages (reverse order) */ + +#if POSTSCRIPT +long page_loc[MAXPAGE+1]; /* byte pointers to output pages */ +INT32 page_tex[MAXPAGE+1]; /* TeX's \count0 page numbers */ +#endif /* POSTSCRIPT */ + +INT16 page_begin[MAXREQUEST+1], + page_end[MAXREQUEST+1], + page_step[MAXREQUEST+1]; /* explicit page range requests */ +INT16 npage; /* number of explicit page range requests */ +struct font_list font_files[MAXOPEN+1]; + /* list of open PXL file identifiers */ + +UNSIGN32 power[32]; /* power[k] = 1 << k */ + +#if POSTSCRIPT +BOOLEAN ps_vmbug; /* reload fonts on each page when TRUE */ +#endif /* POSTSCRIPT */ + +UNSIGN32 rightones[HOST_WORD_SIZE];/* bit masks */ + +#if (APPLEIMAGEWRITER | EPSON | DECLA75 | DECLN03PLUS) +BOOLEAN runlengthcode = FALSE; /* this is runtime option '-r' */ +#endif /* (APPLEIMAGEWRITER | EPSON | DECLA75 | DECLN03PLUS) */ + +#if (GOLDENDAWNGL100 | TOSHIBAP1351) +BOOLEAN runlengthcode = FALSE; /* this is runtime option '-r' */ +#endif /* (GOLDENDAWNGL100 | TOSHIBAP1351) */ + +UNSIGN32 runmag; /* runtime magnification */ +UNSIGN32 mag; /* magnification specified in preamble */ +UNSIGN32 num; /* numerator specified in preamble */ +struct font_entry *pfontptr = (struct font_entry *)NULL; + /* previous font_entry pointer */ +BOOLEAN preload = TRUE; /* preload the font descriptions? */ +FILE *fontfp = (FILE*)NULL; /* font file pointer */ + +BOOLEAN quiet = FALSE; /* suppress status display when TRUE */ + +BOOLEAN backwards = FALSE; /* print in backwards order */ + +#if (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) +COORDINATE rule_height; /* parameters of last rule set */ +COORDINATE rule_width; +COORDINATE str_ycp; /* last string ycp value */ +UNSIGN16 size_limit; /* character size limit in pixels -- larger */ + /* characters are downloaded each time they */ + /* are required to avoid PostScript ROM bugs */ +#endif /* (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */ + +#if (BSD42 | OS_TOPS20) +BOOLEAN spool_output = FALSE; /* offer to send output to spooler */ +#endif /* (BSD42 | OS_TOPS20) */ + +char subpath[MAXFNAME]; /* font substitution file path */ +char subname[MAXFNAME]; /* font substitution file name field */ +char subext[MAXFNAME]; /* font substitution file extension field */ +char subfile[MAXFNAME]; /* font substitution filename */ + +INT32 tex_counter[10]; /* TeX c0..c9 counters on current page */ +float topmargin; /* top margin in inches */ +COORDINATE tmargin; /* top margin offset in pixels */ + +INT32 v; /* current vertical position */ + +#if VIRTUAL_FONTS +BOOLEAN virt_font; /* virtual font cache flag */ +struct virt_data + { + int cnt; + char *ptr; + char *base; + }; +struct virt_data virt_save[_NFILE];/* space for saving old FILE values */ +#endif /* VIRTUAL_FONTS */ + +COORDINATE vv; /* current vertical position in pixels */ + +#if BBNBITGRAPH +struct char_entry *bgcp[NBGFONTS+(NBGFONTS+2)/3][NPXLCHARS]; + /* Pointer to corresponding char_entry for this BitGraph font */ + /* and character. These are used to set the char_entry's */ + /* status to "not loaded" when we have to reuse the BitGraph */ + /* character. The array is cleared initially in devinit(). */ + +INT16 fullfont = 0; /* full font to load in BitGraph */ +BOOLEAN g_interactive=TRUE; /* is the program running interactively */ + /* (i.e., standard output not redirected)? */ +INT16 partchar = FIRSTBGCHAR; /* partial font character to load in BitGraph*/ +INT16 partfont = NBGFONTS; /* partial font to load in BitGraph */ +INT16 pbghpos; /* previous BitGraph horizontal position */ +INT16 pbgvpos; /* previous BitGraph vertical position */ +INT16 pbgf = -1; /* previous BitGraph font */ +COORDINATE xdiff; /* x difference */ +COORDINATE xscreen; /* x screen adjustment */ +COORDINATE ydiff; /* y difference */ +COORDINATE yscreen; /* y screen adjustment */ +long cpagep; /* pointer to current page in DVI file */ +long ppagep; /* pointer to previous page in DVI file */ + +#if OS_TOPS20 +#define jfn_plotfp (jfnof(fileno(plotfp))) + +int bg_length,bg_width,bg_1ccoc,bg_2ccoc,bg_modeword,bg_sysmsg; +#endif /* OS_TOPS20 */ + +#endif /* BBNBITGRAPH */ diff --git a/dviware/kane/prtpage_p.h b/dviware/kane/prtpage_p.h new file mode 100644 index 0000000000..7273769fe8 --- /dev/null +++ b/dviware/kane/prtpage_p.h @@ -0,0 +1,307 @@ + +Date: 20-MAR-1989 17:20:43 GMT +From: PHYOKANE@CS8700.UCG.IE +To: abbottp@ASTON.AC.UK +Subject: file prtpage_p.h +sender: hea"phyokane@cs8700.ucg.ie" + +/* -*-C-*- prtpage.h */ +/*-->prtpage*/ +/**********************************************************************/ +/****************************** prtpage *******************************/ +/**********************************************************************/ + +void +prtpage(bytepos) /* print page whose BOP is at bytepos */ +long bytepos; + +{ + struct stack_entry + { + INT32 h; + COORDINATE hh; + INT32 v; + COORDINATE vv; + INT32 w, x, y, z; /* what's on stack */ + }; + register BYTE command; /* current command */ + register INT16 i; /* command parameter; loop index */ + char tc; /* temporary character */ + UNSIGN32 ht_rule; /* rule height */ + UNSIGN32 wd_rule; /* rule width */ + INT32 k,m; /* temporary parameter */ + INT16 page_number; /* TeX's \count0 parameter */ + BOOLEAN seen_bop; /* flag for noting processing of BOP */ + register INT16 sp; /* stack pointer */ + struct stack_entry stack[STACKSIZE]; /* stack */ + char specstr[MAXSPECIAL+1]; /* \special{} string */ + INT32 w; /* current horizontal spacing */ + INT32 x; /* current horizontal spacing */ + INT32 y; /* current vertical spacing */ + INT32 z; /* current vertical spacing */ + +/*********************************************************************** +Process all commands between the BOP at bytepos and the next BOP or +POST. The page is printed when the EOP is met, but font changes can +also happen between EOP and BOP, so we have to keep going after EOP. +***********************************************************************/ + +/* (void) checkpage(bytepos); */ + + seen_bop = FALSE; /* this is first time through */ + (void) FSEEK(dvifp,bytepos,0); /* start at the desired position */ + + for (;;) /* "infinite" loop - exits when POST or second BOP met */ + { +#if BBNBITGRAPH + /* If the test here on every byte proves to carry objectionable + overhead, it can be moved into the default, PUTx, and SETx + command sections. The goal is to give the user instant + response in page screen positioning, without having to wait + for the entire screen to be painted when it is just going + to be moved anyway. This is the sort of display algorithm + that EMACS uses. */ + if (kbinput() > 0) /* user has typed something */ + command = EOP; /* so set for end-of-page action */ + else +#endif + command = (BYTE)nosignex(dvifp,(BYTE)1); + switch (command) + { + + case SET1: + case SET2: + case SET3: + case SET4: + (void)setchar((BYTE)nosignex(dvifp,(BYTE)(command-SET1+1)),TRUE); + break; + + case SET_RULE: + ht_rule = nosignex(dvifp,(BYTE)4); + wd_rule = nosignex(dvifp,(BYTE)4); + (void)setrule(ht_rule,wd_rule,TRUE); + break; + + case PUT1: + case PUT2: + case PUT3: + case PUT4: + (void)setchar((BYTE)nosignex(dvifp,(BYTE)(command-PUT1+1)),FALSE); + break; + + case PUT_RULE: + ht_rule = nosignex(dvifp,(BYTE)4); + wd_rule = nosignex(dvifp,(BYTE)4); + (void)setrule(ht_rule,wd_rule,FALSE); + break; + + case NOP: + break; + + case BOP: + if (seen_bop) + return; /* we have been here already */ + seen_bop = TRUE; + + for (i=0; i<=9; i++) + tex_counter[i] = (INT32)signex(dvifp,(BYTE)4); + + page_number = (INT16)tex_counter[0]; +#if BBNBITGRAPH + (void)bopact(); /* display menu at top of page */ +#else /* not BBNBITGRAPH */ + +#if (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) +#else /* NOT (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */ + (void)clrbmap(); +#endif /* (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */ + + if (!quiet) + { (void)fprintf(stderr,"{%s}",tctos()); /* TeX page counters */ + fflush(stderr); + } + (void) nosignex(dvifp,(BYTE)4); /* skip prev. page ptr */ +#endif /* BBNBITGRAPH */ + + h = v = w = x = y = z = 0; + hh = lmargin; + vv = tmargin; + sp = 0; + fontptr = (struct font_entry*)NULL; + break; + + case EOP: + +#if (BBNBITGRAPH | CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) + (void)eopact(); +#else + (void)prtbmap(); +#endif /* (BBNBITGRAPH | CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */ + + return; + + case PUSH: + if (sp >= STACKSIZE) + (void)fatal("prtpage(): stack overflow"); + stack[sp].h = h; + stack[sp].hh = hh; + stack[sp].v = v; + stack[sp].vv = vv; + stack[sp].w = w; + stack[sp].x = x; + stack[sp].y = y; + stack[sp].z = z; + sp++; + break; + + case POP: + --sp; + if (sp < 0) + (void)fatal("prtpage(): stack underflow"); + h = stack[sp].h; + hh = stack[sp].hh; + v = stack[sp].v; + vv = stack[sp].vv; + w = stack[sp].w; + x = stack[sp].x; + y = stack[sp].y; + z = stack[sp].z; + break; + + case RIGHT1: + case RIGHT2: + case RIGHT3: + case RIGHT4: + (void)moveover(signex(dvifp,(BYTE)(command-RIGHT1+1))); + break; + + case W0: + (void)moveover(w); + break; + + case W1: + case W2: + case W3: + case W4: + w = (INT32)signex(dvifp,(BYTE)(command-W1+1)); + (void)moveover(w); + break; + + case X0: + (void)moveover(x); + break; + + case X1: + case X2: + case X3: + case X4: + x = (INT32)signex(dvifp,(BYTE)(command-X1+1)); + (void)moveover(x); + break; + + case DOWN1: + case DOWN2: + case DOWN3: + case DOWN4: + (void)movedown(signex(dvifp,(BYTE)(command-DOWN1+1))); + break; + + case Y0: + (void)movedown(y); + break; + + case Y1: + case Y2: + case Y3: + case Y4: + y = signex(dvifp,(BYTE)(command-Y1+1)); + (void)movedown(y); + break; + + case Z0: + (void)movedown(z); + break; + + case Z1: + case Z2: + case Z3: + case Z4: + z = signex(dvifp,(BYTE)(command-Z1+1)); + (void)movedown(z); + break; + + case FNT1: + case FNT2: + case FNT3: + case FNT4: + (void)setfntnm((INT32)nosignex(dvifp, + (BYTE)(command-FNT1+1))); + break; + + case XXX1: + case XXX2: + case XXX3: + case XXX4: + k = (INT32)nosignex(dvifp,(BYTE)(command-XXX1+1)); + if (k > MAXSPECIAL) + { + (void)sprintf(message, + "prtpage(): \\special{} string of %d characters longer \ +than DVI driver limit of %d -- truncated.", + k,MAXSPECIAL); + (void)warning(message); + } + m = 0; + while (k--) + { + tc = (char)nosignex(dvifp,(BYTE)1); + if (m < MAXSPECIAL) + specstr[m++] = tc; + } + specstr[m] = '\0'; + (void) special(specstr); + break; + + case FNT_DEF1: + case FNT_DEF2: + case FNT_DEF3: + case FNT_DEF4: + (void)skipfont ((INT32) nosignex(dvifp, + (BYTE)(command-FNT_DEF1+1))); + break; + + case PRE: + (void)fatal("prtpage(): PRE occurs within file"); + break; + + case POST: + (void)devterm(); /* terminate device output */ + (void)dviterm(); /* terminate DVI file processing */ + (void)alldone(); /* this will never return */ + break; + + case POST_POST: + (void)fatal("prtpage(): POST_POST with no preceding POST"); + break; + + default: + if (command >= FONT_00 && command <= FONT_63) + (void)setfntnm((INT32)(command - FONT_00)); + else if (command >= SETC_000 && command <= SETC_127) + +#if (HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2) + (void)setstr((BYTE)command); /* this sets several chars */ +#else + (void)setchar((BYTE)(command-SETC_000), TRUE); +#endif /* (HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2) */ + + else + { + (void)sprintf(message,"prtpage(): %d is an undefined command", + command); + (void)fatal(message); + } + break; + } + } +} diff --git a/dviware/kane/readme.txt b/dviware/kane/readme.txt new file mode 100644 index 0000000000..37604b3f84 --- /dev/null +++ b/dviware/kane/readme.txt @@ -0,0 +1,20 @@ + +Date: 21-MAR-1989 14:43:31 GMT +From: PHYOKANE@CS8700.UCG.IE +To: abbottp@ASTON.AC.UK +Subject: LaserJet+ Driver +sender: hea"phyokane@cs8700.ucg.ie" + +Sorry... this should have preceded the source files + +To follow; Modified sources for font packing LaserJet+ dvi driver. +dvijep_p.c +dvifile_p.h +gblvars.h +prtpage_p.h +checkpage.h +The work around fixes for the specific Centronics PP8 bugs have been +removed where they might confuse a real LaserJet+. + + Peter. +.... but FTP did something silly with it! -- cgit v1.2.3