[BACK]Return to post.trm CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / term

Annotation of OpenXM_contrib/gnuplot/term/post.trm, Revision 1.1.1.2

1.1       maekawa     1: /*
1.1.1.2 ! maekawa     2:  * $Id: post.trm,v 1.21.2.1 1999/08/19 14:16:33 lhecking Exp $
1.1       maekawa     3:  */
                      4:
                      5: /* GNUPLOT - post.trm */
                      6:
                      7: /*[
                      8:  * Copyright 1990 - 1993, 1998
                      9:  *
                     10:  * Permission to use, copy, and distribute this software and its
                     11:  * documentation for any purpose with or without fee is hereby granted,
                     12:  * provided that the above copyright notice appear in all copies and
                     13:  * that both that copyright notice and this permission notice appear
                     14:  * in supporting documentation.
                     15:  *
                     16:  * Permission to modify the software is granted, but not the right to
                     17:  * distribute the complete modified source code.  Modifications are to
                     18:  * be distributed as patches to the released version.  Permission to
                     19:  * distribute binaries produced by compiling modified sources is granted,
                     20:  * provided you
                     21:  *   1. distribute the corresponding source modifications from the
                     22:  *    released version in the form of a patch file along with the binaries,
                     23:  *   2. add special version identification to distinguish your version
                     24:  *    in addition to the base release version number,
                     25:  *   3. provide your name and address as the primary contact for the
                     26:  *    support of your modified version, and
                     27:  *   4. retain our contact information in regard to use of the base
                     28:  *    software.
                     29:  * Permission to distribute the released version of the source code along
                     30:  * with corresponding source modifications in the form of a patch file is
                     31:  * granted with same provisions 2 through 4 for binary distributions.
                     32:  *
                     33:  * This software is provided "as is" without express or implied warranty
                     34:  * to the extent permitted by applicable law.
                     35: ]*/
                     36:
                     37: /*
                     38:  * This terminal driver supports:
                     39:  *     postscript
                     40:  *
                     41:  * AUTHORS
                     42:  *  Russell Lang
                     43:  *
                     44:  * modified 10/5/95 by drd - put in support for other postscript drivers
                     45:  * (enhpost, pslatex, ...) so they dont have to work quite so hard
                     46:  *
                     47:  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
                     48:  *
                     49:  * The 'postscript' driver produces landscape output 10" wide and 7" high.
                     50:  * To change font to Times-Roman and font size to 20pts use
                     51:  * 'set term postscript "Times-Roman" 20'.
                     52:  * To get a smaller (5" x 3.5") eps output use 'set term post eps'
                     53:  * and make only one plot per file.  Font size for eps will be half
                     54:  * the specified size.
                     55:  *
                     56:  * Erik Luijten 30/5/97: added %%CreationDate, made %%DocumentFonts conform
                     57:  *                       to DSC, added version no. and patchl. to %%Creator
                     58:  */
                     59:
                     60: #include "driver.h"
                     61:
                     62: #ifdef TERM_REGISTER
                     63: register_term(post)
                     64: #endif
                     65:
                     66: #ifdef TERM_PROTO
                     67: TERM_PUBLIC void PS_options __PROTO((void));
                     68: TERM_PUBLIC void PS_common_init __PROTO((int encap, int portrait, int uses_fonts, unsigned int xoff, unsigned int yoff, unsigned int bb_xmin, unsigned int bb_ymin, unsigned int bb_xmax, unsigned int bb_ymax, char **dict));
                     69: TERM_PUBLIC void PS_init __PROTO((void));
                     70: TERM_PUBLIC void PS_graphics __PROTO((void));
                     71: TERM_PUBLIC void PS_text __PROTO((void));
                     72: TERM_PUBLIC void PS_reset __PROTO((void));
                     73: TERM_PUBLIC void PS_linetype __PROTO((int linetype));
                     74: TERM_PUBLIC void PS_move __PROTO((unsigned int x, unsigned int y));
                     75: TERM_PUBLIC void PS_vector __PROTO((unsigned int x, unsigned int y));
                     76: TERM_PUBLIC void PS_put_text __PROTO((unsigned int x, unsigned int y, char *str));
                     77: TERM_PUBLIC void ENHPS_put_text __PROTO((unsigned int x, unsigned int y, char *str));
                     78: TERM_PUBLIC int PS_text_angle __PROTO((int ang));
                     79: TERM_PUBLIC int PS_justify_text __PROTO((enum JUSTIFY mode));
                     80: TERM_PUBLIC void PS_point __PROTO((unsigned int x, unsigned int y, int number));
                     81: TERM_PUBLIC int PS_set_font __PROTO((char * font));
                     82: TERM_PUBLIC int ENHPS_set_font __PROTO((char * font));
                     83: TERM_PUBLIC void PS_fillbox __PROTO((int style, unsigned int x1, unsigned int y1, unsigned int width, unsigned int height));
                     84: TERM_PUBLIC void PS_linewidth __PROTO((double linewidth)); /* JFi [linewidth] */
                     85: TERM_PUBLIC void PS_pointsize __PROTO((double ptsize)); /* JFi [pointsize] */
                     86:
                     87: #define PS_POINT_TYPES 8
                     88: #define PS_XOFF        50      /* page offset in pts */
                     89: #define PS_YOFF        50
                     90: #define PS_XMAX 7200 /* assumes landscape */
                     91: #define PS_YMAX 5040
                     92: #define PS_XLAST (PS_XMAX - 1)
                     93: #define PS_YLAST (PS_YMAX - 1)
                     94: #define PS_VTIC (PS_YMAX/80)
                     95: #define PS_HTIC (PS_YMAX/80)
                     96: #define PS_SC (10)                             /* scale is 1pt = 10 units */
                     97: #define        PS_LW (0.5*PS_SC)               /* linewidth = 0.5 pts */
                     98: #define PS_VCHAR (14*PS_SC)            /* default is 14 point characters */
                     99: #define PS_HCHAR (14*PS_SC*6/10)
                    100:
                    101: #endif
                    102:
                    103:
                    104: #ifndef TERM_PROTO_ONLY
                    105:
                    106: #ifdef TERM_BODY
                    107: /* PostScript driver by Russell Lang, rjl@monu1.cc.monash.edu.au */
                    108:
                    109: /* From version.c */
                    110: extern char version[];
                    111: extern char patchlevel[];
                    112:
                    113: #define PS_FLUSH_PATH \
                    114:     if (ps_path_count) { fprintf(gpoutfile, "stroke "); ps_path_count = 0; }
                    115:
                    116: static char *PS_RememberFont __PROTO((char *fname, int reencode));
                    117: static void ENHPS_put_text __PROTO((unsigned int x, unsigned int y, char *str));
                    118: static char *ENHPS_recurse __PROTO((char *p, TBOOLEAN brace, char *fontname, double fontsize, double base, TBOOLEAN widthflag, TBOOLEAN showflag));
                    119: static char ps_font[MAX_ID_LEN+1] = "Helvetica" ; /* name of font */
                    120: static int ps_fontsize = 14;                                    /* size of font in pts */
                    121:
                    122: /* for enhanced mode, we keep a separate font name and size, which
                    123:  * is restored to the default value on font of ""
                    124:  */
                    125: static char ps_enh_font[MAX_ID_LEN+1];
                    126: static int  ps_enh_fontsize;
                    127:
                    128: static TBOOLEAN ps_portrait = FALSE;                            /* vertical page */
                    129: static TBOOLEAN ps_color = FALSE;
                    130: static TBOOLEAN ps_solid = FALSE;              /*  use solid lines */
                    131: static TBOOLEAN ps_eps = FALSE;        /* Is this for an eps file? */
                    132:                        /* Added by Robert Davis <davis@ecn.purdue.edu> */
                    133: static int ps_page=0;                  /* page count */
                    134: static int ps_path_count=0;    /* count of lines in path */
                    135: static int ps_ang=0;                   /* text angle */
                    136: static enum JUSTIFY ps_justify=LEFT;   /* text is flush left */
                    137:
                    138: /* added by Matt Heffron <heffron@falstaff.css.beckman.com> */
                    139: static TBOOLEAN ps_duplex_state = FALSE;
                    140: static TBOOLEAN ps_duplex_option = FALSE;
                    141:
                    142: static char GPFAR * GPFAR PS_header[] = {
                    143: "/M {moveto} bind def\n",
                    144: "/L {lineto} bind def\n",
                    145: "/R {rmoveto} bind def\n",
                    146: "/V {rlineto} bind def\n",
                    147: "/vpt2 vpt 2 mul def\n",
                    148: "/hpt2 hpt 2 mul def\n",
                    149: /* flush left show */
                    150: "/Lshow { currentpoint stroke M\n",
                    151: "  0 vshift R show } def\n",
                    152: /* flush right show */
                    153: "/Rshow { currentpoint stroke M\n",
                    154: "  dup stringwidth pop neg vshift R show } def\n",
                    155: /* centred show */
                    156: "/Cshow { currentpoint stroke M\n",
                    157: "  dup stringwidth pop -2 div vshift R show } def\n",
                    158: /* set pointsize */
                    159: "/UP { dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def\n",
                    160: "  /hpt2 hpt 2 mul def /vpt2 vpt 2 mul def } def\n",
                    161: /* Dash or Color Line */
                    162: "/DL { Color {setrgbcolor Solid {pop []} if 0 setdash }\n",
                    163: " {pop pop pop Solid {pop []} if 0 setdash} ifelse } def\n",
                    164: /* Border Lines */
1.1.1.2 ! maekawa   165: "/BL { stroke userlinewidth 2 mul setlinewidth } def\n",
1.1       maekawa   166: /* Axes Lines */
1.1.1.2 ! maekawa   167: "/AL { stroke userlinewidth 2 div setlinewidth } def\n",
1.1       maekawa   168: /* set user defined linewidth */
1.1.1.2 ! maekawa   169: "/UL { dup gnulinewidth mul /userlinewidth exch def\n",
        !           170: "      10 mul /udl exch def } def\n",
1.1       maekawa   171: /* Plot Lines */
                    172: "/PL { stroke userlinewidth setlinewidth } def\n",
                    173: /* Line Types */
                    174: "/LTb { BL [] 0 0 0 DL } def\n", /* border */
1.1.1.2 ! maekawa   175: "/LTa { AL [1 udl mul 2 udl mul] 0 setdash 0 0 0 setrgbcolor } def\n", /* axes */
1.1       maekawa   176: "/LT0 { PL [] 1 0 0 DL } def\n",
                    177: "/LT1 { PL [4 dl 2 dl] 0 1 0 DL } def\n",
                    178: "/LT2 { PL [2 dl 3 dl] 0 0 1 DL } def\n",
                    179: "/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def\n",
                    180: "/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def\n",
                    181: "/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def\n",
                    182: "/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def\n",
                    183: "/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def\n",
                    184: "/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def\n",
                    185: /* Point (Round) */    /* Matt Heffron make it round */
                    186: "/Pnt { stroke [] 0 setdash\n",
                    187: "   gsave 1 setlinecap M 0 0 V stroke grestore } def\n",
                    188:
                    189: /* Diamond */
                    190: "/Dia { stroke [] 0 setdash 2 copy vpt add M\n",
                    191: "  hpt neg vpt neg V hpt vpt neg V\n",
                    192: "  hpt vpt V hpt neg vpt V closepath stroke\n",
                    193: "  Pnt } def\n",
                    194:
                    195: /* Plus */
                    196: "/Pls { stroke [] 0 setdash vpt sub M 0 vpt2 V\n",
                    197: "  currentpoint stroke M\n",
                    198: "  hpt neg vpt neg R hpt2 0 V stroke\n",
                    199: "  } def\n",
                    200:
                    201: /* Box */
                    202: "/Box { stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M\n",
                    203: "  0 vpt2 neg V hpt2 0 V 0 vpt2 V\n",
                    204: "  hpt2 neg 0 V closepath stroke\n",
                    205: "  Pnt } def\n",
                    206:
                    207: /* Cross (X) */
                    208: "/Crs { stroke [] 0 setdash exch hpt sub exch vpt add M\n",
                    209: "  hpt2 vpt2 neg V currentpoint stroke M\n",
                    210: "  hpt2 neg 0 R hpt2 vpt2 V stroke } def\n",
                    211:
                    212: /* Triangle Up*/
                    213: "/TriU { stroke [] 0 setdash 2 copy vpt 1.12 mul add M\n",
                    214: "  hpt neg vpt -1.62 mul V\n",
                    215: "  hpt 2 mul 0 V\n",
                    216: "  hpt neg vpt 1.62 mul V closepath stroke\n",
                    217: "  Pnt  } def\n",
                    218:
                    219: /* Star */
                    220: "/Star { 2 copy Pls Crs } def\n",
                    221:
                    222: /* div added filed box */
                    223: /* Filled Box */
                    224: "/BoxF { stroke [] 0 setdash exch hpt sub exch vpt add M\n",
                    225: "  0 vpt2 neg V  hpt2 0 V  0 vpt2 V\n",
                    226: "  hpt2 neg 0 V  closepath fill } def\n",
                    227:
                    228: /* div added filled triangle */
                    229: /* Triangle Up, Filled */
                    230: "/TriUF { stroke [] 0 setdash vpt 1.12 mul add M\n",
                    231: "  hpt neg vpt -1.62 mul V\n",
                    232: "  hpt 2 mul 0 V\n",
                    233: "  hpt neg vpt 1.62 mul V closepath fill } def\n",
                    234:
                    235: /* Matt Heffron: added a few more types */
                    236: /* Triangle Down */
                    237: "/TriD { stroke [] 0 setdash 2 copy vpt 1.12 mul sub M\n",
                    238: "  hpt neg vpt 1.62 mul V\n",
                    239: "  hpt 2 mul 0 V\n",
                    240: "  hpt neg vpt -1.62 mul V closepath stroke\n",
                    241: "  Pnt  } def\n",
                    242:
                    243: /* Triangle Down, Filled*/
                    244: "/TriDF { stroke [] 0 setdash vpt 1.12 mul sub M\n",
                    245: "  hpt neg vpt 1.62 mul V\n",
                    246: "  hpt 2 mul 0 V\n",
                    247: "  hpt neg vpt -1.62 mul V closepath fill} def\n",
                    248:
                    249: /* Diamond, Filled */
                    250: "/DiaF { stroke [] 0 setdash vpt add M\n",
                    251: "  hpt neg vpt neg V hpt vpt neg V\n",
                    252: "  hpt vpt V hpt neg vpt V closepath fill } def\n",
                    253:
                    254: /* Pentagon */
                    255: "/Pent { stroke [] 0 setdash 2 copy gsave\n",
                    256: "  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n",
                    257: "  closepath stroke grestore Pnt } def\n",
                    258:
                    259: /* Pentagon, Filled */
                    260: "/PentF { stroke [] 0 setdash gsave\n",
                    261: "  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n",
                    262: "  closepath fill grestore } def\n",
                    263:
                    264: /* Circle */
                    265: "/Circle { stroke [] 0 setdash 2 copy\n",
                    266: "  hpt 0 360 arc stroke Pnt } def\n",
                    267:
                    268: /* Circle,Filled */
                    269: "/CircleF { stroke [] 0 setdash hpt 0 360 arc fill } def\n",
                    270: /* 16 differently filled circles */
                    271: "/C0 { BL [] 0 setdash 2 copy moveto vpt 90 450  arc } bind def\n",
                    272: "/C1 { BL [] 0 setdash 2 copy        moveto\n",
                    273: "       2 copy  vpt 0 90 arc closepath fill\n",
                    274: "               vpt 0 360 arc closepath } bind def\n",
                    275: "/C2 { BL [] 0 setdash 2 copy moveto\n",
                    276: "       2 copy  vpt 90 180 arc closepath fill\n",
                    277: "               vpt 0 360 arc closepath } bind def\n",
                    278: "/C3 { BL [] 0 setdash 2 copy moveto\n",
                    279: "       2 copy  vpt 0 180 arc closepath fill\n",
                    280: "               vpt 0 360 arc closepath } bind def\n",
                    281: "/C4 { BL [] 0 setdash 2 copy moveto\n",
                    282: "       2 copy  vpt 180 270 arc closepath fill\n",
                    283: "               vpt 0 360 arc closepath } bind def\n",
                    284: "/C5 { BL [] 0 setdash 2 copy moveto\n",
                    285: "       2 copy  vpt 0 90 arc\n",
                    286: "       2 copy moveto\n",
                    287: "       2 copy  vpt 180 270 arc closepath fill\n",
                    288: "               vpt 0 360 arc } bind def\n",
                    289: "/C6 { BL [] 0 setdash 2 copy moveto\n",
                    290: "      2 copy  vpt 90 270 arc closepath fill\n",
                    291: "              vpt 0 360 arc closepath } bind def\n",
                    292: "/C7 { BL [] 0 setdash 2 copy moveto\n",
                    293: "      2 copy  vpt 0 270 arc closepath fill\n",
                    294: "              vpt 0 360 arc closepath } bind def\n",
                    295: "/C8 { BL [] 0 setdash 2 copy moveto\n",
                    296: "      2 copy vpt 270 360 arc closepath fill\n",
                    297: "              vpt 0 360 arc closepath } bind def\n",
                    298: "/C9 { BL [] 0 setdash 2 copy moveto\n",
                    299: "      2 copy  vpt 270 450 arc closepath fill\n",
                    300: "              vpt 0 360 arc closepath } bind def\n",
                    301: "/C10 { BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill\n",
                    302: "       2 copy moveto\n",
                    303: "       2 copy vpt 90 180 arc closepath fill\n",
                    304: "               vpt 0 360 arc closepath } bind def\n",
                    305: "/C11 { BL [] 0 setdash 2 copy moveto\n",
                    306: "       2 copy  vpt 0 180 arc closepath fill\n",
                    307: "       2 copy moveto\n",
                    308: "       2 copy  vpt 270 360 arc closepath fill\n",
                    309: "               vpt 0 360 arc closepath } bind def\n",
                    310: "/C12 { BL [] 0 setdash 2 copy moveto\n",
                    311: "       2 copy  vpt 180 360 arc closepath fill\n",
                    312: "               vpt 0 360 arc closepath } bind def\n",
                    313: "/C13 { BL [] 0 setdash  2 copy moveto\n",
                    314: "       2 copy  vpt 0 90 arc closepath fill\n",
                    315: "       2 copy moveto\n",
                    316: "       2 copy  vpt 180 360 arc closepath fill\n",
                    317: "               vpt 0 360 arc closepath } bind def\n",
                    318: "/C14 { BL [] 0 setdash 2 copy moveto\n",
                    319: "       2 copy  vpt 90 360 arc closepath fill\n",
                    320: "               vpt 0 360 arc } bind def\n",
                    321: "/C15 { BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill\n",
                    322: "               vpt 0 360 arc closepath } bind def\n",
                    323:
                    324: /* Auxiliary definitions for rectangles */
                    325:
                    326: "/Rec   { newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto\n",
                    327: "       neg 0 rlineto closepath } bind def\n",
                    328: "/Square { dup Rec } bind def\n",
                    329: "/Bsquare { vpt sub exch vpt sub exch vpt2 Square } bind def\n",
                    330:
                    331: /* 16 differently filled squares */
                    332:
                    333: "/S0 { BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare } bind def\n",
                    334: "/S1 { BL [] 0 setdash 2 copy vpt Square fill Bsquare } bind def\n",
                    335: "/S2 { BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def\n",
                    336: "/S3 { BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare } bind def\n",
                    337: "/S4 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def\n",
                    338: "/S5 { BL [] 0 setdash 2 copy 2 copy vpt Square fill\n",
                    339: "       exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def\n",
                    340: "/S6 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare } bind def\n",
                    341: "/S7 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill\n",
                    342: "       2 copy vpt Square fill\n",
                    343: "       Bsquare } bind def\n",
                    344: "/S8 { BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare } bind def\n",
                    345: "/S9 { BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare } bind def\n",
                    346: "/S10 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill\n",
                    347: "       Bsquare } bind def\n",
                    348: "/S11 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill\n",
                    349: "       Bsquare } bind def\n",
                    350: "/S12 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare } bind def\n",
                    351: "/S13 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill\n",
                    352: "       2 copy vpt Square fill Bsquare } bind def\n",
                    353: "/S14 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill\n",
                    354: "       2 copy exch vpt sub exch vpt Square fill Bsquare } bind def\n",
                    355: "/S15 { BL [] 0 setdash 2 copy Bsquare fill Bsquare } bind def\n",
                    356:
                    357: /* 16 different diamonds (actually just rotated squares) */
                    358:
                    359: "/D0 { gsave translate 45 rotate 0 0 S0 stroke grestore } bind def\n",
                    360: "/D1 { gsave translate 45 rotate 0 0 S1 stroke grestore } bind def\n",
                    361: "/D2 { gsave translate 45 rotate 0 0 S2 stroke grestore } bind def\n",
                    362: "/D3 { gsave translate 45 rotate 0 0 S3 stroke grestore } bind def\n",
                    363: "/D4 { gsave translate 45 rotate 0 0 S4 stroke grestore } bind def\n",
                    364: "/D5 { gsave translate 45 rotate 0 0 S5 stroke grestore } bind def\n",
                    365: "/D6 { gsave translate 45 rotate 0 0 S6 stroke grestore } bind def\n",
                    366: "/D7 { gsave translate 45 rotate 0 0 S7 stroke grestore } bind def\n",
                    367: "/D8 { gsave translate 45 rotate 0 0 S8 stroke grestore } bind def\n",
                    368: "/D9 { gsave translate 45 rotate 0 0 S9 stroke grestore } bind def\n",
                    369: "/D10 { gsave translate 45 rotate 0 0 S10 stroke grestore } bind def\n",
                    370: "/D11 { gsave translate 45 rotate 0 0 S11 stroke grestore } bind def\n",
                    371: "/D12 { gsave translate 45 rotate 0 0 S12 stroke grestore } bind def\n",
                    372: "/D13 { gsave translate 45 rotate 0 0 S13 stroke grestore } bind def\n",
                    373: "/D14 { gsave translate 45 rotate 0 0 S14 stroke grestore } bind def\n",
                    374: "/D15 { gsave translate 45 rotate 0 0 S15 stroke grestore } bind def\n",
                    375:
                    376: /* closed figures w/o the point in the middle (added by Dick Crawford) */
                    377:
                    378: /* Diamond */
                    379: "/DiaE { stroke [] 0 setdash vpt add M\n",
                    380: "  hpt neg vpt neg V hpt vpt neg V\n",
                    381: "  hpt vpt V hpt neg vpt V closepath stroke } def\n",
                    382:
                    383: /* Box */
                    384: "/BoxE { stroke [] 0 setdash exch hpt sub exch vpt add M\n",
                    385: "  0 vpt2 neg V hpt2 0 V 0 vpt2 V\n",
                    386: "  hpt2 neg 0 V closepath stroke } def\n",
                    387:
                    388: /* Triangle Up*/
                    389: "/TriUE { stroke [] 0 setdash vpt 1.12 mul add M\n",
                    390: "  hpt neg vpt -1.62 mul V\n",
                    391: "  hpt 2 mul 0 V\n",
                    392: "  hpt neg vpt 1.62 mul V closepath stroke } def\n",
                    393:
                    394: /* Triangle Down */
                    395: "/TriDE { stroke [] 0 setdash vpt 1.12 mul sub M\n",
                    396: "  hpt neg vpt 1.62 mul V\n",
                    397: "  hpt 2 mul 0 V\n",
                    398: "  hpt neg vpt -1.62 mul V closepath stroke } def\n",
                    399:
                    400: /* Pentagon */
                    401: "/PentE { stroke [] 0 setdash gsave\n",
                    402: "  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n",
                    403: "  closepath stroke grestore } def\n",
                    404:
                    405: /* Circle */
                    406: "/CircE { stroke [] 0 setdash \n",
                    407: "  hpt 0 360 arc stroke } def\n",
                    408:
                    409: /* opaque closed figures w/o the point in the middle (added by Dick Crawford) */
                    410:
                    411: "/Opaque { gsave closepath 1 setgray fill grestore 0 setgray closepath } def\n",
                    412:
                    413: /* Diamond */
                    414: "/DiaW { stroke [] 0 setdash vpt add M\n",
                    415: "  hpt neg vpt neg V hpt vpt neg V\n",
                    416: "  hpt vpt V hpt neg vpt V Opaque stroke } def\n",
                    417:
                    418: /* Box */
                    419: "/BoxW { stroke [] 0 setdash exch hpt sub exch vpt add M\n",
                    420: "  0 vpt2 neg V hpt2 0 V 0 vpt2 V\n",
                    421: "  hpt2 neg 0 V Opaque stroke } def\n",
                    422:
                    423: /* Triangle Up*/
                    424: "/TriUW { stroke [] 0 setdash vpt 1.12 mul add M\n",
                    425: "  hpt neg vpt -1.62 mul V\n",
                    426: "  hpt 2 mul 0 V\n",
                    427: "  hpt neg vpt 1.62 mul V Opaque stroke } def\n",
                    428:
                    429: /* Triangle Down */
                    430: "/TriDW { stroke [] 0 setdash vpt 1.12 mul sub M\n",
                    431: "  hpt neg vpt 1.62 mul V\n",
                    432: "  hpt 2 mul 0 V\n",
                    433: "  hpt neg vpt -1.62 mul V Opaque stroke } def\n",
                    434:
                    435: /* Pentagon */
                    436: "/PentW { stroke [] 0 setdash gsave\n",
                    437: "  translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n",
                    438: "  Opaque stroke grestore } def\n",
                    439:
                    440: /* Circle */
                    441: "/CircW { stroke [] 0 setdash \n",
                    442: "  hpt 0 360 arc Opaque stroke } def\n",
                    443:
                    444: /* filled box : usage   x1 y1 x2 y2 BoxFill */
                    445: "/BoxFill { gsave Rec 1 setgray fill grestore } def\n",
                    446:
                    447: NULL
                    448: };
                    449:
                    450: static char GPFAR * GPFAR ENHPS_header[] = {
                    451: /* For MFshow and MFwidth the tos is an array with the string and font info:  */
                    452: /*     [<fontname (a string)> <fontsize> <vertical offset> <width significant?> <printed?> <text string>]  */
                    453:
                    454: "/MFshow {{dup dup 0 get findfont exch 1 get scalefont setfont\n",
                    455: "     [ currentpoint ] exch dup 2 get 0 exch rmoveto dup dup 5 get exch 4 get\n",
                    456: "     {show} {stringwidth pop 0 rmoveto}ifelse dup 3 get\n",
                    457: "     {2 get neg 0 exch rmoveto pop} {pop aload pop moveto}ifelse} forall} bind def\n",
                    458: "/MFwidth {0 exch {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont\n",
                    459: "      5 get stringwidth pop add}\n",
                    460: "    {pop} ifelse} forall} bind def\n",
                    461:
                    462: /* flush left show */
                    463: "/MLshow { currentpoint stroke M\n",
                    464: "  0 exch R MFshow } bind def\n",
                    465:
                    466: /* flush right show */
                    467: "/MRshow { currentpoint stroke M\n",
                    468: "  exch dup MFwidth neg 3 -1 roll R MFshow } def\n",
                    469:
                    470: /* centred show */
                    471: "/MCshow { currentpoint stroke M\n",
                    472: "  exch dup MFwidth -2 div 3 -1 roll R MFshow } def\n",
                    473: NULL
                    474: };
                    475:
                    476: /* added to enhpost by Matt Heffron <heffron@falstaff.css.beckman.com> */
                    477: /* moved to post.trm by drd */
                    478:
                    479: static struct PS_FontName {
                    480:        char *name;
                    481:        struct PS_FontName *next;
                    482: } *PS_DocFonts = NULL;
                    483:
                    484: /* given a font, look in store to see if it is there already
                    485:  * if so, return NULL. If not, reencode it if allowed to, otherwise
                    486:  * return an appropriate re-encode string
                    487:  */
                    488:
                    489: TERM_PUBLIC char *PS_RememberFont(fname, can_reencode)
                    490: char *fname;
                    491: int can_reencode;
                    492: {
                    493:        struct PS_FontName *fnp;
                    494:        char *recode = NULL;
                    495:
                    496:    for (fnp=PS_DocFonts; fnp ; fnp = fnp->next)
                    497:                if (strcmp(fnp->name, fname)==0)
                    498:                        return NULL;
                    499:
                    500:        /* we did not find the name */
                    501:
                    502:    fnp = (struct PS_FontName *)gp_alloc(sizeof(struct PS_FontName), "PostScript Font record");
                    503:    fnp->name = gp_alloc(1+strlen(fname), "PostScript Font name");
                    504:    strcpy(fnp->name, fname);
                    505:    fnp->next = PS_DocFonts;
                    506:    PS_DocFonts = fnp;
                    507:
                    508:        switch(encoding)
                    509:        {
                    510:                case ENCODING_ISO_8859_1:
                    511:                        recode = "reencodeISO def\n";
                    512:                        break;
                    513:                case ENCODING_CP_437:
                    514:                        recode = "reencodeCP437 def\n";
                    515:                        break;
                    516:                case ENCODING_CP_850 :
                    517:                        recode = "reencodeCP850 def\n";
                    518:                        break;
                    519:        }
                    520:
                    521:        if (can_reencode && recode)
                    522:        {       fprintf(gpoutfile,"/%s %s",fname, recode);
                    523:                return NULL;
                    524:        }
                    525:        else
                    526:                return recode;
                    527: }
                    528:
                    529: static int PS_pen_x, PS_pen_y;
                    530: static int PS_taken;
                    531: static int PS_linetype_last;
                    532: static TBOOLEAN PS_relative_ok;
                    533:
                    534: TERM_PUBLIC void PS_options()
                    535: {
                    536:        if (!END_OF_COMMAND) {
                    537:                if (almost_equals(c_token,"p$ortrait")) {
                    538:                        ps_portrait=TRUE;
                    539:                        ps_eps=FALSE;
                    540:                        c_token++;
                    541:                }
                    542:                else if (almost_equals(c_token,"l$andscape")) {
                    543:                        ps_portrait=FALSE;
                    544:                        ps_eps=FALSE;
                    545:                        c_token++;
                    546:                }
                    547:                else if (almost_equals(c_token,"ep$sf")) {
                    548:                        ps_portrait=TRUE;
                    549:                        ps_eps = TRUE;
                    550:                        c_token++;
                    551:                }
                    552:                else if (almost_equals(c_token,"d$efault")) {
                    553:                        ps_portrait=FALSE;
                    554:                        ps_eps=FALSE;
                    555:                        ps_color=FALSE;
                    556:                        ps_solid=FALSE;
                    557:                        ps_duplex_option=FALSE;
                    558:                        strcpy(ps_font,"Helvetica");
                    559:                        ps_fontsize = 14;
                    560:                        term->v_char = (unsigned int)(ps_fontsize*PS_SC);
                    561:                        term->h_char = (unsigned int)(ps_fontsize*PS_SC*6/10);
                    562:                        term->put_text = PS_put_text;
                    563:                        c_token++;
                    564:                }
                    565:        }
                    566:
                    567:        if (almost_equals(c_token, "enh$anced")) {
                    568:                term->put_text = ENHPS_put_text;
                    569:                term->set_font = ENHPS_set_font;
                    570:                ++c_token;
                    571:        } else if (almost_equals(c_token, "noenh$anced")) {
                    572:                term->put_text = PS_put_text;
                    573:                term->set_font = PS_set_font;
                    574:                ++c_token;
                    575:        }
                    576:
                    577:        if (!END_OF_COMMAND) {
                    578:                if (almost_equals(c_token,"m$onochrome")) {
                    579:                        ps_color=FALSE;
                    580:                        c_token++;
                    581:                }
                    582:                else if (almost_equals(c_token,"c$olor")
                    583:                         || almost_equals(c_token,"c$olour")) {
                    584:                        ps_color=TRUE;
                    585:                        c_token++;
                    586:                }
                    587:        }
                    588:
                    589:        if (!END_OF_COMMAND) {
                    590:                if (almost_equals(c_token,"so$lid")) {
                    591:                        ps_solid=TRUE;
                    592:                        c_token++;
                    593:                }
                    594:                else if (almost_equals(c_token,"da$shed")) {
                    595:                        ps_solid=FALSE;
                    596:                        c_token++;
                    597:                }
                    598:        }
                    599:
                    600:        if (!END_OF_COMMAND) {
                    601:                if (almost_equals(c_token,"si$mplex")) {
                    602:                        ps_duplex_state  = FALSE;
                    603:                        ps_duplex_option = TRUE;
                    604:                        c_token++;
                    605:                }
                    606:                else if (almost_equals(c_token,"du$plex")) {
                    607:                        ps_duplex_state  = TRUE;
                    608:                        ps_duplex_option = TRUE;
                    609:                        c_token++;
                    610:                }
                    611:                else if (almost_equals(c_token,"defaultp$lex")) {
                    612:                        ps_duplex_option = FALSE;
                    613:                        c_token++;
                    614:                }
                    615:        }
                    616:
                    617:        if (!END_OF_COMMAND && isstring(c_token)) {
                    618:                quote_str(ps_font,c_token, MAX_ID_LEN);
                    619:                c_token++;
                    620:        }
                    621:
                    622:        if (!END_OF_COMMAND) {
                    623:                /* We have font size specified */
                    624:                struct value a;
                    625:                ps_fontsize = (int)real(const_express(&a));
                    626:                term->v_char = (unsigned int)(ps_fontsize*PS_SC);
                    627:                term->h_char = (unsigned int)(ps_fontsize*PS_SC*6/10);
                    628:        }
                    629:
                    630:        sprintf(default_font,"%s,%d",ps_font,ps_fontsize);
                    631:        /* default_font holds the font and size set at 'set term' */
                    632:        /* Entry font added by DJL */
                    633:        sprintf(term_options,"%s %senhanced %s %s %s \"%s\" %d",
                    634:                ps_eps ? "eps" : (ps_portrait ? "portrait" : "landscape"),
                    635:       term->put_text == ENHPS_put_text ? "" : "no",
                    636:                ps_color ? "color" : "monochrome",
                    637:                ps_solid ? "solid" : "dashed",
                    638:                ps_duplex_option ? (ps_duplex_state ? "duplex" : "simplex")
                    639:                                     : "defaultplex",
                    640:                ps_font,ps_fontsize);
                    641: }
                    642:
                    643: /* store settings passed to common_init() for use in PS_graphics()
                    644:  * ps_eps, ps_portrait, etc are reserved for storing the term options
                    645:  */
                    646: static int ps_common_encap;
                    647: static int ps_common_portrait;
                    648: static int ps_common_uses_fonts;
                    649: static unsigned int ps_common_xoff, ps_common_yoff;
                    650:
                    651:
                    652: TERM_PUBLIC void PS_common_init(encap, portrait, uses_fonts, xoff, yoff, bb_xmin, bb_ymin, bb_xmax, bb_ymax, dict)
                    653: int encap; /* encapsulated or not - 1 for pslatex */
                    654: int portrait; /* 1 for pslatex */
                    655: int uses_fonts; /* 0 for ps(la)tex */
                    656: unsigned int xoff, yoff; /* how much to translate by */
                    657: unsigned int bb_xmin, bb_ymin, bb_xmax, bb_ymax; /* bounding box */
                    658: char **dict; /* extra entries for the dictionary */
                    659: {
                    660: static char GPFAR psi1[] = "%%%%Creator: gnuplot %s patchlevel %s\n\
                    661: %%%%CreationDate: %s\
                    662: %%%%DocumentFonts: %s\n";
                    663: static char GPFAR psi2[] = "%%%%EndComments\n\
                    664: /gnudict 256 dict def\ngnudict begin\n\
                    665: /Color %s def\n\
                    666: /Solid %s def\n\
                    667: /gnulinewidth %.3f def\n\
                    668: /userlinewidth gnulinewidth def\n\
                    669: /vshift %d def\n\
                    670: /dl {%d mul} def\n\
                    671: /hpt_ %.1f def\n\
                    672: /vpt_ %.1f def\n\
                    673: /hpt hpt_ def\n\
                    674: /vpt vpt_ def\n";
                    675: static char GPFAR * GPFAR PS_iso_8859_1_encoding[] = {
                    676: "/reencodeISO {\n",
                    677: "dup dup findfont dup length dict begin\n",
                    678: "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n",
                    679: "currentdict /CharStrings known {\n",
                    680: "\tCharStrings /Idieresis known {\n",
                    681: "\t\t/Encoding ISOLatin1Encoding def } if\n} if\n",
                    682: "currentdict end definefont\n",
                    683: "} def\n",
                    684: "/ISOLatin1Encoding [\n",
                    685: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    686: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    687: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    688: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    689: "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n",
                    690: "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n",
                    691: "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n",
                    692: "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n",
                    693: "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n",
                    694: "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n",
                    695: "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde\n",
                    696: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    697: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    698: "/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve\n",
                    699: "/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut\n",
                    700: "/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar\n",
                    701: "/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot\n",
                    702: "/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior\n",
                    703: "/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine\n",
                    704: "/guillemotright/onequarter/onehalf/threequarters/questiondown\n",
                    705: "/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla\n",
                    706: "/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex\n",
                    707: "/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis\n",
                    708: "/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute\n",
                    709: "/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis\n",
                    710: "/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave\n",
                    711: "/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex\n",
                    712: "/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis\n",
                    713: "/yacute/thorn/ydieresis\n",
                    714: "] def\n",
                    715: NULL };
                    716:
                    717: /*   encoding for code page 437                                            */
                    718: /*                                                                         */
                    719: /*   version 1.0:  - Mainly letters are mapped. The following positions    */
                    720: /*   (JFi)           are left blank (undefined):                           */
                    721: /*                   -- first 32 positions,                                */
                    722: /*                   -- frame characters,                                  */
                    723: /*                   -- greek characters,                                  */
                    724: /*                   -- some more special characters.                      */
                    725: /*                                                                         */
                    726: /*   version 1.1:  - added some more special characters                    */
                    727: /*                                                                         */
                    728: static char GPFAR * GPFAR PS_cp_437_encoding[] = {
                    729: "/reencodeCP437 {\n",
                    730: "dup dup findfont dup length dict begin\n",
                    731: "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n",
                    732: "currentdict /CharStrings known {\n",
                    733: "\tCharStrings /Idieresis known {\n",
                    734: "\t\t/Encoding CP437Encoding def } if\n} if\n",
                    735: "currentdict end definefont\n",
                    736: "} def\n",
                    737: "/CP437Encoding [\n",
                    738: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    739: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    740: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    741: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    742: "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n",
                    743: "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n",
                    744: "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n",
                    745: "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n",
                    746: "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n",
                    747: "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n",
                    748: "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde/.notdef\n",
                    749: "/Ccedilla/udieresis/eacute/acircumflex/adieresis/agrave/aring/ccedilla\n",
                    750: "/ecircumflex/edieresis/egrave/idieresis/icircumflex/igrave/Adieresis/Aring\n",
                    751: "/Eacute/ae/AE/ocircumflex/odieresis/ograve/ucircumflex/ugrave\n",
                    752: "/ydieresis/Odieresis/Udieresis/cent/sterling/yen/.notdef/florin\n",
                    753: "/aacute/iacute/oacute/uacute/ntilde/Ntilde/ordfeminine/ordmasculine\n",
                    754: "/questiondown/.notdef/logicalnot/onehalf/onequarter/exclamdown/guillemotleft/guillemotright\n",
                    755: "/space/space/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    756: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    757: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    758: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    759: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    760: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    761: "/.notdef/germandbls/.notdef/.notdef/.notdef/.notdef/mu/.notdef\n",
                    762: "/.notdef/.notdef/.notdef/.notdef/infinity/.notdef/.notdef/.notdef\n",
                    763: "/.notdef/plusminus/greaterequal/lessequal/.notdef/.notdef/divide/.notdef\n",
                    764: "/degree/bullet/periodcentered/.notdef/nsuperior/twosuperior/.notdef\n",
                    765: "] def\n",
                    766: NULL };
                    767:
                    768: /*   encoding for code page 850                                            */
                    769: /*                                                                         */
                    770: /*   version 1.0:  - Mainly letters are mapped. The following positions    */
                    771: /*   (JFi)           are left blank (undefined):                           */
                    772: /*                   -- first 32 positions,                                */
                    773: /*                   -- frame characters,                                  */
                    774: /*                   -- a few special characters.                          */
                    775: /*                                                                         */
                    776: static char GPFAR * GPFAR PS_cp_850_encoding[] = {
                    777: "/reencodeCP850 {\n",
                    778: "dup dup findfont dup length dict begin\n",
                    779: "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n",
                    780: "currentdict /CharStrings known {\n",
                    781: "\tCharStrings /Idieresis known {\n",
                    782: "\t\t/Encoding CP850Encoding def } if\n} if\n",
                    783: "currentdict end definefont\n",
                    784: "} def\n",
                    785: "/CP850Encoding [\n",
                    786: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    787: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    788: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    789: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
                    790: "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n",
                    791: "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n",
                    792: "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n",
                    793: "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n",
                    794: "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n",
                    795: "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n",
                    796: "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde/.notdef\n",
                    797: "/Ccedilla/udieresis/eacute/acircumflex/adieresis/agrave/aring/ccedilla\n",
                    798: "/ecircumflex/edieresis/egrave/idieresis/icircumflex/igrave/Adieresis/Aring\n",
                    799: "/Eacute/ae/AE/ocircumflex/odieresis/ograve/ucircumflex/ugrave\n",
                    800: "/ydieresis/Odieresis/Udieresis/oslash/sterling/Oslash/multiply/florin\n",
                    801: "/aacute/iacute/oacute/uacute/ntilde/Ntilde/ordfeminine/ordmasculine\n",
                    802: "/questiondown/registered/logicalnot/onehalf/onequarter/exclamdown/guillemotleft/guillemotright\n",
                    803: "/space/space/.notdef/.notdef/.notdef/Aacute/Acircumflex/Agrave\n",
                    804: "/.notdef/.notdef/.notdef/.notdef/.notdef/cent/yen/.notdef\n",
                    805: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/atilde/Atilde\n",
                    806: "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/currency\n",
                    807: "/eth/Eth/Ecircumflex/Edieresis/Egrave/dotlessi/Iacute/Icircumflex\n",
                    808: "/Idieresis/.notdef/.notdef/.notdef/.notdef/brokenbar/Igrave/.notdef\n",
                    809: "/Oacute/germandbls/Ocircumflex/Ograve/otilde/Otilde/mu/thorn\n",
                    810: "/Thorn/Uacute/Ucircumflex/Ugrave/yacute/Yacute/macron/acute\n",
                    811: "/hyphen/plusminus/equal/threequarters/paragraph/section/divide/.notdef\n",
                    812: "/degree/.notdef/periodcentered/onesuperior/threesuperior/twosuperior/.notdef\n",
                    813: "] def\n",
                    814: NULL };
                    815:
                    816:        struct termentry *t = term;
                    817:        int i;
                    818:         time_t now;
                    819:
                    820:        ps_common_encap = encap; /* store for later */
                    821:        ps_common_portrait = portrait; /* store for later */
                    822:        ps_common_uses_fonts = uses_fonts;
                    823:        ps_common_xoff = xoff;
                    824:        ps_common_yoff = yoff;
                    825:
                    826:        ps_page = 0;
                    827:
                    828:        if (!encap)
                    829:                fprintf(gpoutfile,"%%!PS-Adobe-2.0\n");
                    830:        else
                    831:                fprintf(gpoutfile,"%%!PS-Adobe-2.0 EPSF-2.0\n");
                    832:
                    833:        if (outstr) fprintf(gpoutfile, "%%%%Title: %s\n", outstr );             /*  JFi  */
                    834:        time(&now);
                    835:        fprintf(gpoutfile, psi1, version, patchlevel, asctime(localtime(&now)), uses_fonts ? "(atend)" : "");
                    836:
                    837:        fprintf(gpoutfile,"%%%%BoundingBox: %d %d %d %d\n", xoff + bb_xmin, yoff + bb_ymin, xoff + bb_xmax, yoff + bb_ymax);
                    838:
                    839:        fprintf(gpoutfile,"%%%%Orientation: %s\n", ps_portrait ? "Portrait" : "Landscape");
                    840:
                    841:        if (!encap)
                    842:                fprintf(gpoutfile,"%%%%Pages: (atend)\n");
                    843:        fprintf(gpoutfile, psi2,
                    844:                ps_color ? "true" : "false",
                    845:                ps_solid ? "true" : "false",
                    846:                PS_LW,                  /* line width */
                    847:                (int)(t->v_char)/(-3),  /* shift for vertical centring */
                    848:                PS_SC,                  /* dash length */
                    849:                PS_HTIC/2.0,            /* half point width */
                    850:                PS_VTIC/2.0);           /* half point height */
                    851:
                    852:        if (uses_fonts && (encoding == ENCODING_ISO_8859_1)) {
                    853:                for (i=0; PS_iso_8859_1_encoding[i] != NULL; i++) {
                    854:                        fprintf(gpoutfile,"%s",PS_iso_8859_1_encoding[i]);
                    855:                }
                    856:        }
                    857:        if (uses_fonts && (encoding == ENCODING_CP_437)) {       /* JFi */
                    858:                for (i=0; PS_cp_437_encoding[i] != NULL; i++) {
                    859:                        fprintf(gpoutfile,"%s",PS_cp_437_encoding[i]);
                    860:                }
                    861:        }
                    862:        if (uses_fonts && (encoding == ENCODING_CP_850)) {       /* JFi */
                    863:                for (i=0; PS_cp_850_encoding[i] != NULL; i++) {
                    864:                        fprintf(gpoutfile,"%s",PS_cp_850_encoding[i]);
                    865:                }
                    866:        }
                    867: /*        Duplicate code!
                    868:           As long as only two code pages are implemented, that's not a big
                    869:           problem. Otherwise a small procedure might be beneficial.
                    870: */
                    871:
                    872:        for ( i=0; PS_header[i] != NULL; i++)
                    873:                fprintf(gpoutfile,"%s",PS_header[i]);
                    874:        if (ps_duplex_option)
                    875:                fprintf(gpoutfile, "statusdict begin %s setduplexmode end\n",
                    876:                                ps_duplex_state ? "true" : "false");
                    877:        PS_RememberFont(ps_font, 1);
                    878:
                    879:        if (dict)
                    880:                while (*dict)
                    881:                        fputs(*(dict++), gpoutfile);
                    882:
                    883:        fprintf(gpoutfile,"end\n%%%%EndProlog\n");
                    884: }
                    885:
                    886: /* the init fn for the postscript driver */
                    887: TERM_PUBLIC void PS_init()
                    888: {
                    889:        unsigned int xmin_t, ymin_t, xmax_t, ymax_t;
                    890:
                    891:        if (ps_eps)
                    892:        {
                    893:                term->xmax = PS_XMAX;
                    894:                term->ymax = PS_YMAX;
                    895:                xmin_t = PS_XMAX * xoffset / (2*PS_SC);
                    896:                xmax_t = PS_XMAX * (xsize + xoffset) / (2*PS_SC);
                    897:                ymin_t = PS_YMAX * yoffset / (2*PS_SC);
                    898:                ymax_t = PS_YMAX * (yoffset + ysize) / (2*PS_SC);
                    899:        }
                    900:        else if (ps_portrait)
                    901:        {
                    902:                term->xmax = PS_YMAX;
                    903:                term->ymax = PS_XMAX;
                    904:                xmin_t = PS_YMAX * xoffset / PS_SC;
                    905:                xmax_t = PS_YMAX * (xsize + xoffset) / PS_SC;
                    906:                ymin_t = PS_XMAX * yoffset / PS_SC;
                    907:                ymax_t = PS_XMAX * (ysize + yoffset) / PS_SC;
                    908:        }
                    909:        else
                    910:        {
                    911:                term->xmax = PS_XMAX;
                    912:                term->ymax = PS_YMAX;
                    913:                ymin_t = PS_XMAX * xoffset / PS_SC;
                    914:                ymax_t = PS_XMAX * (xsize+xoffset) / PS_SC;
                    915:                xmin_t = PS_YMAX * (1-ysize-yoffset) / PS_SC;
                    916:                xmax_t = PS_YMAX * (1-yoffset) / PS_SC;
                    917:        }
                    918:
                    919:        /* for enhanced postscript, copy ps_font to ps_enh_font
                    920:         * does no harm for non-enhanced
                    921:         */
                    922:        strcpy(ps_enh_font, ps_font);
                    923:        ps_enh_fontsize = ps_fontsize;
                    924:
                    925:        PS_common_init(ps_eps, ps_portrait, 1, PS_XOFF, PS_YOFF,
                    926:           xmin_t, ymin_t, xmax_t, ymax_t,
                    927:           (term->put_text == ENHPS_put_text) ? ENHPS_header : NULL);
                    928: }
                    929:
                    930:
                    931: TERM_PUBLIC void PS_graphics()
                    932: {
                    933: static char GPFAR psg1[] = "0 setgray\nnewpath\n";
                    934: struct termentry *t = term;
                    935:        ps_page++;
                    936:        if (!ps_common_encap)
                    937:                fprintf(gpoutfile,"%%%%Page: %d %d\n",ps_page,ps_page);
                    938:        fprintf(gpoutfile,"gnudict begin\ngsave\n");
                    939:        fprintf(gpoutfile,"%d %d translate\n",ps_common_xoff, ps_common_yoff);
                    940:        fprintf(gpoutfile,"%.3f %.3f scale\n", (ps_eps ? 0.5 : 1.0)/PS_SC,
                    941:                                             (ps_eps ? 0.5 : 1.0)/PS_SC);
                    942:        if (!ps_common_portrait) {
                    943:            fprintf(gpoutfile,"90 rotate\n0 %d translate\n", (int)(-PS_YMAX));
                    944:        }
                    945:        fprintf(gpoutfile, psg1);
                    946:        if (ps_common_uses_fonts)
                    947:                fprintf(gpoutfile, "(%s) findfont %d scalefont setfont\n", ps_font, (t->v_char) );
                    948:        ps_path_count = 0;
                    949:        PS_relative_ok = FALSE;
                    950:        PS_pen_x = PS_pen_y = -4000;
                    951:        PS_taken = 0;
                    952:        PS_linetype_last = -1;
                    953: }
                    954:
                    955:
                    956: TERM_PUBLIC void PS_text()
                    957: {
                    958:        ps_path_count = 0;
                    959:        fprintf(gpoutfile,"stroke\ngrestore\nend\nshowpage\n");
                    960:        /* fprintf(stderr,"taken %d times\n",PS_taken); */
                    961:        /* informational:  tells how many times it was "cheaper"
                    962:           to do a relative moveto or lineto rather than an
                    963:           absolute one */
                    964: }
                    965:
                    966:
                    967: TERM_PUBLIC void PS_reset()
                    968: {
                    969:        fprintf(gpoutfile,"%%%%Trailer\n");
                    970:
                    971: /*      I think the following commands should be executed
                    972:         `if (ps_common_uses_fonts)`. So I changed the next line.
                    973:         Please see "PS_RememberFont", too.                       */  /* JFi */
                    974:
                    975: /*     if (!ps_common_uses_fonts) {  */                             /* JFi */
                    976:        if (ps_common_uses_fonts) {
                    977:                fprintf(gpoutfile,"%%%%DocumentFonts: ");
                    978:                while (PS_DocFonts) {
                    979:                    struct PS_FontName *fnp;
                    980:                        fnp = PS_DocFonts->next;
                    981:                        fprintf(gpoutfile, "%s%s", PS_DocFonts->name, fnp ? " " : "\n");
                    982:                        free(PS_DocFonts->name);
                    983:                        free(PS_DocFonts);
                    984:                        PS_DocFonts=fnp;
                    985:                }
                    986:        }
                    987:        if (!ps_common_encap)
                    988:                fprintf(gpoutfile,"%%%%Pages: %d\n",ps_page);
                    989: }
                    990:
                    991:
                    992: TERM_PUBLIC void PS_linetype(linetype)
                    993: int linetype;
                    994: {
                    995:        linetype = (linetype % 9) + 2;
                    996:        if (linetype < 0) linetype = 0;
                    997:        PS_relative_ok = FALSE;
                    998: #if 0
                    999:        /*  In order to make 'PS_linewidth' work properly, I need to comment
                   1000:         *  this line out.  Especially in combination with the line width
                   1001:         *  extension of the `set arrow` command this is necessary.
                   1002:         *  Can we live with that drawback?  (JFi)
                   1003:         */
                   1004:        if (PS_linetype_last == linetype) return;
                   1005: #endif
                   1006:        PS_linetype_last = linetype;
                   1007:        fprintf(gpoutfile,"LT%c\n", "ba012345678"[linetype]);
                   1008:        ps_path_count = 0;
                   1009: }
                   1010:
                   1011:
                   1012: TERM_PUBLIC void PS_linewidth (linewidth)
                   1013: double linewidth;
                   1014: {
                   1015:         fprintf(gpoutfile,"%.3f UL\n",linewidth);
                   1016:
                   1017: /*
                   1018:   Documentation of the 'change linewidth' strategy of the postscript terminal:
                   1019:
                   1020:   1. define a new postscript variable with a default value:
                   1021:      /userlinewidth gnulinewidth def
                   1022:
                   1023:   2. define a new postscript command to change the contents of that variable:
                   1024:      /UL { gnulinewidth mul /userlinewidth exch def } def
                   1025:      usage:  multiplication_factor UL
                   1026:
                   1027:   3. modify the already known postscript command /PL for the plot lines:
                   1028:      /PL { stroke userlinewidth setlinewidth } def
                   1029:
                   1030:   4. issue the new command before every change of the plot linestyle:
                   1031:      example:
                   1032:          4.0 UL
                   1033:          LT0
                   1034:      result:
                   1035:          Linetype 0 is drawn four times as thick as defined by the contents
                   1036:          of the postscript variable 'gnulinewidth'.
                   1037: */
                   1038: }
                   1039:
                   1040:
                   1041: TERM_PUBLIC void PS_pointsize (ptsize)
                   1042: double ptsize;
                   1043: {
                   1044:         fprintf(gpoutfile,"%.3f UP\n",ptsize);
                   1045:
                   1046: /*
                   1047:   Documentation of the 'change pointsize' strategy of the postscript terminal:
                   1048:
                   1049:   1. define two new postscript variables to hold the overall pointsize:
                   1050:      /hpt_  and  /vpt_
                   1051:
                   1052:   2. define a new postscript command to use the contents of these variables:
                   1053:      /UP { cf. definition above } def
                   1054:      usage:  multiplication_factor UP
                   1055:
                   1056:  [3.] [doesn't exist, skip to next number]
                   1057:
                   1058:   4. issue the new command whereever you change the symbols (and linetype):
                   1059:      example:
                   1060:          2.5 UP
                   1061:          4.0 UL  % optionally change linewidth, too
                   1062:          LT0
                   1063:      result:
                   1064:          Next symbols will be drawn 2.5 times as big as defined by the
                   1065:          GNUPLOT `set pointsize` command (= overall pointsize).
                   1066: */
                   1067: }
                   1068:
                   1069:
                   1070: TERM_PUBLIC void PS_move(x,y)
                   1071: unsigned int x,y;
                   1072: {
                   1073:        int dx, dy;
                   1074:        /* Make this semi-dynamic and independent of architecture */
                   1075:        char abso[5+2*INT_STR_LEN], rel[5+2*INT_STR_LEN];
                   1076:        dx = x - PS_pen_x;
                   1077:        dy = y - PS_pen_y;
                   1078:        /* can't cancel all null moves--need a move after stroke'ing */
                   1079:        if (dx==0 && dy==0 && PS_relative_ok)
                   1080:                return;
                   1081:        sprintf(abso, "%d %d M\n", x, y);
                   1082:        sprintf(rel, "%d %d R\n", dx, dy);
                   1083:        if (strlen(rel) < strlen(abso) && PS_relative_ok){
                   1084:                fputs(rel, gpoutfile);
                   1085:                PS_taken++;
                   1086:        }else
                   1087:                fputs(abso, gpoutfile);
                   1088:        PS_relative_ok = TRUE;
                   1089:        ps_path_count += 1;
                   1090:
                   1091:        PS_pen_x = x;
                   1092:        PS_pen_y = y;
                   1093: }
                   1094:
                   1095: TERM_PUBLIC void PS_vector(x,y)
                   1096: unsigned int x,y;
                   1097: {
                   1098:        int dx, dy;
                   1099:        char abso[5+2*INT_STR_LEN], rel[5+2*INT_STR_LEN];
                   1100:        dx = x - PS_pen_x;
                   1101:        dy = y - PS_pen_y;
                   1102:        if (dx==0 && dy==0) return;
                   1103:        sprintf(abso, "%d %d L\n", x, y);
                   1104:        sprintf(rel, "%d %d V\n", dx, dy);
                   1105:        if (strlen(rel) < strlen(abso) && PS_relative_ok){
                   1106:                fputs(rel, gpoutfile);
                   1107:                PS_taken++;
                   1108:        }else
                   1109:                fputs(abso, gpoutfile);
                   1110:        PS_relative_ok = TRUE;
                   1111:        ps_path_count += 1;
                   1112:        PS_pen_x = x;
                   1113:        PS_pen_y = y;
                   1114:        if (ps_path_count >= 400) {
                   1115:                fprintf(gpoutfile,"currentpoint stroke M\n");
                   1116:                ps_path_count = 0;
                   1117:        }
                   1118: }
                   1119:
                   1120:
                   1121: TERM_PUBLIC void PS_put_text(x,y,str)
                   1122: unsigned int x, y;
                   1123: char *str;
                   1124: {
                   1125: char ch;
                   1126:        if (!strlen(str)) return;
                   1127:        PS_move(x,y);
                   1128:        if (ps_ang != 0)
                   1129:                fprintf(gpoutfile,"currentpoint gsave translate %d rotate 0 0 M\n"
                   1130:                        ,ps_ang*90);
                   1131:        putc('(',gpoutfile);
                   1132:        ch = *str++;
                   1133:        while(ch!='\0') {
                   1134:                if ( (ch=='(') || (ch==')') || (ch=='\\') )
                   1135:                        putc('\\',gpoutfile);
                   1136:                putc(ch,gpoutfile);
                   1137:                ch = *str++;
                   1138:        }
                   1139:        switch(ps_justify) {
                   1140:                case LEFT : fprintf(gpoutfile,") Lshow\n");
                   1141:                        break;
                   1142:                case CENTRE : fprintf(gpoutfile,") Cshow\n");
                   1143:                        break;
                   1144:                case RIGHT : fprintf(gpoutfile,") Rshow\n");
                   1145:                        break;
                   1146:        }
                   1147:        if (ps_ang != 0)
                   1148:                fprintf(gpoutfile,"grestore\n");
                   1149:        ps_path_count = 0;
                   1150:        PS_relative_ok = FALSE;
                   1151: }
                   1152:
                   1153:
                   1154: TERM_PUBLIC int PS_text_angle(ang)
                   1155: int ang;
                   1156: {
                   1157:        ps_ang=ang;
                   1158:        return TRUE;
                   1159: }
                   1160:
                   1161:
                   1162: TERM_PUBLIC int PS_justify_text(mode)
                   1163: enum JUSTIFY mode;
                   1164: {
                   1165:        ps_justify=mode;
                   1166:        return TRUE;
                   1167: }
                   1168:
                   1169:
                   1170: TERM_PUBLIC int PS_set_font(font)  /* Entry font added by DJL */
                   1171: char *font;
                   1172: {
                   1173: char name[32];
                   1174: int  size,sep;
                   1175:
                   1176:         sep=strcspn(font,",");
                   1177:         strncpy(name,font,sep); name[sep]=NUL;
                   1178:         size=ps_fontsize; sscanf (&(font[sep+1]),"%d",&size);
                   1179:         fprintf(gpoutfile,"/%s findfont %d scalefont setfont\n",name,size*PS_SC);
                   1180:         PS_RememberFont(name,1 );
                   1181:         return TRUE;
                   1182: }
                   1183:
                   1184:
                   1185: /* postscript point routines */
                   1186:
                   1187:
                   1188: TERM_PUBLIC void PS_point(x,y,number)
                   1189: unsigned int x,y;
                   1190: int number;
                   1191: {
                   1192: static char GPFAR * GPFAR pointFNS[] = {"Pnt",  "Pls",   "Crs",    "Star",
                   1193:                            "Box",  "BoxF",  "Circle", "CircleF",
                   1194:                            "TriU", "TriUF", "TriD",   "TriDF",
                   1195:                            "Dia",  "DiaF",  "Pent",   "PentF",
                   1196:                           "C0",   "C1",    "C2",     "C3",
                   1197:                           "C4",   "C5",    "C6",     "C7",
                   1198:                           "C8",   "C9",    "C10",    "C11",
                   1199:                           "C12",  "C13",   "C14",    "C15",
                   1200:                            "S0",   "S1",    "S2",     "S3",
                   1201:                           "S4",   "S5",    "S6",     "S7",
                   1202:                            "S8",   "S9",    "S10",    "S11",
                   1203:                           "S12",  "S13",   "S14",    "S15",
                   1204:                           "D0",   "D1",    "D2",     "D3",
                   1205:                           "D4",   "D5",    "D6",     "D7",
                   1206:                           "D8",   "D9",    "D10",    "D11",
                   1207:                           "D12",  "D13",   "D14",    "D15",
                   1208:                            "BoxE", "CircE", "TriUE",  "TriDE",
                   1209:                            "DiaE", "PentE", "BoxW",   "CircW",
                   1210:                            "TriUW", "TriDW", "DiaW",  "PentW"
                   1211: };
                   1212:        if (number < 0)
                   1213:                number = -1;            /* negative types are all 'dot' */
                   1214:        else
                   1215:                number %= sizeof(pointFNS)/sizeof(pointFNS[0]) -1;
                   1216:        fprintf(gpoutfile,"%d %d %s\n", x, y, pointFNS[number+1]);
                   1217:
                   1218:        PS_relative_ok = 0;
                   1219:        ps_path_count = 0;
                   1220:        PS_linetype_last = -1; /* force next linetype change */
                   1221: }
                   1222:
                   1223: TERM_PUBLIC void PS_fillbox(style, x1,y1,x2,y2)
                   1224: int style;
                   1225: unsigned int x1,y1,x2,y2;
                   1226: {
                   1227:        PS_FLUSH_PATH
                   1228:
                   1229:        fprintf(gpoutfile, "%d %d %d %d BoxFill\n", x1,y1, x2,y2);
                   1230:
                   1231:        PS_relative_ok = 0;
                   1232:        PS_linetype_last = -1;
                   1233: }
                   1234:
                   1235:
                   1236: /* ENHPOST */
                   1237:
                   1238:
                   1239: #ifdef DEBUG_ENHPS
                   1240: #define ENHPS_DEBUG(x) printf x;
                   1241: #else
                   1242: #define ENHPS_DEBUG(x)
                   1243: #endif
                   1244:
                   1245:
                   1246: static TBOOLEAN ENHps_opened_string;  /* try to cut out empty ()'s */
                   1247:
                   1248: /* used in determining height of processed text */
                   1249:
                   1250: static float ENHps_max_height, ENHps_min_height;
                   1251:
                   1252:
                   1253: /* process a bit of string, and return the last character used.
                   1254:  * p is start of string
                   1255:  * brace is TRUE to keep processing to }, FALSE for do one character
                   1256:  * fontname & fontsize are obvious
                   1257:  * base is the current baseline
                   1258:  * widthflag is TRUE if the width of this should count,
                   1259:  *              FALSE for zero width boxes
                   1260:  * showflag is TRUE if this should be shown,
                   1261:  *             FALSE if it should not be shown (like TeX \phantom)
                   1262:  */
                   1263:
                   1264: static char *ENHPS_recurse(p, brace, fontname, fontsize, base, widthflag, showflag)
                   1265: char *p, *fontname;
                   1266: TBOOLEAN brace, widthflag, showflag;
                   1267: double fontsize, base;
                   1268: {
                   1269:
                   1270: /* close a postscript string if it has been opened */
                   1271: #define ENHPS_FLUSH      \
                   1272: {      if (ENHps_opened_string)  \
                   1273:        {       fputs(")]\n", gpoutfile);   \
                   1274:                ENHps_opened_string = FALSE; \
                   1275:        }                         \
                   1276: }
                   1277:
                   1278: #define ENHPS_OPEN     \
                   1279: {      if (!ENHps_opened_string) \
                   1280:        { fprintf(gpoutfile, "[(%s) %.1f %.1f %s %s (",  \
                   1281:                  fontname, fontsize, base, \
                   1282:                  widthflag ? "true" : "false",  \
                   1283:                  showflag ? "true" : "false");  \
                   1284:          ENHps_opened_string = TRUE; \
                   1285:        }       \
                   1286: }
                   1287:
                   1288:        ENHPS_DEBUG(("RECURSE WITH [%p] \"%s\", %d %s %.1f %.1f %d %d\n", p, p, brace, fontname, fontsize, base, widthflag, showflag))
                   1289:
                   1290:        /* Start each recursion with a clean string */
                   1291:        ENHPS_FLUSH
                   1292:
                   1293:        if (base + fontsize > ENHps_max_height)
                   1294:        {       ENHps_max_height = base + fontsize;
                   1295:                ENHPS_DEBUG(("Setting max height to %.1f\n", ENHps_max_height));
                   1296:        }
                   1297:
                   1298:        if (base < ENHps_min_height)
                   1299:        {       ENHps_min_height = base;
                   1300:                ENHPS_DEBUG(("Setting min height to %.1f\n", ENHps_min_height));
                   1301:        }
                   1302:
                   1303:        while (*p)
                   1304:        {       float shift;
                   1305:
                   1306:                switch (*p)
                   1307:                {
                   1308:                        case '}'  :
                   1309:                                /*{{{  deal with it*/
                   1310:                                if (brace)
                   1311:                                        return (p);
                   1312:
                   1313:                                fprintf(stderr, "enhpost printer driver - spurious }\n");
                   1314:                                break;
                   1315:                                /*}}}*/
                   1316:
                   1317:                        case '_'  :
                   1318:                        case '^'  :
                   1319:                                /*{{{  deal with super/sub script*/
                   1320:
                   1321:                                shift = (*p == '^') ? 0.5 : -0.3;
                   1322:
                   1323:                                ENHPS_FLUSH
                   1324:
                   1325:                                p = ENHPS_recurse(p+1, FALSE, fontname, fontsize*0.8, base+shift*fontsize, widthflag, showflag);
                   1326:
                   1327:                                break;
                   1328:                                /*}}}*/
                   1329:
                   1330:                        case '{'  :
                   1331:                        {
                   1332:                                char *savepos=NULL, save=0;
                   1333:                                char *localfontname=fontname, ch;
                   1334:                                int recode=1;
                   1335:                                float f=fontsize;
                   1336:
                   1337:                                /*{{{  recurse (possibly with a new font) */
                   1338:
                   1339:                                ENHPS_DEBUG(("Dealing with {\n"))
                   1340:
                   1341:                                if (*++p == '/')
                   1342:                                {       /* then parse a fontname, optional fontsize */
                   1343:                                        while (*++p == ' ');
                   1344:                                        if (*p=='-')
                   1345:                                        {
                   1346:                                                recode=0;
                   1347:                                                while (*++p == ' ');
                   1348:                                        }
                   1349:                                        localfontname = p;
                   1350:                                        while ((ch = *p) > ' ' && ch != '=' && ch != '*')
                   1351:                                                ++p;
                   1352:                                        save = *(savepos=p);
                   1353:                                        if (ch == '=')
                   1354:                                        {
                   1355:                                                *p++ = '\0';
                   1356:                                                /*{{{  get optional font size*/
                   1357:                                                ENHPS_DEBUG(("Calling strtod(\"%s\") ...", p))
                   1358:                                                f = (float)strtod(p, &p);
                   1359:                                                ENHPS_DEBUG(("Returned %.1f and \"%s\"\n", f, p))
                   1360:
                   1361:                                                if (f)
                   1362:                                                        f *= PS_SC;  /* remember the scaling */
                   1363:                                                else
                   1364:                                                        f = fontsize;
                   1365:
                   1366:                                                ENHPS_DEBUG(("Font size %.1f\n", f))
                   1367:                                                /*}}}*/
                   1368:                                        }
                   1369:                                        else if (ch == '*')
                   1370:                                        {
                   1371:                                                *p++ = '\0';
                   1372:                                                /*{{{  get optional font size scale factor*/
                   1373:                                                ENHPS_DEBUG(("Calling strtod(\"%s\") ...", p))
                   1374:                                                f = (float)strtod(p, &p);
                   1375:                                                ENHPS_DEBUG(("Returned %.1f and \"%s\"\n", f, p))
                   1376:
                   1377:                                                if (f)
                   1378:                                                        f *= fontsize;  /* apply the scale factor */
                   1379:                                                else
                   1380:                                                        f = fontsize;
                   1381:
                   1382:                                                ENHPS_DEBUG(("Font size %.1f\n", f))
                   1383:                                                /*}}}*/
                   1384:                                        }
                   1385:                                        else
                   1386:                                        {
                   1387:                                                *p++ = '\0';
                   1388:                                                f = fontsize;
                   1389:                                        }
                   1390:
                   1391:                                        while (*p == ' ')
                   1392:                                                ++p;
                   1393:                                        if (*localfontname)
                   1394:                                        {
                   1395:                                                /* only allow RememberFont to re-encode it if no string active */
                   1396:                                                char *recodestring = PS_RememberFont(localfontname, recode && !ENHps_opened_string);
                   1397:                                                if (recode && recodestring)
                   1398:                                                {
                   1399:                                                        ENHPS_FLUSH
                   1400:                                                        fprintf(gpoutfile, "/%s %s", localfontname, recodestring);
                   1401:                                                }
                   1402:                                        }
                   1403:                                        else
                   1404:                                                localfontname = fontname;
                   1405:                                }
                   1406:                                /*}}}*/
                   1407:
                   1408:                                ENHPS_DEBUG(("Before recursing, we are at [%p] \"%s\"\n", p, p))
                   1409:
                   1410:                                p = ENHPS_recurse(p, TRUE, localfontname, f, base, widthflag, showflag);
                   1411:
                   1412:                                ENHPS_DEBUG(("BACK WITH \"%s\"\n", p));
                   1413:
                   1414:                                ENHPS_FLUSH
                   1415:
                   1416:                                if (savepos)
                   1417:                                        /* restore overwritten character */
                   1418:                                        *savepos = save;
                   1419:
                   1420:                                break;
                   1421:                        }
                   1422:
                   1423:                        case '@' :
                   1424:                                /*{{{  phantom box - prints next 'char', then restores currentpoint */
                   1425:
                   1426:                                ENHPS_FLUSH
                   1427:
                   1428:                                p = ENHPS_recurse(++p, FALSE, fontname, fontsize, base, FALSE, showflag);
                   1429:
                   1430:                                break;
                   1431:                                /*}}}*/
                   1432:
                   1433:                        case '&' :
                   1434:                                /*{{{  character skip - skips space equal to length of character(s) */
                   1435:
                   1436:                                ENHPS_FLUSH
                   1437:
                   1438:                                p = ENHPS_recurse(++p, FALSE, fontname, fontsize, base, widthflag, FALSE);
                   1439:
                   1440:                                break;
                   1441:                                /*}}}*/
                   1442:
                   1443:                        case '('  :
                   1444:                        case ')'  :
                   1445:                                /*{{{  an escape and print it */
                   1446:                                /* special cases */
                   1447:                                ENHPS_OPEN
                   1448:                                fputc('\\', gpoutfile);
                   1449:                                fputc(*p, gpoutfile);
                   1450:                                break;
                   1451:                                /*}}}*/
                   1452:
                   1453:                        case '\\'  :
                   1454:                                /*{{{  is it an escape */
                   1455:                                /* special cases */
                   1456:
                   1457:                                if (p[1]=='\\' || p[1]=='(' || p[1]==')')
                   1458:                                {
                   1459:                                        ENHPS_OPEN
                   1460:                                        fputc('\\', gpoutfile);
                   1461:                                }
                   1462:                                else if (p[1] >= '0' && p[1] <= '7')
                   1463:                                {
                   1464:                                        /* up to 3 octal digits */
                   1465:                                        ENHPS_OPEN
                   1466:                                        fputc('\\', gpoutfile);
                   1467:                                        fputc(p[1], gpoutfile);
                   1468:                                        ++p;
                   1469:                                        if (p[1] >= '0' && p[1] <= '7')
                   1470:                                        {
                   1471:                                                fputc(p[1], gpoutfile);
                   1472:                                                ++p;
                   1473:                                                if (p[1] >= '0' && p[1] <= '7')
                   1474:                                                {
                   1475:                                                        fputc(p[1], gpoutfile);
                   1476:                                                        ++p;
                   1477:                                                }
                   1478:                                        }
                   1479:                                        break;
                   1480:                                }
                   1481:
                   1482:                                ++p;
                   1483:                                /* just go and print it (fall into the 'default' case) */
                   1484:
                   1485:                                /*}}}*/
                   1486:                        default:
                   1487:                                /*{{{  print it */
                   1488:                                ENHPS_OPEN
                   1489:
                   1490:                                fputc(*p, gpoutfile);
                   1491:
                   1492:                        /*}}}*/
                   1493:
                   1494:                }
                   1495:
                   1496:                /* like TeX, we only do one character in a recursion, unless it's
                   1497:                 * in braces
                   1498:                 */
                   1499:
                   1500:                if (!brace)
                   1501:                {
                   1502:                        ENHPS_FLUSH
                   1503:                        return(p);  /* the ++p in the outer copy will increment us */
                   1504:                }
                   1505:
                   1506:                if (*p) /* only not true if { not terminated, I think */
                   1507:                        ++p;
                   1508:        }
                   1509:        ENHPS_FLUSH
                   1510:        return p;
                   1511: }
                   1512:
                   1513:
                   1514: /* a set-font routine for enhanced post : simply copies
                   1515:  * the font into a global, or restores the globals
                   1516:  * to the ps_font default
                   1517:  */
                   1518:
                   1519: TERM_PUBLIC int ENHPS_set_font(font)  /* Entry font added by DJL */
                   1520: char *font;
                   1521: {
                   1522:        ENHPS_DEBUG(("ENHPS_set_font(\"%s\")\n", font));
                   1523:
                   1524:        if (*font)
                   1525:        {
                   1526:                int sep=strcspn(font,",");
                   1527:                strncpy(ps_enh_font,font,sep); ps_enh_font[sep]=NUL;
                   1528:                ps_enh_fontsize=ps_fontsize; sscanf (font+sep+1,"%d",&ps_enh_fontsize);
                   1529:                PS_RememberFont(ps_enh_font, 1);
                   1530:        }
                   1531:        else
                   1532:        {
                   1533:                /* return to defaults */
                   1534:                strcpy(ps_enh_font, ps_font);
                   1535:                ps_enh_fontsize = ps_fontsize;
                   1536:        }
                   1537:
                   1538:        return TRUE;
                   1539: }
                   1540:
                   1541: TERM_PUBLIC void ENHPS_put_text(x, y, str)
                   1542: unsigned int x, y;
                   1543: char *str;
                   1544: {
                   1545:        /* flush any pending graphics (all the XShow routines do this...) */
                   1546:
                   1547:        if (!strlen(str))
                   1548:                return;
                   1549:
                   1550:        if (ps_path_count)
                   1551:        {
                   1552:                fputs(" stroke\n",gpoutfile);
                   1553:                ps_path_count=0;
                   1554:                PS_relative_ok=FALSE;
                   1555:        }
                   1556:
                   1557:        /* if there are no magic characters, we should just be able
                   1558:         * punt the string to PS_put_text(), which will give shorter
                   1559:         * ps output [eg tics and stuff rarely need extra processing],
                   1560:         * but we need to make sure that the current font is the
                   1561:         * default one before we can do that. {ie I tried it and it
                   1562:         * used the wrong font !}
                   1563:         * if (!strpbrk(str, "{}^_@&"))
                   1564:         * {
                   1565:         *   - do something to ensure default font is selected
                   1566:         *   PS_put_text(x,y,str);
                   1567:         *   return;
                   1568:         * }
                   1569:         */
                   1570:
                   1571:
                   1572:        PS_move(x,y);
                   1573:
                   1574:        if (ps_ang != 0)
                   1575:                fprintf(gpoutfile,"currentpoint gsave translate %d rotate 0 0 moveto\n",
                   1576:                        ps_ang*90);
                   1577:
                   1578:        fputs("[ ",gpoutfile);
                   1579:
                   1580:        /* set up the globals */
                   1581:
                   1582:        ENHps_opened_string = FALSE;
                   1583:        ENHps_max_height = -1000;
                   1584:        ENHps_min_height = 1000;
                   1585:
                   1586:        /* Set the recursion going. We say to keep going until a
                   1587:         * closing brace, but we don't really expect to find one.
                   1588:         * If the return value is not the nul-terminator of the
                   1589:         * string, that can only mean that we did find an unmatched
                   1590:         * closing brace in the string. We increment past it (else
                   1591:         * we get stuck in an infinite loop) and try again.
                   1592:         *
                   1593:         * ps_enh_font and ps_enh_fontsize are either set to the
                   1594:         * the defaults set on option line, or have been set to
                   1595:         * "font,size". That is to say, ps_font is used only
                   1596:         * at startup and by ENHPS_set_font
                   1597:         */
                   1598:        while (*(str = ENHPS_recurse(str, TRUE, ps_enh_font,
                   1599:                                     (double)(ps_enh_fontsize*PS_SC),
                   1600:                                     0.0, TRUE, TRUE)))
                   1601:        {
                   1602:                ENHPS_FLUSH
                   1603:
                   1604:                /* I think we can only get here if *str == '}' */
                   1605:                if (*str == '}')
                   1606:                        fprintf(stderr, "enhpost printer driver - ignoring spurious }\n");
                   1607:                else
                   1608:                        fprintf(stderr, "internal error in enhpost driver - *str=0x%x\n", *str);
                   1609:
                   1610:                if (!*++str)
                   1611:                        break; /* end of string */
                   1612:
                   1613:                /* else carry on and process the rest of the string */
                   1614:        }
                   1615:
                   1616:        ENHps_max_height += ENHps_min_height;
                   1617:
                   1618:        fprintf(gpoutfile, "] %.1f ", -ENHps_max_height/3);
                   1619:
                   1620:        switch(ps_justify)
                   1621:        {
                   1622:                case LEFT : fprintf(gpoutfile, "MLshow\n");
                   1623:                        break;
                   1624:                case CENTRE : fprintf(gpoutfile, "MCshow\n");
                   1625:                        break;
                   1626:                case RIGHT : fprintf(gpoutfile, "MRshow\n");
                   1627:                        break;
                   1628:        }
                   1629:
                   1630:        if (ps_ang != 0)
                   1631:                fputs("grestore\n", gpoutfile);
                   1632:        ps_path_count = 0;
                   1633:        PS_relative_ok=FALSE;
                   1634: }
                   1635:
                   1636:
                   1637:
                   1638:
                   1639:
                   1640: #endif /* TERM_BODY */
                   1641:
                   1642: #ifdef TERM_TABLE
                   1643:
                   1644: TERM_TABLE_START(post_driver)
                   1645:
                   1646:       "postscript",
                   1647:       "PostScript graphics language [mode \042fontname\042 font_size]",
                   1648:           PS_XMAX, PS_YMAX, PS_VCHAR, PS_HCHAR,
                   1649:           PS_VTIC, PS_HTIC, PS_options, PS_init, PS_reset,
                   1650:           PS_text, null_scale, PS_graphics, PS_move, PS_vector,
                   1651:           PS_linetype, PS_put_text, PS_text_angle,
                   1652:           PS_justify_text, PS_point, do_arrow, PS_set_font, PS_pointsize,
                   1653:           0 /*flags*/, 0 /*suspend*/, 0 /*resume*/, PS_fillbox, PS_linewidth
                   1654:
                   1655: TERM_TABLE_END(post_driver)
                   1656:
                   1657: #undef LAST_TERM
                   1658: #define LAST_TERM post_driver
                   1659:
                   1660: #endif /* TERM_TABLE */
                   1661:
                   1662: #endif /* TERM_PROTO_ONLY */
                   1663:
                   1664: #ifdef TERM_HELP
                   1665: START_HELP(post)
                   1666: "1 postscript",
                   1667: "?commands set terminal postscript",
                   1668: "?set terminal postscript",
                   1669: "?set term postscript",
                   1670: "?terminal postscript",
                   1671: "?term postscript",
                   1672: "?postscript",
                   1673: " Several options may be set in the `postscript` driver.",
                   1674: "",
                   1675: " Syntax:",
                   1676: "       set terminal postscript {<mode>} {enhanced | noenhanced}",
                   1677: "                               {color | monochrome} {solid | dashed}",
                   1678: "                               {<duplexing>}",
                   1679: "                               {\"<fontname>\"} {<fontsize>}",
                   1680: "",
                   1681: " where <mode> is `landscape`, `portrait`, `eps` or `default`;",
                   1682: " `solid` draws all plots with solid lines, overriding any dashed patterns;",
                   1683: " <duplexing> is `defaultplex`, `simplex` or `duplex` (\"duplexing\" in",
                   1684: " PostScript is the ability of the printer to print on both sides of the same",
                   1685: " page---don't set this if your printer can't do it);",
                   1686: " `enhanced` activates the \"enhanced PostScript\" features (subscripts,",
                   1687: " superscripts and mixed fonts);",
                   1688: " `\"<fontname>\"` is the name of a valid PostScript font; and `<fontsize>` is",
                   1689: " the size of the font in PostScript points.",
                   1690: "",
                   1691: " `default` mode sets all options to their defaults: `landscape`, `monochrome`,",
                   1692: " `dashed`, `defaultplex`, `noenhanced`, \"Helvetica\" and 14pt.",
                   1693: "  Default size of a PostScript plot is 10 inches wide and 7 inches high.",
                   1694: "",
                   1695: " `eps` mode generates EPS (Encapsulated PostScript) output, which is just",
                   1696: " regular PostScript with some additional lines that allow the file to be",
                   1697: " imported into a variety of other applications.  (The added lines are",
                   1698: " PostScript comment lines, so the file may still be printed by itself.)  To",
                   1699: " get EPS output, use the `eps` mode and make only one plot per file.  In `eps`",
                   1700: " mode the whole plot, including the fonts, is reduced to half of the default",
                   1701: " size.",
                   1702: "",
                   1703: " Examples:",
                   1704: "       set terminal postscript default       # old postscript",
                   1705: "       set terminal postscript enhanced      # old enhpost",
                   1706: "       set terminal postscript landscape 22  # old psbig",
                   1707: "       set terminal postscript eps 14        # old epsf1",
                   1708: "       set terminal postscript eps 22        # old epsf2",
                   1709: "       set size 0.7,1.4; set term post portrait color \"Times-Roman\" 14",
                   1710: "",
                   1711: " Linewidths and pointsizes may be changed with `set linestyle`.",
                   1712: "",
                   1713: " The `postscript` driver supports about 70 distinct pointtypes, selectable",
                   1714: " through the `pointtype` option on `plot` and `set linestyle`.",
                   1715: "",
                   1716: " Several possibly useful files about `gnuplot`'s PostScript are included",
                   1717: " in the /docs/ps subdirectory of the `gnuplot` distribution and at the",
                   1718: " distribution sites.  These are \"ps_symbols.gpi\" (a `gnuplot` command file",
                   1719: " that, when executed, creates the file \"ps_symbols.ps\" which shows all the",
                   1720: " symbols available through the `postscript` terminal), \"ps_guide.ps\" (a",
                   1721: " PostScript file that contains a summary of the enhanced syntax and a page",
                   1722: " showing what the octal codes produce with text and symbol fonts) and",
                   1723: " \"ps_file.doc\" (a text file that contains a discussion of the organization",
                   1724: " of a PostScript file written by `gnuplot`).",
                   1725: "",
                   1726: " A PostScript file is editable, so once `gnuplot` has created one, you are",
                   1727: " free to modify it to your heart's desire.  See the \"editing postscript\"",
                   1728: " section for some hints.",
                   1729: "2 enhanced postscript",
                   1730: "?commands set terminal postscript enhanced",
                   1731: "?set terminal postscript enhanced",
                   1732: "?set term postscript enhanced",
                   1733: "?terminal postscript enhanced",
                   1734: "?term postscript enhanced",
                   1735: "?enhanced_postscript",
                   1736: "@start table - first is interactive cleartext form",
                   1737: "  Control      Examples        Explanation",
                   1738: "   ^           a^x             superscript",
                   1739: "   _           a_x             subscript",
                   1740: "   @           @x or a@^b_c    phantom box (occupies no width)",
                   1741: "   &           &{space}        inserts space of specified length",
                   1742: "#\\begin{tabular}{|ccl|} \\hline",
                   1743: "#\\multicolumn{3}{|c|}{Enhanced Text Control Codes} \\\\ \\hline",
                   1744: "#Control & Examples & Explanation \\\\ \\hline",
                   1745: "#\\verb~^~ & \\verb~a^x~ & superscript\\\\",
                   1746: "#\\verb~_~ & \\verb~a_x~ & subscript\\\\",
                   1747: "#\\verb~@~ & \\verb~@x or a@^b_c~ & phantom box (occupies no width)\\\\",
                   1748: "#\\verb~&~ & \\verb~&{space}~ & inserts space of specified length\\\\",
                   1749: "%c c l .",
                   1750: "%.TE", /* ugly - doc2ms uses @ for column separator, but here we */
                   1751: "%.TS", /* need @ in table, so end and restart the table ! */
                   1752: "%center box tab ($) ;",
                   1753: "%c c l .",
                   1754: "%Control$Examples$Explanation",
                   1755: "%_",
                   1756: "%^$a^x$superscript",
                   1757: "%\\&_$a\\&_x$subscript",
                   1758: "% @ $ @x or a\\&@^b\\&_c$phantom box (occupies no width)",
                   1759: "% & $ &{space}$inserts space of specified length",
                   1760: "@end table",
                   1761: "",
                   1762: " Braces can be used to place multiple-character text where a single character",
                   1763: " is expected (e.g., 2^{10}).  To change the font and/or size, use the full",
                   1764: " form:  {/[fontname][=fontsize | *fontscale] text}.  Thus {/Symbol=20 G} is a",
                   1765: " 20-point GAMMA) and {/*0.75 K} is a K at three-quarters of whatever fontsize",
                   1766: " is currently in effect.  (The '/' character MUST be the first character after",
                   1767: " the '{'.)",
                   1768: "",
                   1769: " If the encoding vector has been changed by `set encoding`, the default",
                   1770: " encoding vector can be used instead by following the slash with a dash.  This",
                   1771: " is unnecessary if you use the Symbol font, however---since /Symbol uses its",
                   1772: " own encoding vector, `gnuplot` will not apply any other encoding vector to",
                   1773: " it.",
                   1774: "",
                   1775: " The phantom box is useful for a@^b_c to align superscripts and subscripts",
                   1776: " but does not work well for overwriting an accent on a letter.  (To do the",
                   1777: " latter, it is much better to use `set encoding iso_8859_1` to change to the",
                   1778: " ISO Latin-1 encoding vector, which contains a large variety of letters with",
                   1779: " accents or other diacritical marks.)  Since the box is non-spacing, it is",
                   1780: " sensible to put the shorter of the subscript or superscript in the box (that",
                   1781: " is, after the @).",
                   1782: "",
                   1783: " Space equal in length to a string can be inserted using the '&' character.",
                   1784: " Thus",
                   1785: "         'abc&{def}ghi'",
                   1786: " would produce",
                   1787: "         'abc   ghi'.",
                   1788: "",
                   1789: " You can access special symbols numerically by specifying \\character-code (in",
                   1790: " octal), e.g., {/Symbol \\245} is the symbol for infinity.",
                   1791: "",
                   1792: " You can escape control characters using \\, e.g.,  \\\\, \\{, and so on.",
                   1793: "",
                   1794: " But be aware that strings in double-quotes are parsed differently than those",
                   1795: " enclosed in single-quotes.  The major difference is that backslashes may need",
                   1796: " to be doubled when in double-quoted strings.",
                   1797: "",
                   1798: " Examples (these are hard to describe in words---try them!):",
                   1799: "       set xlabel 'Time (10^6 {/Symbol m}s)'",
                   1800: "       set title '{/Symbol=18 \\362@_{/=9.6 0}^{/=12 x}} \\",
                   1801: "                  {/Helvetica e^{-{/Symbol m}^2/2} d}{/Symbol m}'",
                   1802: "",
                   1803: " The file \"ps_guide.ps\" in the /docs/ps subdirectory of the `gnuplot` source",
                   1804: " distribution contains more examples of the enhanced syntax.",
                   1805: "2 editing postscript",
                   1806: "?commands set terminal postscript editing",
                   1807: "?set terminal postscript editing",
                   1808: "?set term postscript editing",
                   1809: "?terminal postscript editing",
                   1810: "?term postscript editing",
                   1811: "?editing_postscript",
                   1812: " The PostScript language is a very complex language---far too complex to",
                   1813: " describe in any detail in this document.  Nevertheless there are some things",
                   1814: " in a PostScript file written by `gnuplot` that can be changed without risk of",
                   1815: " introducing fatal errors into the file.",
                   1816: "",
                   1817: " For example, the PostScript statement \"/Color true def\" (written into the",
                   1818: " file in response to the command `set terminal postscript color`), may be",
                   1819: " altered in an obvious way to generate a black-and-white version of a plot.",
                   1820: " Similarly line colors, text colors, line weights and symbol sizes can also be",
                   1821: " altered in straight-forward ways.  Text (titles and labels) can be edited to",
                   1822: " correct misspellings or to change fonts.  Anything can be repositioned, and",
                   1823: " of course anything can be added or deleted, but modifications such as these",
                   1824: " may require deeper knowledge of the PostScript language.",
                   1825: "",
                   1826: " The organization of a PostScript file written by `gnuplot` is discussed in",
                   1827: " the text file \"ps_file.doc\" in the /docs/ps subdirectory."
                   1828: END_HELP(post)
                   1829: #endif
                   1830:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>