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