5 #include "Dimensions.h"
11 #include "Utilities.h"
16 static void Prologue PROTO((void)); /* forward */
17 static void Variables PROTO((void)); /* forward */
18 static void BorderOutlineBox PROTO((void)); /* forward */
19 static void BigTitleOutlineBox PROTO((void)); /* forward */
20 static void TitleOutlineBox PROTO((void)); /* forward */
21 static void BigTitleText PROTO((void)); /* forward */
22 static void TitleText PROTO((void)); /* forward */
49 fprintf(psfp, "showpage\n");
53 static void StandardSpecialComments PROTO((void)); /* forward */
54 static void EPSFSpecialComments PROTO((floatish)); /* forward */
55 static void Landscape PROTO((void)); /* forward */
56 static void Portrait PROTO((void)); /* forward */
57 static void Scaling PROTO((floatish)); /* forward */
63 floatish epsfscale = epsfwidth / (floatish) borderwidth;
64 EPSFSpecialComments(epsfscale);
67 StandardSpecialComments();
68 if (gflag) Portrait(); else Landscape();
72 extern char *jobstring;
73 extern char *datestring;
76 StandardSpecialComments()
78 fprintf(psfp, "%%!PS-Adobe-2.0\n");
79 fprintf(psfp, "%%%%Title: %s\n", jobstring);
80 fprintf(psfp, "%%%%Creator: %s (version %s)\n", programname, VERSION);
81 fprintf(psfp, "%%%%CreationDate: %s\n", datestring);
82 fprintf(psfp, "%%%%EndComments\n");
86 EPSFSpecialComments(epsfscale)
89 fprintf(psfp, "%%!PS-Adobe-2.0\n");
90 fprintf(psfp, "%%%%Title: %s\n", jobstring);
91 fprintf(psfp, "%%%%Creator: %s (version %s)\n", programname, VERSION);
92 fprintf(psfp, "%%%%CreationDate: %s\n", datestring);
93 fprintf(psfp, "%%%%BoundingBox: 0 0 %d %d\n",
94 (int) (borderwidth * epsfscale + 0.5),
95 (int) (borderheight * epsfscale + 0.5) );
96 fprintf(psfp, "%%%%EndComments\n");
104 fprintf(psfp, "-90 rotate\n");
105 fprintf(psfp, "%f %f translate\n", -(borderwidth + (floatish) START_Y),
112 fprintf(psfp, "%f %f translate\n", (floatish) START_X, (floatish) START_Y);
119 fprintf(psfp, "%f %f scale\n", epsfscale, epsfscale);
126 fprintf(psfp, "/HE%d /Helvetica findfont %d scalefont def\n",
127 NORMAL_FONT, NORMAL_FONT);
129 fprintf(psfp, "/HE%d /Helvetica findfont %d scalefont def\n",
130 LARGE_FONT, LARGE_FONT);
137 fprintf(psfp, "newpath\n");
138 fprintf(psfp, "0 0 moveto\n");
139 fprintf(psfp, "0 %f rlineto\n", borderheight);
140 fprintf(psfp, "%f 0 rlineto\n", borderwidth);
141 fprintf(psfp, "0 %f rlineto\n", -borderheight);
142 fprintf(psfp, "closepath\n");
143 fprintf(psfp, "%f setlinewidth\n", borderthick);
144 fprintf(psfp, "stroke\n");
150 fprintf(psfp, "newpath\n");
151 fprintf(psfp, "%f %f moveto\n", borderspace,
152 borderheight - titleheight - borderspace);
153 fprintf(psfp, "0 %f rlineto\n", titleheight);
154 fprintf(psfp, "%f 0 rlineto\n", titlewidth);
155 fprintf(psfp, "0 %f rlineto\n", -titleheight);
156 fprintf(psfp, "closepath\n");
157 fprintf(psfp, "%f setlinewidth\n", borderthick);
158 fprintf(psfp, "stroke\n");
160 fprintf(psfp, "%f %f moveto\n", borderspace,
161 borderheight - titleheight / 2 - borderspace);
162 fprintf(psfp, "%f 0 rlineto\n", titlewidth);
163 fprintf(psfp, "stroke\n");
170 fprintf(psfp, "newpath\n");
171 fprintf(psfp, "%f %f moveto\n", borderspace,
172 borderheight - titleheight - borderspace);
173 fprintf(psfp, "0 %f rlineto\n", titleheight);
174 fprintf(psfp, "%f 0 rlineto\n", titlewidth);
175 fprintf(psfp, "0 %f rlineto\n", -titleheight);
176 fprintf(psfp, "closepath\n");
177 fprintf(psfp, "%f setlinewidth\n", borderthick);
178 fprintf(psfp, "stroke\n");
181 static void EscapePrint PROTO((char *, int)); /* forward */
188 x = borderspace + titletextspace;
189 y = borderheight - titleheight / 2 - borderspace + titletextspace;
191 /* job identifier goes on top at the far left */
193 fprintf(psfp, "HE%d setfont\n", TITLE_TEXT_FONT);
194 fprintf(psfp, "%f %f moveto\n", x, y);
196 EscapePrint(jobstring, BIG_JOB_STRING_WIDTH);
197 fprintf(psfp, ") show\n");
199 y = borderheight - titleheight - borderspace + titletextspace;
201 /* area below curve gows at the botton, far left */
203 fprintf(psfp, "HE%d setfont\n", TITLE_TEXT_FONT);
204 fprintf(psfp, "%f %f moveto\n", x, y);
206 CommaPrint(psfp, (intish)areabelow);
207 fprintf(psfp, " %s x %s)\n", valueunitstring, sampleunitstring);
208 fprintf(psfp, "show\n");
210 /* date goes at far right */
212 fprintf(psfp, "HE%d setfont\n", TITLE_TEXT_FONT);
213 fprintf(psfp, "(%s)\n", datestring);
214 fprintf(psfp, "dup stringwidth pop\n");
215 fprintf(psfp, "%f\n", (titlewidth + borderspace) - titletextspace);
216 fprintf(psfp, "exch sub\n");
217 fprintf(psfp, "%f moveto\n", y);
218 fprintf(psfp, "show\n");
227 x = borderspace + titletextspace;
228 y = borderheight - titleheight - borderspace + titletextspace;
230 /* job identifier goes at far left */
232 fprintf(psfp, "HE%d setfont\n", TITLE_TEXT_FONT);
233 fprintf(psfp, "%f %f moveto\n", x, y);
235 EscapePrint(jobstring, SMALL_JOB_STRING_WIDTH);
236 fprintf(psfp, ") show\n");
238 /* area below curve is centered */
240 fprintf(psfp, "HE%d setfont\n", TITLE_TEXT_FONT);
242 CommaPrint(psfp, (intish) areabelow);
243 fprintf(psfp, " %s x %s)\n", valueunitstring, sampleunitstring);
245 fprintf(psfp, "dup stringwidth pop\n");
246 fprintf(psfp, "2 div\n");
247 fprintf(psfp, "%f\n", titlewidth / 2);
248 fprintf(psfp, "exch sub\n");
249 fprintf(psfp, "%f moveto\n", y);
250 fprintf(psfp, "show\n");
252 /* date goes at far right */
254 fprintf(psfp, "HE%d setfont\n", TITLE_TEXT_FONT);
255 fprintf(psfp, "(%s)\n", datestring);
256 fprintf(psfp, "dup stringwidth pop\n");
257 fprintf(psfp, "%f\n", (titlewidth + borderspace) - titletextspace);
258 fprintf(psfp, "exch sub\n");
259 fprintf(psfp, "%f moveto\n", y);
260 fprintf(psfp, "show\n");
264 * Print a string s in width w, escaping characters where necessary.
271 for ( ; *s && w > 0; s++, w--) {
272 if (*s == '(') { /* escape required */
274 } else if (*s == ')') {