Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 565 lines (482 sloc) 14.565 kb
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
1 /* lpps.c */
2 /* Copyright 1995 by Steve Kirkendall */
3
4
5
6 /* This file contains a driver for Adobe PostScript. The driver supports
7 * printing text either 1-up or 2-up.
8 */
9
10
11 #include "elvis.h"
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
12 #ifdef FEATURE_RCSID
13 char id_lpps[] = "$Id: lpps.c,v 2.31 2003/10/17 17:41:23 steve Exp $";
14 #endif
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored
15 #ifdef FEATURE_LPR
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
16
17 #if USE_PROTOTYPES
18 static void out(char *str, char *param);
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
19 static void outdef(char *name, char *value);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
20 static void psmove(int newrow, int newcol);
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
21 static void pscenter(int newrow, int newcol, char *cmd);
22 static void pscolor(_char_ newfont);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
23 static void psstring(_char_ newfont);
24 static void pagestart(void);
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
25 static void pageend(ELVBOOL final);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
26 static void before(int minorno, void (*draw)(_CHAR_));
27 static void fontch(_char_ font, _CHAR_ ch);
28 static void page(int linesleft);
29 static void after(int linesleft);
30 #endif
31
32 /* These variables store the current state of the driver */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
33 static int elvrow; /* Row where elvis thinks cursor is */
34 static int elvcol; /* Column where elvis thinks cursor is */
35 static int elvfont; /* Current elvis font */
36 static unsigned char elvrgb[3]; /* Current color */
37 static int psrow; /* Row where cursor is located */
38 static int pscol; /* Column where cursor is located */
39 static char psfont; /* Current PS font - one of n/b/i */
40 static ELVBOOL instr; /* Are we in the middle of outputting a string? */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
41 static int width; /* width of current string, measured in characters */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
42 static ELVBOOL twoup; /* Print two logical pages on each piece of paper? */
43 static ELVBOOL even; /* ElvTrue during printing of second logical page */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
44 static long pagenum;/* Physical page number */
45
46
47 /* This is a pointer to the draw() function to use for outputing individual
48 * characters. It is set by the before() function, and remains valid until
49 * the after() function returns.
50 */
51 static void (*prtchar) P_((_CHAR_ ch));
52
53
54 /* Output a constant string to the printer, optionally followed by another
55 * string, and then an implied newline. This is used mostly for outputting
56 * the header.
57 */
58 static void out(str, param)
59 char *str; /* string to be output */
60 char *param; /* optional second string */
61 {
62 while (*str)
63 {
64 (*prtchar)((_CHAR_)*str++);
65 }
66 while (param && *param)
67 {
68 (*prtchar)((_CHAR_)*param++);
69 }
70 (*prtchar)((_CHAR_)'\n');
71 }
72
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
73 /* output a PostScript def command */
74 static void outdef(name, value)
75 char *name; /* string to be output */
76 char *value; /* optional second string */
77 {
78 while (*name)
79 {
80 (*prtchar)((_CHAR_)*name++);
81 }
82 (*prtchar)((_CHAR_)' ');
83 out(value, " def");
84 }
85
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
86
87 /* This function moves the PostScript cursor to a given row/column, if it
88 * isn't there already.
89 */
90 static void psmove(newrow, newcol)
91 int newrow; /* new row number, with 0 being the top of the page */
92 int newcol; /* column number, with 0 being the leftmost column */
93 {
94 char buf[50];
95 int psx, psy; /* PostScript coordinates for position */
96
97 /* If the PS cursor is already there, then do nothing */
98 if (newrow == psrow && newcol == pscol)
99 return;
100
101 /* Convert row/column position to PostScript coordinates. Here, we
102 * assume that each character is 1/10 of an inch wide and 1/6 of an
103 * inch high. We also assume that the font's baseline is about 1/6
104 * of the way up the character cell.
105 */
106 psx = newcol * 72;
107 psy = (o_lplines - newrow) * 120 - 100;
108
109 /* Output a "move" command */
110 sprintf(buf, "%d.%d %d.%d moveto", psx/10, psx%10, psy/10, psy%10);
111 out(buf, NULL);
112 psrow = newrow;
113 pscol = newcol;
114 }
115
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
116 /* This function moves the PostScript cursor to the *CENTER* of a the
117 * character cell for a given row/column, and then optionally outputs some
118 * other command.
119 */
120 static void pscenter(newrow, newcol, cmd)
121 int newrow; /* new row number, with 0 being the top of the page */
122 int newcol; /* column number, with 0 being the leftmost column */
123 char *cmd; /* command to execute at the center */
124 {
125 char buf[100];
126 int psx, psy; /* PostScript coordinates for position */
127
128 /* Convert row/column position to PostScript coordinates. Here, we
129 * assume that each character is 1/10 of an inch wide and 1/6 of an
130 * inch high. We also assume that the font's baseline is about 1/6
131 * of the way up the character cell.
132 */
133 psx = newcol * 72 + 36;
134 psy = (o_lplines - newrow) * 120 - 60;
135
136 /* Output the coordinates and the command */
137 sprintf(buf, "%d.%d %d.%d %s", psx/10, psx%10, psy/10, psy%10, cmd);
138 out(buf, NULL);
139 pscol = -1;
140 }
141
142 static void pscolor(newfont)
143 _char_ newfont; /* font whose colors to use */
144 {
145 char str[100];
146 unsigned char rgb[3];
147
148 /* if "lpcolor" is unset, then do nothing */
149 if (!o_lpcolor)
150 return;
151
152 /* find the color of this font */
153 memcpy(rgb, lpfg(newfont), 3);
154
155 /* if same as previous color, then do nothing */
156 if (!memcmp(rgb, elvrgb, 3))
157 return;
158
159 /* output a color change command */
160 sprintf(str, "%d 255.0 div %d 255.0 div %d 255.0 div setrgbcolor",
161 rgb[0], rgb[1], rgb[2]);
162 out(str, NULL);
163
164 /* remember the color */
165 memcpy(elvrgb, rgb, 3);
166 }
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
167
168 /* This function starts and/or ends a string. It also handles font changes */
169 static void psstring(newfont)
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
170 _char_ newfont; /* font to load */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
171 {
172 char newps; /* new postscript font */
173 int oldcol;
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
174 int bits;
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
175
176 /* If fonts haven't changed, we don't need to do anything */
177 if (newfont == elvfont && instr)
178 return;
179
180 /* If we were in a string before, we need to draw it now. */
181 if (instr)
182 {
183 /* end the string */
184 (*prtchar)(')');
185
186 /* drawing underlined strings requires extra work */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
187 bits = colorinfo[elvfont].da.bits;
188 if (bits & (COLOR_BOXED | COLOR_UNDERLINED))
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
189 {
190 /* Output the string, and also find its width */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
191 out(" dup ElvisShow ElvisStringWidth", NULL);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
192
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
193 /* Begin drawing a new path. */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
194 out(" newpath", NULL);
195 oldcol = pscol;
196 pscol = -1;
197 psmove(elvrow, oldcol);
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
198
199 /* BOXED or UNDERLINED? */
200 if (bits & COLOR_BOXED)
201 {
202 /* Draw all four sides of a box */
203 out(" 0 -3 rmoveto dup 0 rlineto", NULL);
204 out(" 0 12 rlineto", NULL);
205 out(" neg 0 rlineto", NULL);
206 out(" closepath", NULL);
207 }
208 else
209 {
210 /* Just draw an underline */
211 out(" 0 -1 rmoveto 0 rlineto", NULL);
212 }
213
214 /* Draw it */
215 out(" stroke", NULL);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
216
217 /* That leaves the PS cursor position undefined */
218 pscol = psrow = -1;
219 }
220 else
221 {
222 /* output the string */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
223 out(" ElvisShow", NULL);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
224 pscol += width;
225 }
226
227 /* we are no longer in a string */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
228 instr = ElvFalse;
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
229 width = 0;
230 }
231
232 /* if no new font is specified, we're done */
233 if (!newfont)
234 return;
235
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
236 /* Adjust colors */
237 pscolor(newfont);
238
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
239 /* Move the cursor to where the new string will be output */
240 psmove(elvrow, elvcol);
241
242 /* If necessary, switch postscript fonts */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
243 bits = colorinfo[newfont].da.bits;
244 if (bits & COLOR_BOLD)
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
245 newps = 'b';
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
246 else if (bits & COLOR_ITALIC)
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
247 newps = 'i';
248 else
249 newps = 'n';
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
250 if (bits & COLOR_PROP)
251 newps = elvtoupper(newps);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
252 if (newps != psfont)
253 {
254 switch (newps)
255 {
256 case 'n': out("ElvisN", " setfont"); break;
257 case 'b': out("ElvisB", " setfont"); break;
258 case 'i': out("ElvisI", " setfont"); break;
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
259 case 'N': out("ElvisPN", " setfont"); break;
260 case 'B': out("ElvisPB", " setfont"); break;
261 case 'I': out("ElvisPI", " setfont"); break;
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
262 }
263 psfont = newps;
264 }
265 elvfont = newfont;
266
267 /* start outputing a new string */
268 (*prtchar)('(');
269
270 /* we are now in a string */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
271 instr = ElvTrue;
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
272 }
273
274
275 /* Prepare for the next logical page. For one-up printing, this is fairly
276 * simple. For two-up, it depends on whether this is the first logical page
277 * on this sheet of paper, or the second logical page.
278 */
279 static void pagestart()
280 {
281 char buf[12];
282
283 /* reset variables */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
284 elvrow = elvcol = elvfont = 0;
285 memset(elvrgb, 0, 3);
286 psfont = '\0';
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
287 psrow = psfont = -1; /* to force movement the first time */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
288 instr = ElvFalse;
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
289 width = 0;
290
291 /* output a comment, if at the top of a physical page */
292 if (!twoup || !even)
293 {
294 sprintf(buf, "%ld", pagenum++);
295 out("%%Page: page ", buf);
296 }
297
298 /* change graphic context, depending on printing style */
299 if (!twoup)
300 {
301 out("gsave ElvisPage", NULL);
302 }
303 else if (!even)
304 {
305 out("gsave ElvisLeftPage", NULL);
306 }
307 else
308 {
309 out("gsave ElvisRightPage", NULL);
310 }
311 }
312
313
314 /* This function ends a logical page */
315 static void pageend(final)
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
316 ELVBOOL final; /* is this the last page of the print job? */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
317 {
318 /* end the current string, if any */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
319 psstring(0);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
320
321 out("grestore", NULL);
322 if (!twoup || even || final)
323 {
324 out("showpage", NULL);
325 }
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
326 even = (ELVBOOL)!even;
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
327 }
328
329
330 /* This is the before() function. It sets the prtchar variable, and outputs
331 * the PostScript header.
332 */
333 static void before(minorno, draw)
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
334 int minorno; /* logical pages per sheet */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
335 void (*draw) P_((_CHAR_)); /* function for sending single char to printer */
336 {
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
337 char *tmp;
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
338 FILE *fp;
339 int ch;
340 char paper[20];
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
341 int j;
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
342
343 /* Set the ptype and out function */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
344 twoup = (ELVBOOL)(minorno == 2);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
345 prtchar = draw;
346
347 /* Output the basic header */
348 out("%!PS-Adobe-2.0", NULL);
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
349 out("%%Creator: Elvis ", VERSION);
350 out("%%Orientation:", twoup ? "Landscape" : "Portrait");
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
351 out("%%EndComments", "\n");
352
353 out("%%BeginProlog", NULL);
354
355 /* output the paper size. This can be used by the lib/elvis.ps file
356 * to adjust its size and positions.
357 */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
358 tmp = lpoptfield("paper", "default");
359 paper[0] = '(';
360 for (j = 1; *tmp; tmp++)
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
361 {
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
362 if (elvalnum(*tmp))
363 paper[j++] = *tmp;
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
364 }
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
365 strcpy(&paper[j], ")");
366 outdef("/ElvisPaper", paper);
367 outdef("/ElvisBar", lpoptfield("bar", "false"));
368 outdef("/ElvisFrame", lpoptfield("frame", "true"));
369 outdef("/ElvisPunch", lpoptfield("punch", "false"));
370 outdef("/ElvisClip", lpoptfield("clip", "false"));
371 sprintf(paper, "%ld", o_lplines);
372 outdef("/ElvisLines", paper);
373 sprintf(paper, "%ld", o_lpcolumns);
374 outdef("/ElvisColumns", paper);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
375
376 /* Define the fonts that we'll be using. Note that we don't define
377 * fonts for 'g' and 'u' because they're done using graphics and the
378 * 'n' font.
379 *
380 * Also define some page positioning macros.
381 */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
382 tmp = iopath(tochar8(o_elvispath), "elvis.ps", ElvFalse);
383 if (tmp && (fp = fopen(tmp, "r")) != NULL)
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
384 {
385 /* Copy definitions from the "lib/elvis.ps" file */
386 while ((ch = getc(fp)) != EOF)
387 {
388 (*prtchar)((_CHAR_)ch);
389 }
390 fclose(fp);
391 }
392 else
393 {
394 /* Use default definitions. These are not sensitive to the
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
395 * lpcolumns, lprows, and lpoptions options.
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
396 */
397 out("/ElvisN /Courier findfont 12 scalefont def", NULL);
398 out("/ElvisB /Courier-Bold findfont 12 scalefont def", NULL);
399 out("/ElvisI /Courier-Oblique findfont 12 scalefont def", NULL);
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
400 out("/ElvisPN /Courier findfont 12 scalefont def", NULL);
401 out("/ElvisPB /Courier-Bold findfont 12 scalefont def", NULL);
402 out("/ElvisPI /Courier-Oblique findfont 12 scalefont def", NULL);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
403 out("/ElvisPage { 12 36 translate } def", NULL);
404 out("/ElvisLeftPage { 12 750 translate -90 rotate 0.58 0.75 scale } def", NULL);
405 out("/ElvisRightPage { newpath 12 394 moveto 576 0 rlineto stroke 12 366 translate -90 rotate 0.58 0.75 scale } def", NULL);
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
406 out("/ElvisStringWidth { stringwidth pop } def", NULL);
407 out("/ElvisShow { show } def", NULL);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
408 }
409 out("%%EndProlog", "\n");
410
411 /* Prepare for first page */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
412 even = ElvFalse;
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
413 pagenum = 1;
414 pagestart();
415 }
416
417
418
419 /* This function adds a character to the output, simulating the behavior of
420 * control characters. (The only possible control character is '\n'.)
421 */
422 static void fontch(font, ch)
423 _char_ font; /* font of the next character from text image */
424 _CHAR_ ch; /* the next character */
425 {
426 char buf[10];
427
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
428 if (font == 0)
429 font = 1;
430
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
431 if (ch == '\n')
432 {
433 /* end the current string, if any */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
434 psstring(0);
435
436 /* add a line break in the PostScipt code */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
437 (*prtchar)('\n');
438
439 /* move to the start of the next line */
440 elvcol = 0;
441 elvrow++;
442 }
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
443 else if ((colorinfo[font].da.bits & COLOR_GRAPHIC)
444 && strchr("123456789|-", (_char_)ch))
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
445 {
446 /* End any current string. */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
447 psstring(0);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
448
449 /* Move to the center of the character cell */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
450 pscolor(font);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
451 out("newpath", NULL);
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
452 pscenter(elvrow, elvcol, "moveto");
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
453
454 /* Maybe draw an uptick */
455 if (strchr("123456|", (_char_)ch))
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
456 out(" 0 6.1 rlineto 0 -6.1 rmoveto", NULL);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
457
458 /* Maybe draw a downtick */
459 if (strchr("456789|", (_char_)ch))
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
460 out(" 0 -6.1 rlineto 0 6.1 rmoveto", NULL);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
461
462 /* Maybe draw a lefttick */
463 if (strchr("235689-", (_char_)ch))
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
464 out(" -3.7 0 rlineto 3.7 0 rmoveto", NULL);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
465
466 /* Maybe draw a righttick */
467 if (strchr("124578-", (_char_)ch))
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
468 out(" 3.7 0 rlineto -3.7 0 rmoveto", NULL);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
469
470 /* Draw those lines, and move to next character cell */
471 out(" stroke", NULL);
472 elvcol++;
473 pscol = -1;
474 }
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
475 else if ((colorinfo[font].da.bits & COLOR_GRAPHIC)
476 && (ch == 'o' || ch == '*'))
477 {
478 /* End any current string. */
479 psstring(0);
480
481 /* Stroke a complete circle at center of character cell */
482 pscolor(font);
483 out("newpath", NULL);
484 pscenter(elvrow, elvcol, "3 0 360 arc");
485
486 /* Either fill or draw the stroke */
487 if (ch == 'o')
488 out(" stroke", NULL);
489 else
490 out(" fill", NULL);
491 elvcol++;
492 pscol = -1;
493 }
494 else if (!instr && ch == ' '
495 && (colorinfo[font].da.bits & COLOR_GRAPHIC) != COLOR_GRAPHIC
496 && (colorinfo[font].da.bits & COLOR_UNDERLINED) == 0)
497 {
498 /* Skip leading spaces because they make the left margin
499 * be ragged, since variable-pitch fonts are output with a
500 * varying horizontal scale factor to make their overall
501 * width be the same as fixed-pitch. We do need to count
502 * its width though.
503 */
504 elvcol++;
505 }
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
506 else
507 {
508 /* start a new string, if necessary */
509 psstring(font);
510
511 /* Add the character to the current string */
512 if (ch == '(' || ch == ')' || ch == '\\')
513 {
514 (*prtchar)('\\');
515 (*prtchar)(ch);
516 }
517 else if (ch >= 127)
518 {
519 sprintf(buf, "%03o", ch);
520 (*prtchar)('\\');
521 (*prtchar)((_CHAR_)buf[0]);
522 (*prtchar)((_CHAR_)buf[1]);
523 (*prtchar)((_CHAR_)buf[2]);
524 }
525 else
526 {
527 (*prtchar)(ch);
528 }
529 elvcol++;
530 }
531 }
532
533
534 /* This function is called after every page except the last one */
535 static void page(linesleft)
536 int linesleft; /* lines remaining on page */
537 {
538 /* end the page */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
539 pageend(ElvFalse);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
540
541 /* start the next page */
542 pagestart();
543 }
544
545
546 /* This function is called at the end of the print job. It can output a
547 * final formfeed, restore fonts, or whatever.
548 */
549 static void after(linesleft)
550 int linesleft; /* lines remaining on final page */
551 {
552 /* print the last page */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
553 pageend(ElvTrue);
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
554
555 /* output a trailer */
556 out("%%Trailer", NULL);
557 }
558
559
560 /* These describe the printer types supported by these functions */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
561 LPTYPE lpps = {"ps", 1, ElvTrue, before, fontch, page, after};
562 LPTYPE lpps2 = {"ps2", 2, ElvTrue, before, fontch, page, after};
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored
563
564 #endif /* FEATURE_LPR */
Something went wrong with that request. Please try again.