home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / PROCWRKB.ZIP / BENCH1.ZIP / PRINT / FLUSH.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-07  |  31.4 KB  |  1,204 lines

  1. /***( flush.c )*****************************************************************
  2. *                                                                              *
  3. *  Written: Brent Faulkner - June 19, 1989                                     *
  4. *  Updated: Brent Faulkner - June 19, 1989                                     *
  5. *                                                                              *
  6. ********************************************************************************
  7. *                                                                              *
  8. * Contents:    flushprt() - flush the buffers to the printer                   *
  9. *                outlen() - return output length of line                       *
  10. *                                                                              *
  11. *******************************************************************************/
  12. #include <stdio.h>
  13. #include <bench.h>
  14. #include "prt.h"
  15.  
  16. #ifdef ANSI
  17. static unsigned int do_attr(unsigned int, unsigned int);
  18. static int outlen(char *, int);
  19. static void flush1(void);
  20. static void flush2(void);
  21. static void ps_attr(int, int);
  22. static void ps_comment(char *, ...);
  23. static void ps_line(int, int, char *, ...);
  24. static void ps_fnbeg(char *, char *);
  25. static void ps_fnend(void);
  26. static void ps_encode(int, char *);
  27. static void ps_onelinedef(char *, char *);
  28. static void ps_moveto(int, int, int, int);
  29. static void ps_lineto(int, int, int, int);
  30. #else
  31. static unsigned int do_attr();
  32. static int outlen();
  33. static void flush1();
  34. static void flush2();
  35. static void ps_attr();
  36. static void ps_comment();
  37. static void ps_line();
  38. static void ps_fnbeg();
  39. static void ps_fnend();
  40. static void ps_encode();
  41. static void ps_onelinedef();
  42. static void ps_moveto();
  43. static void ps_lineto();
  44. #endif
  45.  
  46. #define ps_skip()    fputs("\015\012", devfp)
  47.  
  48. int ps_tablvl = 0;
  49.  
  50. /*
  51.  * Flush the page buffers to the printer device
  52. */
  53. void flushprt()
  54. {
  55.     if (prtdef[POSTSCRIPT] == NULL)
  56.         flush1();  /* standard (non-postscript) printer */
  57.     else
  58.         flush2();  /* postscript printer */
  59. }
  60.  
  61. static void flush1()
  62. {
  63.     int i;
  64.     register int j;
  65.     unsigned int oldattr = P_DUMMY;
  66.  
  67.     /* for each line */
  68.     for(i = 0; i < (unsigned char)*prtdef[NUM_LINES]; i++)
  69.     {
  70.         /* for each column */
  71.         for(j = 0; j < outlen(pagebuff[i], (unsigned char)*prtdef[NUM_COLS]); j++)
  72.         {
  73.             /* change attribute if required */
  74.             oldattr = do_attr((unsigned int)oldattr, (unsigned int)attrbuff[i][j]);
  75.             /* do underline if it isn't defined but BS is */
  76.             if((attrbuff[i][j] & P_UNDER) && prtdef[UNDER_ON] == NULL)
  77.             {
  78.                 if (prtdef[BS] != NULL)
  79.                 {
  80.                     fputc('_', devfp);
  81.                     emit_seq(BS);
  82.                 }
  83.             }
  84.             /* overstrike for BOLD if it isn't defined but BS is */
  85.             if((attrbuff[i][j] & P_BOLD) && prtdef[BOLD_ON] == NULL)
  86.             {
  87.                 if (prtdef[BS] != NULL && pagebuff[i][j] != '\0')    
  88.                 {
  89.                     fputc(pagebuff[i][j], devfp);
  90.                     emit_seq(BS);
  91.                 }
  92.             }
  93.             /* overstrike for LQ if it isn't defined but BS is */
  94.             if((attrbuff[i][j] & P_LQ) && prtdef[LQ_ON] == NULL)
  95.             {
  96.                 if(pagebuff[i][j] != '\0')
  97.                 {
  98.                     fputc(pagebuff[i][j], devfp);
  99.                     emit_seq(BS);
  100.                 }
  101.             }
  102.                 
  103.             /* output character */
  104.             if(pagebuff[i][j] == '\0')
  105.                 fputc(' ', devfp);
  106.             else
  107.                 fputc(pagebuff[i][j], devfp);
  108.         }
  109.         if (prtdef[ATTR_REFRESH] != NULL)
  110.         {
  111.             do_attr((unsigned int)oldattr, (unsigned int)P_DUMMY);
  112.             oldattr = P_DUMMY;
  113.         }
  114.         emit_seq(LINEFEED);     /* do the line feed */
  115.     }
  116.     if (prtdef[ATTR_REFRESH] == NULL)
  117.         do_attr((unsigned int)oldattr, (unsigned int)P_DUMMY);
  118. }
  119.  
  120. /*
  121.  * Return the output length of a line
  122.  * ie. the number of characters on a line not counting trailing spaces
  123.  *     or \0's
  124. */
  125. static int outlen(outstr, outsiz)
  126. char *outstr;
  127. int outsiz;
  128. {
  129.     register int i;
  130.  
  131.     for(i = outsiz; i > 0; i--)
  132.         if(outstr[i - 1] != '\0' && outstr[i - 1] != ' ')
  133.             break;
  134.  
  135.     return(i);
  136. }
  137.  
  138. /*
  139.  * Output any sequences for a change in attributes
  140. */
  141. static unsigned int do_attr(oatt, natt)
  142. unsigned int oatt;
  143. unsigned int natt;
  144. {
  145.     int i;
  146.     register unsigned int tbit;
  147.     unsigned int tatt;
  148.  
  149.     tatt = natt ^ oatt;     /* find any changed attributes */
  150.     /* for each changed attribute turn off if on and on if off */
  151.     for(i = 0; i < 16; i++)
  152.     {
  153.         tbit = 1 << i;
  154.         if(tatt & tbit)
  155.         {
  156.             switch(tbit)
  157.             {
  158.                 case P_ITALIC:             /* 0x0001 */
  159.                     if (natt & P_ITALIC)
  160.                         emit_seq(ITALIC_ON);
  161.                     else
  162.                         emit_seq(ITALIC_OFF);
  163.                     break;
  164.                 case P_BOLD:               /* 0x0002 */
  165.                     if (natt & P_BOLD)
  166.                         emit_seq(BOLD_ON);
  167.                     else
  168.                         emit_seq(BOLD_OFF);
  169.                     break;
  170.                 case P_UNDER:              /* 0x0004 */
  171.                     if (natt & P_UNDER)
  172.                         emit_seq(UNDER_ON);
  173.                     else
  174.                         emit_seq(UNDER_OFF);
  175.                     break;
  176.                 case P_LQ:                 /* 0x0008 */
  177.                     if (natt & P_LQ)
  178.                         emit_seq(LQ_ON);
  179.                     else
  180.                         emit_seq(LQ_OFF);
  181.                     break;
  182.                 case P_PS:                 /* 0x0010 */
  183.                     if (natt & P_PS)
  184.                         emit_seq(PS_ON);
  185.                     else
  186.                         emit_seq(PS_OFF);
  187.                     break;
  188.                 case P_SUBSCRIPT:          /* 0x0020 */
  189.                     if (natt & P_SUBSCRIPT)
  190.                         emit_seq(SUBSCRIPT_ON);
  191.                     else
  192.                         emit_seq(SUBSCRIPT_OFF);
  193.                     break;
  194.                 case P_SUPERSCRIPT:        /* 0x0040 */
  195.                     if (natt & P_SUPERSCRIPT)
  196.                         emit_seq(SUPERSCRIPT_ON);
  197.                     else
  198.                         emit_seq(SUPERSCRIPT_OFF);
  199.                     break;
  200.                 case P_DBL_WIDE:           /* 0x0080 */
  201.                     if (natt & P_DBL_WIDE)
  202.                         emit_seq(DBL_WIDE_ON);
  203.                     else
  204.                         emit_seq(DBL_WIDE_OFF);
  205.                     break;
  206.                 case P_DBL_HIGH:           /* 0x0100 */
  207.                     if (natt & P_DBL_HIGH)
  208.                         emit_seq(DBL_HIGH_ON);
  209.                     else
  210.                         emit_seq(DBL_HIGH_OFF);
  211.                     break;
  212.                 case P_CONDENSED:          /* 0x0200 */
  213.                     if (natt & P_CONDENSED)
  214.                         emit_seq(CONDENSED_ON);
  215.                     else
  216.                         emit_seq(CONDENSED_OFF);
  217.                     break;
  218.                 case P_CPI5:               /* 0x0400 */
  219.                     if (natt & P_CPI5)
  220.                         emit_seq(CPI5);
  221.                     else
  222.                         emit_seq(CPI10);
  223.                     break;
  224.                 case P_CPI10:              /* 0x0800 */
  225.                     if (natt & P_CPI10)
  226.                         emit_seq(CPI10);
  227.                     else
  228.                         emit_seq(CPI10);
  229.                     break;
  230.                 case P_CPI12:              /* 0x1000 */
  231.                     if (natt & P_CPI12)
  232.                         emit_seq(CPI12);
  233.                     else
  234.                         emit_seq(CPI10);
  235.                     break;
  236.                 case P_CPI16:              /* 0x2000 */
  237.                     if (natt & P_CPI16)
  238.                         emit_seq(CPI16);
  239.                     else
  240.                         emit_seq(CPI10);
  241.                     break;
  242.                 case P_BOX:                /* 0x4000 */
  243.                     if (natt & P_BOX)
  244.                         emit_seq(BOX_ON);
  245.                     else
  246.                         emit_seq(BOX_OFF);
  247.                     break;
  248.             }
  249.         }      
  250.     }
  251.     return(natt);
  252. }
  253.  
  254. static void flush2()
  255. {
  256.     int i;
  257.     int j, J;
  258.     register int k;
  259.     unsigned int oldattr = P_DUMMY;
  260.     char LBUFF[512];
  261.     int aflag = 0;      /* flag for attribute change */
  262.  
  263.     ps_comment("Beginning of Page");    /* page prefix */
  264.     ps_onelinedef("pg", "save");
  265.  
  266.     /* for each line */
  267.     for(i = 0; i < (unsigned char)*prtdef[NUM_LINES]; i++)
  268.     {
  269.         /* calculate line length */
  270.         J = outlen(pagebuff[i], (unsigned char)*prtdef[NUM_COLS]);
  271.         if (J > 0)                 /* if line has non-zero length do moveto */
  272.             ps_moveto(-1, 1, 18, 756 - i * 12);
  273.         for(j = 0; j < J;)         /* for each column */
  274.         {
  275.             memset(LBUFF, '\0', 512); /* zero out line buffer */
  276.             for(k = 0; j < J; j++, k++)  /* gather chars with same attribute */
  277.             {
  278.                 if (attrbuff[i][j] != oldattr)
  279.                 {
  280.                     aflag = 1;        /* if the attribute changes set the */
  281.                     break;            /* flag and break out of the loop */
  282.                 }
  283.                                          /* add the char to the line buffer */
  284.                 if (pagebuff[i][j] == '\0')
  285.                     LBUFF[k] = ' ';
  286.                 else
  287.                 {                     /* convert non-printable chars to octal */
  288.                     if(pagebuff[i][j] < 0x20 || pagebuff[i][j] > 0x7e)
  289.                     {
  290.                         int n = pagebuff[i][j];
  291.                    
  292.                         LBUFF[k] = '\\';
  293.                         k++;
  294.                         LBUFF[k] = (char)(0x30 + n / 64);
  295.                         k++;
  296.                         n %= 64;
  297.                         LBUFF[k] = (char)(0x30 + n / 8);
  298.                         k++;
  299.                         n %= 8;
  300.                         LBUFF[k] = (char)(0x30 + n);
  301.                     }
  302.                     else
  303.                     {
  304.                         if (pagebuff[i][j] == '%')
  305.                         {
  306.                             LBUFF[k] = '%';  /* do two percents for a percent */
  307.                             k++;
  308.                             LBUFF[k] = '%';
  309.                         }
  310.                         else
  311.                             LBUFF[k] = pagebuff[i][j];
  312.                     }
  313.                 }
  314.             }
  315.             if (strlen(LBUFF) > 0)
  316.             {
  317.                 if (oldattr & P_DBL_WIDE)    /* call any modifying postscript */
  318.                     ps_line(-1, 1, "dbl-width");    /* functions */
  319.                 if (oldattr & P_DBL_HIGH)
  320.                     ps_line(-1, 1, "dbl-height");
  321.                 if (oldattr & P_CONDENSED)
  322.                     ps_line(-1, 1, "condense");
  323.  
  324.                 if (oldattr & P_UNDER)       /* output the text using show */
  325.                     ps_line(-1, 1, "12 (%s) undershow", LBUFF); /* underlined */
  326.                 else
  327.                     ps_line(-1, 1, "(%s) show", LBUFF);
  328.  
  329.                 if (oldattr & P_DBL_WIDE)    /* call the complimenting */
  330.                     ps_line(-1, 1, "half-width");   /* postscript function for */
  331.                 if (oldattr & P_DBL_HIGH)    /* any modifiers */
  332.                     ps_line(-1, 1, "half-height");
  333.                 if (oldattr & P_CONDENSED)
  334.                     ps_line(-1, 1, "expand");
  335.             }
  336.             if (aflag)                       /* if an attribute change is */
  337.             {                                /* do any font changes */
  338.                 ps_attr(attrbuff[i][j], oldattr);
  339.                 oldattr = attrbuff[i][j];
  340.                 aflag = 0;
  341.             }
  342.         }
  343.     }
  344.  
  345.     ps_line(-1, 1, "showpage pg restore");          /* end of the page */
  346. }
  347.  
  348. static char vpsbuff[512];                    /* buffer for varargs functions */
  349.  
  350. /*
  351.  * Output a postscript comment
  352. */
  353. #ifdef ANSI
  354. static void ps_comment(char *va_alist, ...)
  355. #else
  356. static void ps_comment(va_alist)
  357. va_dcl
  358. #endif
  359. {
  360.     va_list ap;
  361.     register char *fmt;
  362.  
  363. #ifdef ANSI
  364.     va_start(ap, va_alist);
  365.     fmt = va_alist;
  366. #else
  367.     va_start(ap);
  368.     fmt = va_arg(ap, char *);
  369. #endif
  370.  
  371.     vsprintf(vpsbuff, fmt, ap);
  372.     va_end(ap);
  373.  
  374.     fprintf(devfp, "%% %s\015\012", vpsbuff);
  375. }
  376.  
  377. /*
  378.  * Output a line of postscript (other than a comment or a blank line)
  379. */
  380. #ifdef ANSI
  381. static void ps_line(int otl, int crflag, char *va_alist, ...)
  382. #else
  383. static void ps_line(otl, crflag, va_alist)
  384. int otl;
  385. int crflag;
  386. va_dcl
  387. #endif
  388. {
  389.     va_list ap;
  390.     register char *fmt;
  391.  
  392. #ifdef ANSI
  393.     va_start(ap, va_alist);
  394.     fmt = va_alist;
  395. #else
  396.     va_start(ap);
  397.     fmt = va_arg(ap, char *);
  398. #endif
  399.  
  400.     vsprintf(vpsbuff, fmt, ap);
  401.     va_end(ap);
  402.  
  403.     if (otl == -1)
  404.         otl = ps_tablvl;
  405.  
  406.     while(otl-- > 0)
  407.         fputc('\t', devfp);
  408.  
  409.     fputs(vpsbuff, devfp);
  410.  
  411.     if (crflag)
  412.         fputs("\015\012", devfp);
  413. }
  414.  
  415. /*
  416.  * Output any postscript required for a font change
  417. */
  418. static void ps_attr(nattr, oattr)
  419. int nattr;
  420. int oattr;
  421. {
  422.     char fontname[40];
  423.     static char lastfont[40];
  424.     int fontsize;
  425.     static int lastsize = 0;
  426.     
  427.     if (oattr == P_DUMMY)
  428.     {
  429.         strcpy(lastfont, "");
  430.         lastsize = 0;
  431.     }
  432.  
  433.     if (nattr & P_BOX)                 /* get the initial name for a font */
  434.         strcpy(fontname, "LineChars");
  435.     else if (nattr & P_PS)
  436.         strcpy(fontname, "Helvetica");
  437.     else
  438.         strcpy(fontname, "Courier");
  439.  
  440.     if (nattr & P_BOLD)                /* modify the font name for BOLD */
  441.         strcat(fontname, "-Bold");     /* or ITALIC */
  442.  
  443.     if (nattr & P_ITALIC && !(nattr & P_BOX))
  444.     {
  445.         if (!(nattr & P_BOLD))    
  446.             strcat(fontname, "-");
  447.         strcat(fontname, "Oblique");
  448.     }
  449.  
  450.     if (nattr & P_CPI5)                 /* set the font size required */
  451.         fontsize = 24;
  452.     else if (nattr & P_CPI12)
  453.         fontsize = 10;
  454.     else if (nattr & P_CPI16)
  455.         fontsize = 8;
  456.     else
  457.         fontsize = 12;
  458.  
  459. /* only output the change if really required
  460.  * ie. the attribute may change but the font may not
  461.  *     such as for condensed, etc.
  462. */
  463.     if (lastsize != fontsize || strcmp(lastfont, fontname) != 0)
  464.         ps_line(-1, 1, "/%s findfont %d scalefont setfont", fontname, fontsize);
  465.     lastsize = fontsize;
  466.     strcpy(lastfont, fontname);
  467.  
  468. /* do any relative moves required for super/sub scripting */
  469.     if ( ((oattr & P_SUBSCRIPT) && !(nattr & P_SUBSCRIPT)) ||
  470.         (!(oattr & P_SUPERSCRIPT) && (nattr & P_SUPERSCRIPT)) )
  471.         ps_line(-1, 1, "0 3 rmoveto");
  472.  
  473.     if ( (!(oattr & P_SUBSCRIPT) && (nattr & P_SUBSCRIPT)) ||
  474.         ((oattr & P_SUPERSCRIPT) && !(nattr & P_SUPERSCRIPT)) )
  475.         ps_line(-1, 1, "0 -3 rmoveto");
  476. }
  477.  
  478. /*
  479.  * Output the postscript required by all print jobs
  480.  * ie. define the functions for underline, etc. and define the LineChars
  481.  *     and LineChars-Bold fonts
  482. */
  483. void ps_init()
  484. {
  485.     char *_newpath = "newpath";
  486.     char *_stroke = "stroke";
  487.     char *_end = "end";
  488.     char *_begin = "begin";
  489.     char *_pop = "pop";
  490.     char *_scale = "scale";
  491.     char *_exch = "exch";
  492.  
  493.     ps_comment("!PS-Adobe");
  494.     ps_skip();
  495.     ps_fnbeg("undershow", "show with underline");
  496.     ps_line(-1, 1, "dup stringwidth %s", _pop);
  497.     ps_line(-1, 1, "3 -1 roll");
  498.     ps_line(-1, 1, "uline");
  499.     ps_line(-1, 1, "show");
  500.     ps_fnend();
  501.     ps_skip();
  502.     ps_fnbeg("uline", "do the underlining");
  503.     ps_onelinedef("ps", _exch);
  504.     ps_line(-1, 1, "gsave");
  505.     ps_line(-1, 1, "currentfont /FontInfo get dup");
  506.     ps_line(-1, 1, "/UnderlinePosition get ps mul 1000 div 0 %s rmoveto %s 0 rlineto", _exch, _exch);
  507.     ps_line(-1, 1, "/UnderlineThickness get ps mul 1000 div setlinewidth %s", _stroke);
  508.     ps_line(-1, 1, "grestore");
  509.     ps_fnend();
  510.     ps_skip();
  511.     ps_fnbeg("dbl-height", "double the y-scale");
  512.     ps_line(-1, 1, "1 2 %s", _scale);
  513.     ps_fnend();
  514.     ps_skip();
  515.     ps_fnbeg("half-height", "half the y-scale");
  516.     ps_line(-1, 1, "1 .5 %s", _scale);
  517.     ps_fnend();
  518.     ps_skip();
  519.     ps_fnbeg("dbl-width", "double the x-scale");
  520.     ps_line(-1, 1, "2 1 %s", _scale);
  521.     ps_fnend();
  522.     ps_skip();
  523.     ps_fnbeg("half-width", "half the x-scale");
  524.     ps_line(-1, 1, ".5 1 %s", _scale);
  525.     ps_fnend();
  526.     ps_skip();
  527.     ps_fnbeg("condense", "2/3 the x-scale");
  528.     ps_line(-1, 1, "2 3 div 1 %s", _scale);
  529.     ps_fnend();
  530.     ps_skip();
  531.     ps_fnbeg("expand", "3/2 the x-scale");
  532.     ps_line(-1, 1, "1.5 1 %s", _scale);
  533.     ps_fnend();
  534.     ps_skip();
  535.     ps_comment("Define the PC line drawing character set (LineChars),");
  536.     ps_comment("and the bold equivalent (LineChars-Bold).");
  537.     ps_comment("");
  538.     ps_comment("The characters are drawn on a 1000 by 1000 square then the x is");
  539.     ps_comment("%sd by .0006 to make it line up with the courier character set.", _scale);
  540.     ps_skip();
  541.     ps_line(-1, 1, "10 dict dup %s", _begin);
  542.     ps_skip();
  543.     ps_onelinedef("FontType", "3");
  544.     ps_onelinedef("FontMatrix", "[.0006 0 0 .001 0 0]");
  545.     ps_onelinedef("FontBBox", "[0 0 1000 1000]");
  546.     ps_onelinedef("Encoding", "256 array");
  547.     ps_line(-1, 1, "0 1 255 { Encoding %s /.notdef put } for", _exch);
  548.     ps_encode(0xb0, "shade_block");
  549.     ps_encode(0xb3, "vertical");
  550.     ps_encode(0xb4, "right_tee");
  551.     ps_encode(0xb6, "dsright_tee");
  552.     ps_encode(0xb5, "sdright_tee");
  553.     ps_encode(0xb7, "sdtop_right");
  554.     ps_encode(0xb8, "dstop_right");
  555.     ps_encode(0xb9, "dright_tee");
  556.     ps_encode(0xba, "dvertical");
  557.     ps_encode(0xbb, "dtop_right");
  558.     ps_encode(0xbc, "dbot_right");
  559.     ps_encode(0xbd, "sdbot_right");
  560.     ps_encode(0xbe, "dsbot_right");
  561.     ps_encode(0xbf, "top_right");
  562.     ps_encode(0xc0, "bot_left");
  563.     ps_encode(0xc1, "up_tee");
  564.     ps_encode(0xc2, "down_tee");
  565.     ps_encode(0xc3, "left_tee");
  566.     ps_encode(0xc4, "horizontal");
  567.     ps_encode(0xc5, "cross");
  568.     ps_encode(0xc6, "sdleft_tee");
  569.     ps_encode(0xc7, "dsleft_tee");
  570.     ps_encode(0xc8, "dbot_left");
  571.     ps_encode(0xc9, "dtop_left");
  572.     ps_encode(0xca, "dup_tee");
  573.     ps_encode(0xcb, "ddown_tee");
  574.     ps_encode(0xcc, "dleft_tee");
  575.     ps_encode(0xcd, "dhorizontal");
  576.     ps_encode(0xce, "dcross");
  577.     ps_encode(0xcf, "dsup_tee");
  578.     ps_encode(0xd0, "sdup_tee");
  579.     ps_encode(0xd1, "dsdown_tee");
  580.     ps_encode(0xd2, "sddown_tee");
  581.     ps_encode(0xd3, "sdbot_left");
  582.     ps_encode(0xd4, "dsbot_left");
  583.     ps_encode(0xd5, "dstop_left");
  584.     ps_encode(0xd6, "sdtop_left");
  585.     ps_encode(0xd7, "sdcross");
  586.     ps_encode(0xd8, "dscross");
  587.     ps_encode(0xd9, "bot_right");
  588.     ps_encode(0xda, "top_left");
  589.     ps_encode(0xdb, "solid_block");
  590.     ps_encode(0xdc, "bot_block");
  591.     ps_encode(0xdf, "top_block");
  592.     ps_skip();
  593.     ps_onelinedef("CharProcs", "45 dict");
  594.     ps_line(-1, 1, "CharProcs %s           %% The functions for each character", _begin);
  595.     ps_fnbeg(".notdef", NULL);
  596.     ps_fnend();
  597.     ps_fnbeg("solid_block", NULL);
  598.     ps_line(-1, 1, _newpath);
  599.     ps_moveto(-1, 0, 0, 0);
  600.     ps_lineto(0, 0, 1000, 0);
  601.     ps_lineto(0, 0, 1000, 1000);
  602.     ps_lineto(0, 1, 0, 1000);
  603.     ps_line(-1, 1, "closepath");
  604.     ps_line(-1, 1, "fill");
  605.     ps_fnend();
  606.     ps_fnbeg("shade_block", NULL);
  607.     ps_line(-1, 1, _newpath);
  608.  
  609.     ps_moveto(-1, 0, 125, 0);
  610.     ps_lineto(0, 0, 250, 0);
  611.     ps_moveto(0, 0, 625, 0);
  612.     ps_lineto(0, 1, 750, 0);
  613.  
  614.     ps_moveto(-1, 0, 375, 62);
  615.     ps_lineto(0, 0, 500, 62);
  616.     ps_moveto(0, 0, 875, 62);
  617.     ps_lineto(0, 1, 1000, 62);
  618.  
  619.     ps_moveto(-1, 0, 125, 124);
  620.     ps_lineto(0, 0, 250, 124);
  621.     ps_moveto(0, 0, 625, 124);
  622.     ps_lineto(0, 1, 750, 124);
  623.  
  624.     ps_moveto(-1, 0, 375, 186);
  625.     ps_lineto(0, 0, 500, 186);
  626.     ps_moveto(0, 0, 875, 186);
  627.     ps_lineto(0, 1, 1000, 186);
  628.  
  629.     ps_moveto(-1, 0, 125, 248);
  630.     ps_lineto(0, 0, 250, 248);
  631.     ps_moveto(0, 0, 625, 248);
  632.     ps_lineto(0, 1, 750, 248);
  633.  
  634.     ps_moveto(-1, 0, 375, 310);
  635.     ps_lineto(0, 0, 500, 310);
  636.     ps_moveto(0, 0, 875, 310);
  637.     ps_lineto(0, 1, 1000, 310);
  638.  
  639.     ps_moveto(-1, 0, 125, 372);
  640.     ps_lineto(0, 0, 250, 372);
  641.     ps_moveto(0, 0, 625, 372);
  642.     ps_lineto(0, 1, 750, 372);
  643.  
  644.     ps_moveto(-1, 0, 375, 434);
  645.     ps_lineto(0, 0, 500, 434);
  646.     ps_moveto(0, 0, 875, 434);
  647.     ps_lineto(0, 1, 1000, 434);
  648.  
  649.     ps_moveto(-1, 0, 125, 496);
  650.     ps_lineto(0, 0, 250, 496);
  651.     ps_moveto(0, 0, 625, 496);
  652.     ps_lineto(0, 1, 750, 496);
  653.  
  654.     ps_moveto(-1, 0, 375, 558);
  655.     ps_lineto(0, 0, 500, 558);
  656.     ps_moveto(0, 0, 875, 558);
  657.     ps_lineto(0, 1, 1000, 558);
  658.  
  659.     ps_moveto(-1, 0, 125, 620);
  660.     ps_lineto(0, 0, 250, 620);
  661.     ps_moveto(0, 0, 625, 620);
  662.     ps_lineto(0, 1, 750, 620);
  663.  
  664.     ps_moveto(-1, 0, 375, 682);
  665.     ps_lineto(0, 0, 500, 682);
  666.     ps_moveto(0, 0, 875, 682);
  667.     ps_lineto(0, 1, 1000, 682);
  668.  
  669.     ps_moveto(-1, 0, 125, 744);
  670.     ps_lineto(0, 0, 250, 744);
  671.     ps_moveto(0, 0, 625, 744);
  672.     ps_lineto(0, 1, 750, 744);
  673.  
  674.     ps_moveto(-1, 0, 375, 806);
  675.     ps_lineto(0, 0, 500, 806);
  676.     ps_moveto(0, 0, 875, 806);
  677.     ps_lineto(0, 1, 1000, 806);
  678.  
  679.     ps_moveto(-1, 0, 125, 868);
  680.     ps_lineto(0, 0, 250, 868);
  681.     ps_moveto(0, 0, 625, 868);
  682.     ps_lineto(0, 1, 750, 868);
  683.  
  684.     ps_moveto(-1, 0, 375, 930);
  685.     ps_lineto(0, 0, 500, 930);
  686.     ps_moveto(0, 0, 875, 930);
  687.     ps_lineto(0, 1, 1000, 930);
  688.  
  689.     ps_line(-1, 1, _stroke);
  690.     ps_fnend();
  691.     ps_fnbeg("horizontal", NULL);
  692.     ps_line(-1, 1, _newpath);
  693.     ps_moveto(-1, 0, 0, 500);
  694.     ps_lineto(0, 1, 1000, 500);
  695.     ps_line(-1, 1, _stroke);
  696.     ps_fnend();
  697.     ps_fnbeg("dhorizontal", NULL);
  698.     ps_line(-1, 1, _newpath);
  699.     ps_moveto(-1, 0, 0, 500);
  700.     ps_lineto(0, 0, 1000, 500);
  701.     ps_moveto(0, 0, 0, 700);
  702.     ps_lineto(0, 1, 1000, 700);
  703.     ps_line(-1, 1, _stroke);
  704.     ps_fnend();
  705.     ps_fnbeg("vertical", NULL);
  706.     ps_line(-1, 1, _newpath);
  707.     ps_moveto(-1, 0, 500, 0);
  708.     ps_lineto(0, 1, 500, 1000);
  709.     ps_line(-1, 1, _stroke);
  710.     ps_fnend();
  711.     ps_fnbeg("dvertical", NULL);
  712.     ps_line(-1, 1, _newpath);
  713.     ps_moveto(-1, 0, 400, 0);
  714.     ps_lineto(0, 0, 400, 1000);
  715.     ps_moveto(0, 0, 600, 0);
  716.     ps_lineto(0, 1, 600, 1000);
  717.     ps_line(-1, 1, _stroke);
  718.     ps_fnend();
  719.     ps_fnbeg("cross", NULL);
  720.     ps_line(-1, 1, _newpath);
  721.     ps_moveto(-1, 0, 0, 500);
  722.     ps_lineto(0, 1, 1000, 500);
  723.     ps_moveto(-1, 0, 500, 0);
  724.     ps_lineto(0, 1, 500, 1000);
  725.     ps_line(-1, 1, _stroke);
  726.     ps_fnend();
  727.     ps_fnbeg("dcross", NULL);
  728.     ps_line(-1, 1, _newpath);
  729.     ps_moveto(-1, 0, 0, 500);
  730.     ps_lineto(0, 0, 400, 500);
  731.     ps_lineto(0, 1, 400, 0);
  732.     ps_moveto(-1, 0, 0, 700);
  733.     ps_lineto(0, 0, 400, 700);
  734.     ps_lineto(0, 1, 400, 1000);
  735.     ps_moveto(-1, 0, 600, 0);
  736.     ps_lineto(0, 0, 600, 500);
  737.     ps_lineto(0, 1, 1000, 500);
  738.     ps_moveto(-1, 0, 600, 1000);
  739.     ps_lineto(0, 0, 600, 700);
  740.     ps_lineto(0, 1, 1000, 700);
  741.     ps_line(-1, 1, _stroke);
  742.     ps_fnend();
  743.     ps_fnbeg("dscross", NULL);
  744.     ps_line(-1, 1, _newpath);
  745.     ps_moveto(-1, 0, 0, 500);
  746.     ps_lineto(0, 1, 1000, 500);
  747.     ps_moveto(-1, 0, 0, 700);
  748.     ps_lineto(0, 1, 1000, 700);
  749.     ps_moveto(-1, 0, 500, 0);
  750.     ps_lineto(0, 1, 500, 1000);
  751.     ps_line(-1, 1, _stroke);
  752.     ps_fnend();
  753.     ps_fnbeg("top_left", NULL);
  754.     ps_line(-1, 1, _newpath);
  755.     ps_moveto(-1, 0, 500, 0);
  756.     ps_lineto(0, 0, 500, 500);
  757.     ps_lineto(0, 1, 1000, 500);
  758.     ps_line(-1, 1, _stroke);
  759.     ps_fnend();
  760.     ps_fnbeg("dtop_left", NULL);
  761.     ps_line(-1, 1, _newpath);
  762.     ps_moveto(-1, 0, 400, 0);
  763.     ps_lineto(0, 0, 400, 700);
  764.     ps_lineto(0, 1, 1000, 700);
  765.     ps_moveto(-1, 0, 600, 0);
  766.     ps_lineto(0, 0, 600, 500);
  767.     ps_lineto(0, 1, 1000, 500);
  768.     ps_line(-1, 1, _stroke);
  769.     ps_fnend();
  770.     ps_fnbeg("dstop_left", NULL);
  771.     ps_line(-1, 1, _newpath);
  772.     ps_moveto(-1, 0, 500, 0);
  773.     ps_lineto(0, 0, 500, 700);
  774.     ps_lineto(0, 1, 1000, 700);
  775.     ps_moveto(-1, 0, 500, 500);
  776.     ps_lineto(0, 1, 1000, 500);
  777.     ps_line(-1, 1, _stroke);
  778.     ps_fnend();
  779.     ps_fnbeg("sdtop_left", NULL);
  780.     ps_line(-1, 1, _newpath);
  781.     ps_moveto(-1, 0, 400, 0);
  782.     ps_lineto(0, 0, 400, 500);
  783.     ps_lineto(0, 1, 1000, 500);
  784.     ps_moveto(-1, 0, 600, 0);
  785.     ps_lineto(0, 1, 600, 500);
  786.     ps_line(-1, 1, _stroke);
  787.     ps_fnend();
  788.     ps_fnbeg("top_right", NULL);
  789.     ps_line(-1, 1, _newpath);
  790.     ps_moveto(-1, 0, 0, 500);
  791.     ps_lineto(0, 0, 500, 500);
  792.     ps_lineto(0, 1, 500, 0);
  793.     ps_line(-1, 1, _stroke);
  794.     ps_fnend();
  795.     ps_fnbeg("sdtop_right", NULL);
  796.     ps_line(-1, 1, _newpath);
  797.     ps_moveto(-1, 0, 400, 500);
  798.     ps_lineto(0, 1, 400, 0);
  799.     ps_moveto(-1, 0, 0, 500);
  800.     ps_lineto(0, 0, 600, 500);
  801.     ps_lineto(0, 1, 600, 0);
  802.     ps_line(-1, 1, _stroke);
  803.     ps_fnend();
  804.     ps_fnbeg("dtop_right", NULL);
  805.     ps_line(-1, 1, _newpath);
  806.     ps_moveto(-1, 0, 0, 700);
  807.     ps_lineto(0, 0, 600, 700);
  808.     ps_lineto(0, 1, 600, 0);
  809.     ps_moveto(-1, 0, 0, 500);
  810.     ps_lineto(0, 0, 400, 500);
  811.     ps_lineto(0, 1, 400, 0);
  812.     ps_line(-1, 1, _stroke);
  813.     ps_fnend();
  814.     ps_fnbeg("bot_right", NULL);
  815.     ps_line(-1, 1, _newpath);
  816.     ps_moveto(-1, 0, 0, 500);
  817.     ps_lineto(0, 0, 500, 500);
  818.     ps_lineto(0, 1, 500, 1000);
  819.     ps_line(-1, 1, _stroke);
  820.     ps_fnend();
  821.     ps_fnbeg("dbot_right", NULL);
  822.     ps_line(-1, 1, _newpath);
  823.     ps_moveto(-1, 0, 0, 700);
  824.     ps_lineto(0, 0, 400, 700);
  825.     ps_lineto(0, 1, 400, 1000);
  826.     ps_moveto(-1, 0, 0, 500);
  827.     ps_lineto(0, 0, 600, 500);
  828.     ps_lineto(0, 1, 600, 1000);
  829.     ps_line(-1, 1, _stroke);
  830.     ps_fnend();
  831.     ps_fnbeg("sdbot_right", NULL);
  832.     ps_line(-1, 1, _newpath);
  833.     ps_line(-1, 1, "400 500 moveto 400 1000 lineto");
  834.     ps_moveto(-1, 0, 400, 500);
  835.     ps_lineto(0, 1, 400, 1000);
  836.     ps_moveto(-1, 0, 0, 500);
  837.     ps_lineto(0, 0, 600, 500);
  838.     ps_lineto(0, 1, 600, 1000);
  839.     ps_line(-1, 1, _stroke);
  840.     ps_fnend();
  841.     ps_fnbeg("bot_left", NULL);
  842.     ps_line(-1, 1, _newpath);
  843.     ps_moveto(-1, 0, 500, 1000);
  844.     ps_lineto(0, 0, 500, 500);
  845.     ps_lineto(0, 1, 1000, 500);
  846.     ps_line(-1, 1, _stroke);
  847.     ps_fnend();
  848.     ps_fnbeg("dbot_left", NULL);
  849.     ps_line(-1, 1, _newpath);
  850.     ps_moveto(-1, 0, 600, 1000);
  851.     ps_lineto(0, 0, 600, 700);
  852.     ps_lineto(0, 1, 1000, 700);
  853.     ps_moveto(-1, 0, 400, 1000);
  854.     ps_lineto(0, 0, 400, 500);
  855.     ps_lineto(0, 1, 1000, 500);
  856.     ps_line(-1, 1, _stroke);
  857.     ps_fnend();
  858.     ps_fnbeg("dsbot_left", NULL);
  859.     ps_line(-1, 1, _newpath);
  860.     ps_moveto(-1, 0, 500, 700);
  861.     ps_lineto(0, 1, 1000, 700);
  862.     ps_moveto(-1, 0, 500, 1000);
  863.     ps_lineto(0, 0, 500, 500);
  864.     ps_lineto(0, 1, 1000, 500);
  865.     ps_line(-1, 1, _stroke);
  866.     ps_fnend();
  867.     ps_fnbeg("dsbot_right", NULL);
  868.     ps_line(-1, 1, _newpath);
  869.     ps_moveto(-1, 0, 500, 700);
  870.     ps_lineto(0, 1, 0, 700);
  871.     ps_moveto(-1, 0, 500, 1000);
  872.     ps_lineto(0, 0, 500, 500);
  873.     ps_lineto(0, 1, 0, 500);
  874.     ps_line(-1, 1, _stroke);
  875.     ps_fnend();
  876.     ps_fnbeg("dstop_right", NULL);
  877.     ps_line(-1, 1, _newpath);
  878.     ps_moveto(-1, 0, 0, 700);
  879.     ps_lineto(0, 0, 500, 700);
  880.     ps_lineto(0, 1, 500, 0);
  881.     ps_lineto(-1, 0, 500, 500);
  882.     ps_lineto(0, 1, 0, 500);
  883.     ps_line(-1, 1, _stroke);
  884.     ps_fnend();
  885.     ps_fnbeg("sdbot_left", NULL);
  886.     ps_line(-1, 1, _newpath);
  887.     ps_moveto(-1, 0, 400, 1000);
  888.     ps_lineto(0, 0, 400, 500);
  889.     ps_lineto(0, 1, 1000, 500);
  890.     ps_moveto(-1, 0, 600, 1000);
  891.     ps_lineto(0, 1, 600, 500);
  892.     ps_line(-1, 1, _stroke);
  893.     ps_fnend();
  894.     ps_fnbeg("left_tee", NULL);
  895.     ps_line(-1, 1, _newpath);
  896.     ps_moveto(-1, 0, 500, 0);
  897.     ps_lineto(0, 0, 500, 1000);
  898.     ps_moveto(0, 0, 500, 500);
  899.     ps_lineto(0, 1, 1000, 500);
  900.     ps_line(-1, 1, _stroke);
  901.     ps_fnend();
  902.     ps_fnbeg("dleft_tee", NULL);
  903.     ps_line(-1, 1, _newpath);
  904.     ps_moveto(-1, 0, 400, 0);
  905.     ps_lineto(0, 1, 400, 1000);
  906.     ps_moveto(-1, 0, 600, 0);
  907.     ps_lineto(0, 0, 600, 500);
  908.     ps_lineto(0, 1, 1000, 500);
  909.     ps_moveto(-1, 0, 1000, 700);
  910.     ps_lineto(0, 0, 600, 700);
  911.     ps_lineto(0, 1, 600, 1000);
  912.     ps_line(-1, 1, _stroke);
  913.     ps_fnend();
  914.     ps_fnbeg("sdleft_tee", NULL);
  915.     ps_line(-1, 1, _newpath);
  916.     ps_moveto(-1, 0, 500, 0);
  917.     ps_lineto(0, 1, 500, 1000);
  918.     ps_moveto(-1, 0, 500, 500);
  919.     ps_lineto(0, 1, 1000, 500);
  920.     ps_moveto(-1, 0, 500, 700);
  921.     ps_lineto(0, 1, 1000, 700);
  922.     ps_line(-1, 1, _stroke);
  923.     ps_fnend();
  924.     ps_fnbeg("sdright_tee", NULL);
  925.     ps_line(-1, 1, _newpath);
  926.     ps_moveto(-1, 0, 0, 500);
  927.     ps_lineto(0, 1, 500, 500);
  928.     ps_moveto(-1, 0, 400, 0);
  929.     ps_lineto(0, 1, 400, 1000);
  930.     ps_moveto(-1, 0, 600, 0);
  931.     ps_lineto(0, 0, 600, 500);
  932.     ps_lineto(0, 1, 1000, 500);
  933.     ps_moveto(-1, 0, 1000, 700);
  934.     ps_lineto(0, 0, 600, 700);
  935.     ps_lineto(0, 1, 600, 1000);
  936.     ps_moveto(-1, 0, 0, 700);
  937.     ps_lineto(0, 1, 500, 700);
  938.     ps_moveto(-1, 0, 500, 0);
  939.     ps_lineto(0, 1, 500, 1000);
  940.     ps_line(-1, 1, _stroke);
  941.     ps_fnend();
  942.     ps_fnbeg("dsleft_tee", NULL);
  943.     ps_line(-1, 1, _newpath);
  944.     ps_moveto(-1, 0, 400, 0);
  945.     ps_lineto(0, 0, 400, 1000);
  946.     ps_moveto(0, 0, 600, 0);
  947.     ps_lineto(0, 0, 600, 1000);
  948.     ps_moveto(0, 0, 600, 500);
  949.     ps_lineto(0, 1, 1000, 500);
  950.     ps_line(-1, 1, _stroke);
  951.     ps_fnend();
  952.     ps_fnbeg("sdcross", NULL);
  953.     ps_line(-1, 1, _newpath);
  954.     ps_moveto(-1, 0, 400, 0);
  955.     ps_lineto(0, 0, 400, 1000);
  956.     ps_moveto(0, 0, 600, 0);
  957.     ps_lineto(0, 0, 600, 1000);
  958.     ps_moveto(0, 0, 0, 500);
  959.     ps_lineto(0, 1, 1000, 500);
  960.     ps_line(-1, 1, _stroke);
  961.     ps_fnend();
  962.     ps_fnbeg("right_tee", NULL);
  963.     ps_line(-1, 1, _newpath);
  964.     ps_moveto(-1, 0, 500, 0);
  965.     ps_lineto(0, 0, 500, 1000);
  966.     ps_moveto(0, 0, 500, 500);
  967.     ps_lineto(0, 1, 0, 500);
  968.     ps_line(-1, 1, _stroke);
  969.     ps_fnend();
  970.     ps_fnbeg("dright_tee", NULL);
  971.     ps_line(-1, 1, _newpath);
  972.     ps_moveto(-1, 0, 600, 1000);
  973.     ps_lineto(0, 1, 600, 0);
  974.     ps_moveto(-1, 0, 400, 1000);
  975.     ps_lineto(0, 0, 400, 700);
  976.     ps_lineto(0, 1, 0, 700);
  977.     ps_moveto(-1, 0, 0, 500);
  978.     ps_lineto(0, 0, 400, 500);
  979.     ps_lineto(0, 1, 400, 0);
  980.     ps_line(-1, 1, _stroke);
  981.     ps_fnend();
  982.     ps_fnbeg("dsright_tee", NULL);
  983.     ps_line(-1, 1, _newpath);
  984.     ps_moveto(-1, 0, 600, 0);
  985.     ps_lineto(0, 0, 600, 1000);
  986.     ps_moveto(0, 0, 400, 0);
  987.     ps_lineto(0, 0, 400, 1000);
  988.     ps_moveto(0, 0, 400, 500);
  989.     ps_lineto(0, 1, 0, 500);
  990.     ps_line(-1, 1, _stroke);
  991.     ps_fnend();
  992.     ps_fnbeg("up_tee", NULL);
  993.     ps_line(-1, 1, _newpath);
  994.     ps_moveto(-1, 0, 0, 500);
  995.     ps_lineto(0, 0, 1000, 500);
  996.     ps_moveto(0, 0, 500, 500);
  997.     ps_lineto(0, 1, 500, 1000);
  998.     ps_line(-1, 1, _stroke);
  999.     ps_fnend();
  1000.     ps_fnbeg("dup_tee", NULL);
  1001.     ps_line(-1, 1, _newpath);
  1002.     ps_moveto(-1, 0, 0, 700);
  1003.     ps_lineto(0, 0, 400, 700);
  1004.     ps_lineto(0, 1, 400, 1000);
  1005.     ps_moveto(-1, 0, 600, 1000);
  1006.     ps_lineto(0, 0, 600, 700);
  1007.     ps_lineto(0, 1, 1000, 700);
  1008.     ps_moveto(-1, 0, 0, 500);
  1009.     ps_lineto(0, 1, 1000, 500);
  1010.     ps_line(-1, 1, _stroke);
  1011.     ps_fnend();
  1012.     ps_fnbeg("dsup_tee", NULL);
  1013.     ps_line(-1, 1, _newpath);
  1014.     ps_moveto(-1, 0, 0, 700);
  1015.     ps_lineto(0, 1, 1000, 700);
  1016.     ps_moveto(-1, 0, 0, 500);
  1017.     ps_lineto(0, 1, 1000, 500);
  1018.     ps_moveto(-1, 0, 500, 700);
  1019.     ps_lineto(0, 1, 500, 1000);
  1020.     ps_line(-1, 1, _stroke);
  1021.     ps_fnend();
  1022.     ps_fnbeg("sdup_tee", NULL);
  1023.     ps_line(-1, 1, _newpath);
  1024.     ps_moveto(-1, 0, 0, 500);
  1025.     ps_lineto(0, 1, 1000, 500);
  1026.     ps_moveto(-1, 0, 400, 500);
  1027.     ps_lineto(0, 1, 400, 1000);
  1028.     ps_moveto(-1, 0, 600, 500);
  1029.     ps_lineto(0, 1, 600, 1000);
  1030.     ps_line(-1, 1, _stroke);
  1031.     ps_fnend();
  1032.     ps_fnbeg("down_tee", NULL);
  1033.     ps_line(-1, 1, _newpath);
  1034.     ps_moveto(-1, 0, 0, 500);
  1035.     ps_lineto(0, 0, 1000, 500);
  1036.     ps_moveto(0, 0, 500, 500);
  1037.     ps_lineto(0, 1, 500, 0);
  1038.     ps_line(-1, 1, _stroke);
  1039.     ps_fnend();
  1040.     ps_fnbeg("ddown_tee", NULL);
  1041.     ps_line(-1, 1, _newpath);
  1042.     ps_moveto(-1, 0, 0, 700);
  1043.     ps_lineto(0, 1, 1000, 700);
  1044.     ps_moveto(-1, 0, 0, 500);
  1045.     ps_lineto(0, 0, 400, 500);
  1046.     ps_lineto(0, 1, 400, 0);
  1047.     ps_moveto(-1, 0, 600, 0);
  1048.     ps_lineto(0, 0, 600, 500);
  1049.     ps_lineto(0, 1, 1000, 500);
  1050.     ps_line(-1, 1, _stroke);
  1051.     ps_fnend();
  1052.     ps_fnbeg("dsdown_tee", NULL);
  1053.     ps_line(-1, 1, _newpath);
  1054.     ps_moveto(-1, 0, 0, 500);
  1055.     ps_lineto(0, 0, 1000, 500);
  1056.     ps_moveto(0, 0, 500, 500);
  1057.     ps_lineto(0, 1, 500, 0);
  1058.     ps_moveto(-1, 0, 0, 700);
  1059.     ps_lineto(0, 1, 1000, 700);
  1060.     ps_line(-1, 1, _stroke);
  1061.     ps_fnend();
  1062.     ps_fnbeg("sddown_tee", NULL);
  1063.     ps_line(-1, 1, _newpath);
  1064.     ps_moveto(-1, 0, 0, 500);
  1065.     ps_lineto(0, 1, 1000, 500);
  1066.     ps_moveto(-1, 0, 400, 500);
  1067.     ps_lineto(0, 1, 400, 0);
  1068.     ps_moveto(-1, 0, 600, 500);
  1069.     ps_lineto(0, 1, 600, 0);
  1070.     ps_line(-1, 1, _stroke);
  1071.     ps_fnend();
  1072.     ps_fnbeg("top_block", NULL);
  1073.     ps_line(-1, 1, _newpath);
  1074.     ps_moveto(-1, 0, 0, 500);
  1075.     ps_lineto(0, 0, 1000, 500);
  1076.     ps_lineto(0, 0, 1000, 1000);
  1077.     ps_lineto(0, 1, 0, 1000);
  1078.     ps_line(-1, 1, "closepath");
  1079.     ps_line(-1, 1, "fill");
  1080.     ps_fnend();
  1081.     ps_fnbeg("bot_block", NULL);
  1082.     ps_line(-1, 1, _newpath);
  1083.     ps_moveto(-1, 0, 0, 500);
  1084.     ps_lineto(0, 0, 1000, 500);
  1085.     ps_lineto(0, 0, 1000, 0);
  1086.     ps_lineto(0, 1, 0, 0);
  1087.     ps_line(-1, 1, "closepath");
  1088.     ps_line(-1, 1, "fill");
  1089.     ps_fnend();
  1090.     ps_line(-1, 1, _end);
  1091.     ps_skip();
  1092.     ps_fnbeg("BuildChar", NULL);
  1093.     ps_line(-1, 1, "40 setlinewidth");
  1094.     ps_line(-1, 1, "1000 0");
  1095.     ps_line(-1, 1, "0 0 1000 1000");
  1096.     ps_line(-1, 1, "setcachedevice");
  1097.     ps_line(-1, 1, _exch);
  1098.     ps_line(-1, 1, _begin);
  1099.     ps_tablvl++;
  1100.     ps_line(-1, 1, "Encoding %s get", _exch);
  1101.     ps_line(-1, 1, "CharProcs %s get", _exch);
  1102.     ps_tablvl--;
  1103.     ps_line(-1, 1, _end);
  1104.     ps_line(-1, 1, "exec");
  1105.     ps_fnend();
  1106.     ps_skip();
  1107.     ps_line(-1, 1, _end);
  1108.     ps_skip();
  1109.     ps_line(-1, 1, "/LineChars %s definefont %s", _exch, _pop);
  1110.     ps_skip();
  1111.     ps_comment("Now copy the LineChars font and modify the line width for -Bold");
  1112.     ps_onelinedef("makelinecharsbolddict", "7 dict");
  1113.     ps_fnbeg("MakeLineChars-BoldFont", NULL);
  1114.     ps_line(-1, 1, "makelinecharsbolddict %s", _begin);
  1115.     ps_skip();
  1116.     ps_onelinedef("linecharsdict", "/LineChars findfont");
  1117.     ps_skip();
  1118.     ps_onelinedef("numentries", "linecharsdict maxlength");
  1119.     ps_skip();
  1120.     ps_onelinedef("linecharsbolddict", "numentries dict");
  1121.     ps_skip();
  1122.     ps_line(-1, 1, "linecharsdict");
  1123.     ps_line(-1, 1, "{ %s dup /FID ne", _exch);
  1124.     ps_tablvl++;
  1125.     ps_line(-1, 1, "{ %s linecharsbolddict 3 1 roll put }", _exch);
  1126.     ps_line(-1, 1, "{ %s %s }", _pop, _pop);
  1127.     ps_line(-1, 1, "ifelse");
  1128.     ps_tablvl--;
  1129.     ps_line(-1, 1, "} forall");
  1130.     ps_skip();
  1131.     ps_line(-1, 1, "linecharsbolddict %s", _begin);
  1132.     ps_fnbeg("BuildChar", NULL);
  1133.     ps_line(-1, 1, "80 setlinewidth");
  1134.     ps_line(-1, 1, "1000 0");
  1135.     ps_line(-1, 1, "0 0 1000 1000");
  1136.     ps_line(-1, 1, "setcachedevice");
  1137.     ps_line(-1, 1, _exch);
  1138.     ps_line(-1, 1, _begin);
  1139.     ps_tablvl++;
  1140.     ps_line(-1, 1, "Encoding %s get", _exch);
  1141.     ps_line(-1, 1, "CharProcs %s get", _exch);
  1142.     ps_tablvl--;
  1143.     ps_line(-1, 1, _end);
  1144.     ps_line(-1, 1, "exec");
  1145.     ps_fnend();
  1146.     ps_line(-1, 1, _end);
  1147.     ps_skip();
  1148.     ps_line(-1, 1, "/LineChars-Bold linecharsbolddict definefont %s", _pop);
  1149.     ps_line(-1, 1, _end);
  1150.     ps_fnend();
  1151.     ps_skip();
  1152.     ps_line(-1, 1, "MakeLineChars-BoldFont");
  1153.     ps_skip();
  1154.     ps_comment("End of Prolog");
  1155.     ps_skip();
  1156. }
  1157.  
  1158. static void ps_fnbeg(name, comment)
  1159. char *name;
  1160. char *comment;
  1161. {
  1162.     if (comment == NULL)
  1163.         ps_line(-1, 1, "/%s {", name);
  1164.     else
  1165.         ps_line(-1, 1, "/%s {      %% %s", name, comment);
  1166.     ps_tablvl++;
  1167. }
  1168.  
  1169. static void ps_fnend()
  1170. {
  1171.     ps_line(-1, 1, "} def");
  1172.     ps_tablvl--;
  1173. }
  1174.  
  1175. static void ps_encode(ascval, fnname)
  1176. int ascval;
  1177. char *fnname;
  1178. {
  1179.     ps_line(-1, 1, "Encoding 16#%02x /%s put", ascval, fnname);
  1180. }
  1181.  
  1182. static void ps_onelinedef(name, def)
  1183. char *name;
  1184. char *def;
  1185. {
  1186.     ps_line(-1, 1, "/%s %s def", name, def);
  1187. }
  1188.  
  1189. static void ps_moveto(ort, crflag, c1, c2)
  1190. int ort;
  1191. int crflag;
  1192. int c1, c2;
  1193. {
  1194.     ps_line(ort, crflag, "%d %d moveto ", c1, c2);
  1195. }
  1196.  
  1197. static void ps_lineto(ort, crflag, c1, c2)
  1198. int ort;
  1199. int crflag;
  1200. int c1, c2;
  1201. {
  1202.     ps_line(ort, crflag, "%d %d lineto ", c1, c2);
  1203. }
  1204.