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