home *** CD-ROM | disk | FTP | other *** search
- /***( flush.c )*****************************************************************
- * *
- * Written: Brent Faulkner - June 19, 1989 *
- * Updated: Brent Faulkner - June 19, 1989 *
- * *
- ********************************************************************************
- * *
- * Contents: flushprt() - flush the buffers to the printer *
- * outlen() - return output length of line *
- * *
- *******************************************************************************/
- #include <stdio.h>
- #include <bench.h>
- #include "prt.h"
-
- #ifdef ANSI
- static unsigned int do_attr(unsigned int, unsigned int);
- static int outlen(char *, int);
- static void flush1(void);
- static void flush2(void);
- static void ps_attr(int, int);
- static void ps_comment(char *, ...);
- static void ps_line(int, int, char *, ...);
- static void ps_fnbeg(char *, char *);
- static void ps_fnend(void);
- static void ps_encode(int, char *);
- static void ps_onelinedef(char *, char *);
- static void ps_moveto(int, int, int, int);
- static void ps_lineto(int, int, int, int);
- #else
- static unsigned int do_attr();
- static int outlen();
- static void flush1();
- static void flush2();
- static void ps_attr();
- static void ps_comment();
- static void ps_line();
- static void ps_fnbeg();
- static void ps_fnend();
- static void ps_encode();
- static void ps_onelinedef();
- static void ps_moveto();
- static void ps_lineto();
- #endif
-
- #define ps_skip() fputs("\015\012", devfp)
-
- int ps_tablvl = 0;
-
- /*
- * Flush the page buffers to the printer device
- */
- void flushprt()
- {
- if (prtdef[POSTSCRIPT] == NULL)
- flush1(); /* standard (non-postscript) printer */
- else
- flush2(); /* postscript printer */
- }
-
- static void flush1()
- {
- int i;
- register int j;
- unsigned int oldattr = P_DUMMY;
-
- /* for each line */
- for(i = 0; i < (unsigned char)*prtdef[NUM_LINES]; i++)
- {
- /* for each column */
- for(j = 0; j < outlen(pagebuff[i], (unsigned char)*prtdef[NUM_COLS]); j++)
- {
- /* change attribute if required */
- oldattr = do_attr((unsigned int)oldattr, (unsigned int)attrbuff[i][j]);
- /* do underline if it isn't defined but BS is */
- if((attrbuff[i][j] & P_UNDER) && prtdef[UNDER_ON] == NULL)
- {
- if (prtdef[BS] != NULL)
- {
- fputc('_', devfp);
- emit_seq(BS);
- }
- }
- /* overstrike for BOLD if it isn't defined but BS is */
- if((attrbuff[i][j] & P_BOLD) && prtdef[BOLD_ON] == NULL)
- {
- if (prtdef[BS] != NULL && pagebuff[i][j] != '\0')
- {
- fputc(pagebuff[i][j], devfp);
- emit_seq(BS);
- }
- }
- /* overstrike for LQ if it isn't defined but BS is */
- if((attrbuff[i][j] & P_LQ) && prtdef[LQ_ON] == NULL)
- {
- if(pagebuff[i][j] != '\0')
- {
- fputc(pagebuff[i][j], devfp);
- emit_seq(BS);
- }
- }
-
- /* output character */
- if(pagebuff[i][j] == '\0')
- fputc(' ', devfp);
- else
- fputc(pagebuff[i][j], devfp);
- }
- if (prtdef[ATTR_REFRESH] != NULL)
- {
- do_attr((unsigned int)oldattr, (unsigned int)P_DUMMY);
- oldattr = P_DUMMY;
- }
- emit_seq(LINEFEED); /* do the line feed */
- }
- if (prtdef[ATTR_REFRESH] == NULL)
- do_attr((unsigned int)oldattr, (unsigned int)P_DUMMY);
- }
-
- /*
- * Return the output length of a line
- * ie. the number of characters on a line not counting trailing spaces
- * or \0's
- */
- static int outlen(outstr, outsiz)
- char *outstr;
- int outsiz;
- {
- register int i;
-
- for(i = outsiz; i > 0; i--)
- if(outstr[i - 1] != '\0' && outstr[i - 1] != ' ')
- break;
-
- return(i);
- }
-
- /*
- * Output any sequences for a change in attributes
- */
- static unsigned int do_attr(oatt, natt)
- unsigned int oatt;
- unsigned int natt;
- {
- int i;
- register unsigned int tbit;
- unsigned int tatt;
-
- tatt = natt ^ oatt; /* find any changed attributes */
- /* for each changed attribute turn off if on and on if off */
- for(i = 0; i < 16; i++)
- {
- tbit = 1 << i;
- if(tatt & tbit)
- {
- switch(tbit)
- {
- case P_ITALIC: /* 0x0001 */
- if (natt & P_ITALIC)
- emit_seq(ITALIC_ON);
- else
- emit_seq(ITALIC_OFF);
- break;
- case P_BOLD: /* 0x0002 */
- if (natt & P_BOLD)
- emit_seq(BOLD_ON);
- else
- emit_seq(BOLD_OFF);
- break;
- case P_UNDER: /* 0x0004 */
- if (natt & P_UNDER)
- emit_seq(UNDER_ON);
- else
- emit_seq(UNDER_OFF);
- break;
- case P_LQ: /* 0x0008 */
- if (natt & P_LQ)
- emit_seq(LQ_ON);
- else
- emit_seq(LQ_OFF);
- break;
- case P_PS: /* 0x0010 */
- if (natt & P_PS)
- emit_seq(PS_ON);
- else
- emit_seq(PS_OFF);
- break;
- case P_SUBSCRIPT: /* 0x0020 */
- if (natt & P_SUBSCRIPT)
- emit_seq(SUBSCRIPT_ON);
- else
- emit_seq(SUBSCRIPT_OFF);
- break;
- case P_SUPERSCRIPT: /* 0x0040 */
- if (natt & P_SUPERSCRIPT)
- emit_seq(SUPERSCRIPT_ON);
- else
- emit_seq(SUPERSCRIPT_OFF);
- break;
- case P_DBL_WIDE: /* 0x0080 */
- if (natt & P_DBL_WIDE)
- emit_seq(DBL_WIDE_ON);
- else
- emit_seq(DBL_WIDE_OFF);
- break;
- case P_DBL_HIGH: /* 0x0100 */
- if (natt & P_DBL_HIGH)
- emit_seq(DBL_HIGH_ON);
- else
- emit_seq(DBL_HIGH_OFF);
- break;
- case P_CONDENSED: /* 0x0200 */
- if (natt & P_CONDENSED)
- emit_seq(CONDENSED_ON);
- else
- emit_seq(CONDENSED_OFF);
- break;
- case P_CPI5: /* 0x0400 */
- if (natt & P_CPI5)
- emit_seq(CPI5);
- else
- emit_seq(CPI10);
- break;
- case P_CPI10: /* 0x0800 */
- if (natt & P_CPI10)
- emit_seq(CPI10);
- else
- emit_seq(CPI10);
- break;
- case P_CPI12: /* 0x1000 */
- if (natt & P_CPI12)
- emit_seq(CPI12);
- else
- emit_seq(CPI10);
- break;
- case P_CPI16: /* 0x2000 */
- if (natt & P_CPI16)
- emit_seq(CPI16);
- else
- emit_seq(CPI10);
- break;
- case P_BOX: /* 0x4000 */
- if (natt & P_BOX)
- emit_seq(BOX_ON);
- else
- emit_seq(BOX_OFF);
- break;
- }
- }
- }
- return(natt);
- }
-
- static void flush2()
- {
- int i;
- int j, J;
- register int k;
- unsigned int oldattr = P_DUMMY;
- char LBUFF[512];
- int aflag = 0; /* flag for attribute change */
-
- ps_comment("Beginning of Page"); /* page prefix */
- ps_onelinedef("pg", "save");
-
- /* for each line */
- for(i = 0; i < (unsigned char)*prtdef[NUM_LINES]; i++)
- {
- /* calculate line length */
- J = outlen(pagebuff[i], (unsigned char)*prtdef[NUM_COLS]);
- if (J > 0) /* if line has non-zero length do moveto */
- ps_moveto(-1, 1, 18, 756 - i * 12);
- for(j = 0; j < J;) /* for each column */
- {
- memset(LBUFF, '\0', 512); /* zero out line buffer */
- for(k = 0; j < J; j++, k++) /* gather chars with same attribute */
- {
- if (attrbuff[i][j] != oldattr)
- {
- aflag = 1; /* if the attribute changes set the */
- break; /* flag and break out of the loop */
- }
- /* add the char to the line buffer */
- if (pagebuff[i][j] == '\0')
- LBUFF[k] = ' ';
- else
- { /* convert non-printable chars to octal */
- if(pagebuff[i][j] < 0x20 || pagebuff[i][j] > 0x7e)
- {
- int n = pagebuff[i][j];
-
- LBUFF[k] = '\\';
- k++;
- LBUFF[k] = (char)(0x30 + n / 64);
- k++;
- n %= 64;
- LBUFF[k] = (char)(0x30 + n / 8);
- k++;
- n %= 8;
- LBUFF[k] = (char)(0x30 + n);
- }
- else
- {
- if (pagebuff[i][j] == '%')
- {
- LBUFF[k] = '%'; /* do two percents for a percent */
- k++;
- LBUFF[k] = '%';
- }
- else
- LBUFF[k] = pagebuff[i][j];
- }
- }
- }
- if (strlen(LBUFF) > 0)
- {
- if (oldattr & P_DBL_WIDE) /* call any modifying postscript */
- ps_line(-1, 1, "dbl-width"); /* functions */
- if (oldattr & P_DBL_HIGH)
- ps_line(-1, 1, "dbl-height");
- if (oldattr & P_CONDENSED)
- ps_line(-1, 1, "condense");
-
- if (oldattr & P_UNDER) /* output the text using show */
- ps_line(-1, 1, "12 (%s) undershow", LBUFF); /* underlined */
- else
- ps_line(-1, 1, "(%s) show", LBUFF);
-
- if (oldattr & P_DBL_WIDE) /* call the complimenting */
- ps_line(-1, 1, "half-width"); /* postscript function for */
- if (oldattr & P_DBL_HIGH) /* any modifiers */
- ps_line(-1, 1, "half-height");
- if (oldattr & P_CONDENSED)
- ps_line(-1, 1, "expand");
- }
- if (aflag) /* if an attribute change is */
- { /* do any font changes */
- ps_attr(attrbuff[i][j], oldattr);
- oldattr = attrbuff[i][j];
- aflag = 0;
- }
- }
- }
-
- ps_line(-1, 1, "showpage pg restore"); /* end of the page */
- }
-
- static char vpsbuff[512]; /* buffer for varargs functions */
-
- /*
- * Output a postscript comment
- */
- #ifdef ANSI
- static void ps_comment(char *va_alist, ...)
- #else
- static void ps_comment(va_alist)
- va_dcl
- #endif
- {
- va_list ap;
- register char *fmt;
-
- #ifdef ANSI
- va_start(ap, va_alist);
- fmt = va_alist;
- #else
- va_start(ap);
- fmt = va_arg(ap, char *);
- #endif
-
- vsprintf(vpsbuff, fmt, ap);
- va_end(ap);
-
- fprintf(devfp, "%% %s\015\012", vpsbuff);
- }
-
- /*
- * Output a line of postscript (other than a comment or a blank line)
- */
- #ifdef ANSI
- static void ps_line(int otl, int crflag, char *va_alist, ...)
- #else
- static void ps_line(otl, crflag, va_alist)
- int otl;
- int crflag;
- va_dcl
- #endif
- {
- va_list ap;
- register char *fmt;
-
- #ifdef ANSI
- va_start(ap, va_alist);
- fmt = va_alist;
- #else
- va_start(ap);
- fmt = va_arg(ap, char *);
- #endif
-
- vsprintf(vpsbuff, fmt, ap);
- va_end(ap);
-
- if (otl == -1)
- otl = ps_tablvl;
-
- while(otl-- > 0)
- fputc('\t', devfp);
-
- fputs(vpsbuff, devfp);
-
- if (crflag)
- fputs("\015\012", devfp);
- }
-
- /*
- * Output any postscript required for a font change
- */
- static void ps_attr(nattr, oattr)
- int nattr;
- int oattr;
- {
- char fontname[40];
- static char lastfont[40];
- int fontsize;
- static int lastsize = 0;
-
- if (oattr == P_DUMMY)
- {
- strcpy(lastfont, "");
- lastsize = 0;
- }
-
- if (nattr & P_BOX) /* get the initial name for a font */
- strcpy(fontname, "LineChars");
- else if (nattr & P_PS)
- strcpy(fontname, "Helvetica");
- else
- strcpy(fontname, "Courier");
-
- if (nattr & P_BOLD) /* modify the font name for BOLD */
- strcat(fontname, "-Bold"); /* or ITALIC */
-
- if (nattr & P_ITALIC && !(nattr & P_BOX))
- {
- if (!(nattr & P_BOLD))
- strcat(fontname, "-");
- strcat(fontname, "Oblique");
- }
-
- if (nattr & P_CPI5) /* set the font size required */
- fontsize = 24;
- else if (nattr & P_CPI12)
- fontsize = 10;
- else if (nattr & P_CPI16)
- fontsize = 8;
- else
- fontsize = 12;
-
- /* only output the change if really required
- * ie. the attribute may change but the font may not
- * such as for condensed, etc.
- */
- if (lastsize != fontsize || strcmp(lastfont, fontname) != 0)
- ps_line(-1, 1, "/%s findfont %d scalefont setfont", fontname, fontsize);
- lastsize = fontsize;
- strcpy(lastfont, fontname);
-
- /* do any relative moves required for super/sub scripting */
- if ( ((oattr & P_SUBSCRIPT) && !(nattr & P_SUBSCRIPT)) ||
- (!(oattr & P_SUPERSCRIPT) && (nattr & P_SUPERSCRIPT)) )
- ps_line(-1, 1, "0 3 rmoveto");
-
- if ( (!(oattr & P_SUBSCRIPT) && (nattr & P_SUBSCRIPT)) ||
- ((oattr & P_SUPERSCRIPT) && !(nattr & P_SUPERSCRIPT)) )
- ps_line(-1, 1, "0 -3 rmoveto");
- }
-
- /*
- * Output the postscript required by all print jobs
- * ie. define the functions for underline, etc. and define the LineChars
- * and LineChars-Bold fonts
- */
- void ps_init()
- {
- char *_newpath = "newpath";
- char *_stroke = "stroke";
- char *_end = "end";
- char *_begin = "begin";
- char *_pop = "pop";
- char *_scale = "scale";
- char *_exch = "exch";
-
- ps_comment("!PS-Adobe");
- ps_skip();
- ps_fnbeg("undershow", "show with underline");
- ps_line(-1, 1, "dup stringwidth %s", _pop);
- ps_line(-1, 1, "3 -1 roll");
- ps_line(-1, 1, "uline");
- ps_line(-1, 1, "show");
- ps_fnend();
- ps_skip();
- ps_fnbeg("uline", "do the underlining");
- ps_onelinedef("ps", _exch);
- ps_line(-1, 1, "gsave");
- ps_line(-1, 1, "currentfont /FontInfo get dup");
- ps_line(-1, 1, "/UnderlinePosition get ps mul 1000 div 0 %s rmoveto %s 0 rlineto", _exch, _exch);
- ps_line(-1, 1, "/UnderlineThickness get ps mul 1000 div setlinewidth %s", _stroke);
- ps_line(-1, 1, "grestore");
- ps_fnend();
- ps_skip();
- ps_fnbeg("dbl-height", "double the y-scale");
- ps_line(-1, 1, "1 2 %s", _scale);
- ps_fnend();
- ps_skip();
- ps_fnbeg("half-height", "half the y-scale");
- ps_line(-1, 1, "1 .5 %s", _scale);
- ps_fnend();
- ps_skip();
- ps_fnbeg("dbl-width", "double the x-scale");
- ps_line(-1, 1, "2 1 %s", _scale);
- ps_fnend();
- ps_skip();
- ps_fnbeg("half-width", "half the x-scale");
- ps_line(-1, 1, ".5 1 %s", _scale);
- ps_fnend();
- ps_skip();
- ps_fnbeg("condense", "2/3 the x-scale");
- ps_line(-1, 1, "2 3 div 1 %s", _scale);
- ps_fnend();
- ps_skip();
- ps_fnbeg("expand", "3/2 the x-scale");
- ps_line(-1, 1, "1.5 1 %s", _scale);
- ps_fnend();
- ps_skip();
- ps_comment("Define the PC line drawing character set (LineChars),");
- ps_comment("and the bold equivalent (LineChars-Bold).");
- ps_comment("");
- ps_comment("The characters are drawn on a 1000 by 1000 square then the x is");
- ps_comment("%sd by .0006 to make it line up with the courier character set.", _scale);
- ps_skip();
- ps_line(-1, 1, "10 dict dup %s", _begin);
- ps_skip();
- ps_onelinedef("FontType", "3");
- ps_onelinedef("FontMatrix", "[.0006 0 0 .001 0 0]");
- ps_onelinedef("FontBBox", "[0 0 1000 1000]");
- ps_onelinedef("Encoding", "256 array");
- ps_line(-1, 1, "0 1 255 { Encoding %s /.notdef put } for", _exch);
- ps_encode(0xb0, "shade_block");
- ps_encode(0xb3, "vertical");
- ps_encode(0xb4, "right_tee");
- ps_encode(0xb6, "dsright_tee");
- ps_encode(0xb5, "sdright_tee");
- ps_encode(0xb7, "sdtop_right");
- ps_encode(0xb8, "dstop_right");
- ps_encode(0xb9, "dright_tee");
- ps_encode(0xba, "dvertical");
- ps_encode(0xbb, "dtop_right");
- ps_encode(0xbc, "dbot_right");
- ps_encode(0xbd, "sdbot_right");
- ps_encode(0xbe, "dsbot_right");
- ps_encode(0xbf, "top_right");
- ps_encode(0xc0, "bot_left");
- ps_encode(0xc1, "up_tee");
- ps_encode(0xc2, "down_tee");
- ps_encode(0xc3, "left_tee");
- ps_encode(0xc4, "horizontal");
- ps_encode(0xc5, "cross");
- ps_encode(0xc6, "sdleft_tee");
- ps_encode(0xc7, "dsleft_tee");
- ps_encode(0xc8, "dbot_left");
- ps_encode(0xc9, "dtop_left");
- ps_encode(0xca, "dup_tee");
- ps_encode(0xcb, "ddown_tee");
- ps_encode(0xcc, "dleft_tee");
- ps_encode(0xcd, "dhorizontal");
- ps_encode(0xce, "dcross");
- ps_encode(0xcf, "dsup_tee");
- ps_encode(0xd0, "sdup_tee");
- ps_encode(0xd1, "dsdown_tee");
- ps_encode(0xd2, "sddown_tee");
- ps_encode(0xd3, "sdbot_left");
- ps_encode(0xd4, "dsbot_left");
- ps_encode(0xd5, "dstop_left");
- ps_encode(0xd6, "sdtop_left");
- ps_encode(0xd7, "sdcross");
- ps_encode(0xd8, "dscross");
- ps_encode(0xd9, "bot_right");
- ps_encode(0xda, "top_left");
- ps_encode(0xdb, "solid_block");
- ps_encode(0xdc, "bot_block");
- ps_encode(0xdf, "top_block");
- ps_skip();
- ps_onelinedef("CharProcs", "45 dict");
- ps_line(-1, 1, "CharProcs %s %% The functions for each character", _begin);
- ps_fnbeg(".notdef", NULL);
- ps_fnend();
- ps_fnbeg("solid_block", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 0);
- ps_lineto(0, 0, 1000, 0);
- ps_lineto(0, 0, 1000, 1000);
- ps_lineto(0, 1, 0, 1000);
- ps_line(-1, 1, "closepath");
- ps_line(-1, 1, "fill");
- ps_fnend();
- ps_fnbeg("shade_block", NULL);
- ps_line(-1, 1, _newpath);
-
- ps_moveto(-1, 0, 125, 0);
- ps_lineto(0, 0, 250, 0);
- ps_moveto(0, 0, 625, 0);
- ps_lineto(0, 1, 750, 0);
-
- ps_moveto(-1, 0, 375, 62);
- ps_lineto(0, 0, 500, 62);
- ps_moveto(0, 0, 875, 62);
- ps_lineto(0, 1, 1000, 62);
-
- ps_moveto(-1, 0, 125, 124);
- ps_lineto(0, 0, 250, 124);
- ps_moveto(0, 0, 625, 124);
- ps_lineto(0, 1, 750, 124);
-
- ps_moveto(-1, 0, 375, 186);
- ps_lineto(0, 0, 500, 186);
- ps_moveto(0, 0, 875, 186);
- ps_lineto(0, 1, 1000, 186);
-
- ps_moveto(-1, 0, 125, 248);
- ps_lineto(0, 0, 250, 248);
- ps_moveto(0, 0, 625, 248);
- ps_lineto(0, 1, 750, 248);
-
- ps_moveto(-1, 0, 375, 310);
- ps_lineto(0, 0, 500, 310);
- ps_moveto(0, 0, 875, 310);
- ps_lineto(0, 1, 1000, 310);
-
- ps_moveto(-1, 0, 125, 372);
- ps_lineto(0, 0, 250, 372);
- ps_moveto(0, 0, 625, 372);
- ps_lineto(0, 1, 750, 372);
-
- ps_moveto(-1, 0, 375, 434);
- ps_lineto(0, 0, 500, 434);
- ps_moveto(0, 0, 875, 434);
- ps_lineto(0, 1, 1000, 434);
-
- ps_moveto(-1, 0, 125, 496);
- ps_lineto(0, 0, 250, 496);
- ps_moveto(0, 0, 625, 496);
- ps_lineto(0, 1, 750, 496);
-
- ps_moveto(-1, 0, 375, 558);
- ps_lineto(0, 0, 500, 558);
- ps_moveto(0, 0, 875, 558);
- ps_lineto(0, 1, 1000, 558);
-
- ps_moveto(-1, 0, 125, 620);
- ps_lineto(0, 0, 250, 620);
- ps_moveto(0, 0, 625, 620);
- ps_lineto(0, 1, 750, 620);
-
- ps_moveto(-1, 0, 375, 682);
- ps_lineto(0, 0, 500, 682);
- ps_moveto(0, 0, 875, 682);
- ps_lineto(0, 1, 1000, 682);
-
- ps_moveto(-1, 0, 125, 744);
- ps_lineto(0, 0, 250, 744);
- ps_moveto(0, 0, 625, 744);
- ps_lineto(0, 1, 750, 744);
-
- ps_moveto(-1, 0, 375, 806);
- ps_lineto(0, 0, 500, 806);
- ps_moveto(0, 0, 875, 806);
- ps_lineto(0, 1, 1000, 806);
-
- ps_moveto(-1, 0, 125, 868);
- ps_lineto(0, 0, 250, 868);
- ps_moveto(0, 0, 625, 868);
- ps_lineto(0, 1, 750, 868);
-
- ps_moveto(-1, 0, 375, 930);
- ps_lineto(0, 0, 500, 930);
- ps_moveto(0, 0, 875, 930);
- ps_lineto(0, 1, 1000, 930);
-
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("horizontal", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dhorizontal", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 1000, 500);
- ps_moveto(0, 0, 0, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("vertical", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 500, 0);
- ps_lineto(0, 1, 500, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dvertical", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 400, 0);
- ps_lineto(0, 0, 400, 1000);
- ps_moveto(0, 0, 600, 0);
- ps_lineto(0, 1, 600, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("cross", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_moveto(-1, 0, 500, 0);
- ps_lineto(0, 1, 500, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dcross", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 400, 500);
- ps_lineto(0, 1, 400, 0);
- ps_moveto(-1, 0, 0, 700);
- ps_lineto(0, 0, 400, 700);
- ps_lineto(0, 1, 400, 1000);
- ps_moveto(-1, 0, 600, 0);
- ps_lineto(0, 0, 600, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_moveto(-1, 0, 600, 1000);
- ps_lineto(0, 0, 600, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dscross", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_moveto(-1, 0, 0, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_moveto(-1, 0, 500, 0);
- ps_lineto(0, 1, 500, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("top_left", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 500, 0);
- ps_lineto(0, 0, 500, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dtop_left", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 400, 0);
- ps_lineto(0, 0, 400, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_moveto(-1, 0, 600, 0);
- ps_lineto(0, 0, 600, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dstop_left", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 500, 0);
- ps_lineto(0, 0, 500, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_moveto(-1, 0, 500, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("sdtop_left", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 400, 0);
- ps_lineto(0, 0, 400, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_moveto(-1, 0, 600, 0);
- ps_lineto(0, 1, 600, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("top_right", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 500, 500);
- ps_lineto(0, 1, 500, 0);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("sdtop_right", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 400, 500);
- ps_lineto(0, 1, 400, 0);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 600, 500);
- ps_lineto(0, 1, 600, 0);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dtop_right", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 700);
- ps_lineto(0, 0, 600, 700);
- ps_lineto(0, 1, 600, 0);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 400, 500);
- ps_lineto(0, 1, 400, 0);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("bot_right", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 500, 500);
- ps_lineto(0, 1, 500, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dbot_right", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 700);
- ps_lineto(0, 0, 400, 700);
- ps_lineto(0, 1, 400, 1000);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 600, 500);
- ps_lineto(0, 1, 600, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("sdbot_right", NULL);
- ps_line(-1, 1, _newpath);
- ps_line(-1, 1, "400 500 moveto 400 1000 lineto");
- ps_moveto(-1, 0, 400, 500);
- ps_lineto(0, 1, 400, 1000);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 600, 500);
- ps_lineto(0, 1, 600, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("bot_left", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 500, 1000);
- ps_lineto(0, 0, 500, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dbot_left", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 600, 1000);
- ps_lineto(0, 0, 600, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_moveto(-1, 0, 400, 1000);
- ps_lineto(0, 0, 400, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dsbot_left", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 500, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_moveto(-1, 0, 500, 1000);
- ps_lineto(0, 0, 500, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dsbot_right", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 500, 700);
- ps_lineto(0, 1, 0, 700);
- ps_moveto(-1, 0, 500, 1000);
- ps_lineto(0, 0, 500, 500);
- ps_lineto(0, 1, 0, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dstop_right", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 700);
- ps_lineto(0, 0, 500, 700);
- ps_lineto(0, 1, 500, 0);
- ps_lineto(-1, 0, 500, 500);
- ps_lineto(0, 1, 0, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("sdbot_left", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 400, 1000);
- ps_lineto(0, 0, 400, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_moveto(-1, 0, 600, 1000);
- ps_lineto(0, 1, 600, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("left_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 500, 0);
- ps_lineto(0, 0, 500, 1000);
- ps_moveto(0, 0, 500, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dleft_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 400, 0);
- ps_lineto(0, 1, 400, 1000);
- ps_moveto(-1, 0, 600, 0);
- ps_lineto(0, 0, 600, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_moveto(-1, 0, 1000, 700);
- ps_lineto(0, 0, 600, 700);
- ps_lineto(0, 1, 600, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("sdleft_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 500, 0);
- ps_lineto(0, 1, 500, 1000);
- ps_moveto(-1, 0, 500, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_moveto(-1, 0, 500, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("sdright_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 1, 500, 500);
- ps_moveto(-1, 0, 400, 0);
- ps_lineto(0, 1, 400, 1000);
- ps_moveto(-1, 0, 600, 0);
- ps_lineto(0, 0, 600, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_moveto(-1, 0, 1000, 700);
- ps_lineto(0, 0, 600, 700);
- ps_lineto(0, 1, 600, 1000);
- ps_moveto(-1, 0, 0, 700);
- ps_lineto(0, 1, 500, 700);
- ps_moveto(-1, 0, 500, 0);
- ps_lineto(0, 1, 500, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dsleft_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 400, 0);
- ps_lineto(0, 0, 400, 1000);
- ps_moveto(0, 0, 600, 0);
- ps_lineto(0, 0, 600, 1000);
- ps_moveto(0, 0, 600, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("sdcross", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 400, 0);
- ps_lineto(0, 0, 400, 1000);
- ps_moveto(0, 0, 600, 0);
- ps_lineto(0, 0, 600, 1000);
- ps_moveto(0, 0, 0, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("right_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 500, 0);
- ps_lineto(0, 0, 500, 1000);
- ps_moveto(0, 0, 500, 500);
- ps_lineto(0, 1, 0, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dright_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 600, 1000);
- ps_lineto(0, 1, 600, 0);
- ps_moveto(-1, 0, 400, 1000);
- ps_lineto(0, 0, 400, 700);
- ps_lineto(0, 1, 0, 700);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 400, 500);
- ps_lineto(0, 1, 400, 0);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dsright_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 600, 0);
- ps_lineto(0, 0, 600, 1000);
- ps_moveto(0, 0, 400, 0);
- ps_lineto(0, 0, 400, 1000);
- ps_moveto(0, 0, 400, 500);
- ps_lineto(0, 1, 0, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("up_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 1000, 500);
- ps_moveto(0, 0, 500, 500);
- ps_lineto(0, 1, 500, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dup_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 700);
- ps_lineto(0, 0, 400, 700);
- ps_lineto(0, 1, 400, 1000);
- ps_moveto(-1, 0, 600, 1000);
- ps_lineto(0, 0, 600, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dsup_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_moveto(-1, 0, 500, 700);
- ps_lineto(0, 1, 500, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("sdup_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_moveto(-1, 0, 400, 500);
- ps_lineto(0, 1, 400, 1000);
- ps_moveto(-1, 0, 600, 500);
- ps_lineto(0, 1, 600, 1000);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("down_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 1000, 500);
- ps_moveto(0, 0, 500, 500);
- ps_lineto(0, 1, 500, 0);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("ddown_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 400, 500);
- ps_lineto(0, 1, 400, 0);
- ps_moveto(-1, 0, 600, 0);
- ps_lineto(0, 0, 600, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("dsdown_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 1000, 500);
- ps_moveto(0, 0, 500, 500);
- ps_lineto(0, 1, 500, 0);
- ps_moveto(-1, 0, 0, 700);
- ps_lineto(0, 1, 1000, 700);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("sddown_tee", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 1, 1000, 500);
- ps_moveto(-1, 0, 400, 500);
- ps_lineto(0, 1, 400, 0);
- ps_moveto(-1, 0, 600, 500);
- ps_lineto(0, 1, 600, 0);
- ps_line(-1, 1, _stroke);
- ps_fnend();
- ps_fnbeg("top_block", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 1000, 500);
- ps_lineto(0, 0, 1000, 1000);
- ps_lineto(0, 1, 0, 1000);
- ps_line(-1, 1, "closepath");
- ps_line(-1, 1, "fill");
- ps_fnend();
- ps_fnbeg("bot_block", NULL);
- ps_line(-1, 1, _newpath);
- ps_moveto(-1, 0, 0, 500);
- ps_lineto(0, 0, 1000, 500);
- ps_lineto(0, 0, 1000, 0);
- ps_lineto(0, 1, 0, 0);
- ps_line(-1, 1, "closepath");
- ps_line(-1, 1, "fill");
- ps_fnend();
- ps_line(-1, 1, _end);
- ps_skip();
- ps_fnbeg("BuildChar", NULL);
- ps_line(-1, 1, "40 setlinewidth");
- ps_line(-1, 1, "1000 0");
- ps_line(-1, 1, "0 0 1000 1000");
- ps_line(-1, 1, "setcachedevice");
- ps_line(-1, 1, _exch);
- ps_line(-1, 1, _begin);
- ps_tablvl++;
- ps_line(-1, 1, "Encoding %s get", _exch);
- ps_line(-1, 1, "CharProcs %s get", _exch);
- ps_tablvl--;
- ps_line(-1, 1, _end);
- ps_line(-1, 1, "exec");
- ps_fnend();
- ps_skip();
- ps_line(-1, 1, _end);
- ps_skip();
- ps_line(-1, 1, "/LineChars %s definefont %s", _exch, _pop);
- ps_skip();
- ps_comment("Now copy the LineChars font and modify the line width for -Bold");
- ps_onelinedef("makelinecharsbolddict", "7 dict");
- ps_fnbeg("MakeLineChars-BoldFont", NULL);
- ps_line(-1, 1, "makelinecharsbolddict %s", _begin);
- ps_skip();
- ps_onelinedef("linecharsdict", "/LineChars findfont");
- ps_skip();
- ps_onelinedef("numentries", "linecharsdict maxlength");
- ps_skip();
- ps_onelinedef("linecharsbolddict", "numentries dict");
- ps_skip();
- ps_line(-1, 1, "linecharsdict");
- ps_line(-1, 1, "{ %s dup /FID ne", _exch);
- ps_tablvl++;
- ps_line(-1, 1, "{ %s linecharsbolddict 3 1 roll put }", _exch);
- ps_line(-1, 1, "{ %s %s }", _pop, _pop);
- ps_line(-1, 1, "ifelse");
- ps_tablvl--;
- ps_line(-1, 1, "} forall");
- ps_skip();
- ps_line(-1, 1, "linecharsbolddict %s", _begin);
- ps_fnbeg("BuildChar", NULL);
- ps_line(-1, 1, "80 setlinewidth");
- ps_line(-1, 1, "1000 0");
- ps_line(-1, 1, "0 0 1000 1000");
- ps_line(-1, 1, "setcachedevice");
- ps_line(-1, 1, _exch);
- ps_line(-1, 1, _begin);
- ps_tablvl++;
- ps_line(-1, 1, "Encoding %s get", _exch);
- ps_line(-1, 1, "CharProcs %s get", _exch);
- ps_tablvl--;
- ps_line(-1, 1, _end);
- ps_line(-1, 1, "exec");
- ps_fnend();
- ps_line(-1, 1, _end);
- ps_skip();
- ps_line(-1, 1, "/LineChars-Bold linecharsbolddict definefont %s", _pop);
- ps_line(-1, 1, _end);
- ps_fnend();
- ps_skip();
- ps_line(-1, 1, "MakeLineChars-BoldFont");
- ps_skip();
- ps_comment("End of Prolog");
- ps_skip();
- }
-
- static void ps_fnbeg(name, comment)
- char *name;
- char *comment;
- {
- if (comment == NULL)
- ps_line(-1, 1, "/%s {", name);
- else
- ps_line(-1, 1, "/%s { %% %s", name, comment);
- ps_tablvl++;
- }
-
- static void ps_fnend()
- {
- ps_line(-1, 1, "} def");
- ps_tablvl--;
- }
-
- static void ps_encode(ascval, fnname)
- int ascval;
- char *fnname;
- {
- ps_line(-1, 1, "Encoding 16#%02x /%s put", ascval, fnname);
- }
-
- static void ps_onelinedef(name, def)
- char *name;
- char *def;
- {
- ps_line(-1, 1, "/%s %s def", name, def);
- }
-
- static void ps_moveto(ort, crflag, c1, c2)
- int ort;
- int crflag;
- int c1, c2;
- {
- ps_line(ort, crflag, "%d %d moveto ", c1, c2);
- }
-
- static void ps_lineto(ort, crflag, c1, c2)
- int ort;
- int crflag;
- int c1, c2;
- {
- ps_line(ort, crflag, "%d %d lineto ", c1, c2);
- }
-