1 /* Hello, Emacs, this is -*-C-*-
2 * $Id: corel.trm,v 1.17 2006/07/21 02:35:45 sfeam Exp $
8 A modified ai.trm for CorelDraw import filters
9 by Chris Parks, parks@physics.purdue.edu
10 Import from CorelDraw with the CorelTrace filter
12 syntax: set terminal default
13 set terminal mode "fontname" fontsize,xsize,ysize,linewidth
15 mode= color or monochrome (default=mono)
16 "fontname"= postscript font name (default="SwitzerlandLight")
17 fontsize = size of font in points (default=22pt)
18 xsize = width of page in inches (default=8.2in)
19 ysize = height of page in inches (default=10in)
20 linewidth = width of lines in points (default=1.2pt)
25 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
35 TERM_PUBLIC void COREL_options __PROTO((void));
36 TERM_PUBLIC void COREL_init __PROTO((void));
37 TERM_PUBLIC void COREL_graphics __PROTO((void));
38 TERM_PUBLIC void COREL_text __PROTO((void));
39 TERM_PUBLIC void COREL_reset __PROTO((void));
40 TERM_PUBLIC void COREL_linetype __PROTO((int linetype));
41 TERM_PUBLIC void COREL_move __PROTO((unsigned int x, unsigned int y));
42 TERM_PUBLIC void COREL_vector __PROTO((unsigned int x, unsigned int y));
43 TERM_PUBLIC void COREL_put_text __PROTO((unsigned int x, unsigned int y,
45 TERM_PUBLIC int COREL_text_angle __PROTO((int ang));
46 TERM_PUBLIC int COREL_justify_text __PROTO((enum JUSTIFY mode));
47 #define CORELD_XMAX 5960 /* 8.2 inches wide */
48 #define CORELD_YMAX 7200 /* 10 inches high */
49 #define CORELD_VTIC (CORELD_YMAX/80)
50 #define CORELD_HTIC (CORELD_YMAX/80)
51 #define CORELD_VCHAR (22*COREL_SC) /* default is 22 point characters */
52 #define CORELD_HCHAR (22*COREL_SC*6/10)
55 #ifndef TERM_PROTO_ONLY
58 #define DEFAULT_CORELFONT "SwitzerlandLight"
60 /* plots for publication should be sans-serif (don't use TimesRoman) */
61 static char corel_font[MAX_ID_LEN + 1] = DEFAULT_CORELFONT; /* name of font */
62 static int corel_fontsize = 22; /* size of font in pts */
63 static TBOOLEAN corel_color = FALSE;
64 static TBOOLEAN corel_stroke = FALSE;
65 static int corel_path_count = 0; /* count of lines in path */
66 static int corel_ang = 0; /* text angle */
67 static enum JUSTIFY corel_justify = LEFT; /* text is flush left */
70 /* default mode constants */
71 #define CORELD_XOFF 0 /* page offset in pts */
73 #define COREL_SC (10.0) /* scale is 1pt = 10 units */
74 #define CORELD_LW (1.2*COREL_SC) /* linewidth = 1.2 pts */
76 static unsigned int corel_xmax = CORELD_XMAX;
77 static unsigned int corel_ymax = CORELD_YMAX;
78 static float corel_lw = CORELD_LW;
80 enum COREL_id {COREL_DEFAULT, COREL_MONOCHROME, COREL_COLOR, COREL_OTHER };
82 static struct gen_table COREL_opts[] =
84 { "def$ault", COREL_DEFAULT},
85 { "mono$chrome", COREL_MONOCHROME },
86 { "color$", COREL_COLOR },
87 { "colour$", COREL_COLOR },
96 while (!END_OF_COMMAND) {
97 switch(lookup_table(&COREL_opts[0],c_token)) {
100 strcpy(corel_font, DEFAULT_CORELFONT);
102 corel_lw = CORELD_LW;
103 corel_xmax = CORELD_XMAX;
104 corel_ymax = CORELD_YMAX;
107 case COREL_MONOCHROME:
118 if (isstring(c_token)) {
119 quote_str(corel_font, c_token, MAX_ID_LEN);
122 /* We have font size specified */
123 corel_fontsize = (int) real(const_express(&a));
125 term->v_char = (unsigned int) (corel_fontsize * COREL_SC);
126 term->h_char = (unsigned int) (corel_fontsize * COREL_SC * 6 / 10);
132 /* FIXME - argh. Stupid syntax alert here */
133 if (!END_OF_COMMAND) {
134 corel_xmax = (unsigned int) (real(const_express(&a)) * 720);
136 if (!END_OF_COMMAND) {
137 corel_ymax = (unsigned int) (real(const_express(&a)) * 720);
140 term->xmax = corel_xmax;
141 term->ymax = corel_ymax;
142 term->v_tic = corel_ymax / 80;
143 term->h_tic = corel_ymax / 80;
145 if (!END_OF_COMMAND) {
146 corel_lw = real(const_express(&a)) * COREL_SC;
149 sprintf(term_options, "%s \"%s\" %d,%0.1f,%0.1f,%0.1f",
150 corel_color ? "color" : "monochrome", corel_font,
151 corel_fontsize, corel_xmax / 720.0, corel_ymax / 720.0,
152 corel_lw / COREL_SC);
158 fprintf(gpoutfile, "\
159 %%!PS-Adobe-2.0 EPSF-1.2\n\
160 %%%%BoundingBox: %d %d %d %d\n\
161 %%%%TemplateBox: %d %d %d %d\n\
164 %%%%BeginSetup\n%%%%EndSetup\n",
165 CORELD_XOFF, CORELD_YOFF,
166 (int) ((corel_xmax) / COREL_SC + 0.5 + CORELD_XOFF),
167 (int) ((corel_ymax) / COREL_SC + 0.5 + CORELD_YOFF),
168 CORELD_XOFF, CORELD_YOFF,
169 (int) ((corel_xmax) / COREL_SC + 0.5 + CORELD_XOFF),
170 (int) ((corel_ymax) / COREL_SC + 0.5 + CORELD_YOFF));
177 corel_path_count = 0;
178 corel_stroke = FALSE;
186 fputs("S\n", gpoutfile);
187 corel_stroke = FALSE;
189 corel_path_count = 0;
196 fputs("%%Trailer\n", gpoutfile);
201 COREL_linetype(int linetype)
204 fputs("S\n", gpoutfile);
205 corel_stroke = FALSE;
209 fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
211 fputs("0 0 0 1 K\n", gpoutfile);
215 0 j\n0 G\n", gpoutfile);
220 fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
222 fputs("0 0 0 1 K\n", gpoutfile);
226 0 j\n0 G\n", gpoutfile);
231 fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
233 fputs("1 0 1 0 K\n", gpoutfile);
237 2 j\n0 G\n", gpoutfile);
242 fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
244 fputs("1 1 0 0 K\n", gpoutfile);
248 2 j\n0 G\n", gpoutfile);
253 fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
255 fputs("0 1 1 0 K\n", gpoutfile);
259 2 j\n0 G\n", gpoutfile);
264 fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
266 fputs("0 1 0 0 K\n", gpoutfile);
270 2 j\n0 G\n", gpoutfile);
275 fprintf(gpoutfile, "%f w\n", corel_lw / COREL_SC);
277 fputs("1 0 0 0 K\n", gpoutfile);
281 2 j\n0 G\n", gpoutfile);
286 fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
288 fputs("0 0 1 0 K\n", gpoutfile);
292 2 j\n0 G\n", gpoutfile);
297 fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
299 fputs("0 0 0 1 K\n", gpoutfile);
303 2 j\n0 G\n", gpoutfile);
308 fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
310 fputs("0 0.7 1 0 K\n", gpoutfile);
314 2 j\n0 G\n", gpoutfile);
319 fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
321 fputs("0.5 0.5 0.5 0 K\n", gpoutfile);
324 [2 2 2 2 2 2 2 4] 0 d\n\
325 2 j\n0 G\n", gpoutfile);
329 corel_path_count = 0;
334 COREL_move(unsigned int x, unsigned int y)
337 fputs("S\n", gpoutfile);
338 fprintf(gpoutfile, "%0.2f %0.2f m\n", x / COREL_SC, y / COREL_SC);
339 corel_path_count += 1;
345 COREL_vector(unsigned int x, unsigned int y)
347 fprintf(gpoutfile, "%.2f %.2f l\n", x / COREL_SC, y / COREL_SC);
348 corel_path_count += 1;
350 if (corel_path_count >= 400) {
351 fprintf(gpoutfile, "S\n%.2f %.2f m\n", x / COREL_SC, y / COREL_SC);
352 corel_path_count = 0;
358 COREL_put_text(unsigned int x, unsigned int y, const char *str)
362 fputs("S\n", gpoutfile);
363 corel_stroke = FALSE;
365 switch (corel_justify) {
367 fprintf(gpoutfile, "/_%s %d %d 0 0 z\n",
368 corel_font, corel_fontsize, corel_fontsize);
371 fprintf(gpoutfile, "/_%s %d %d 0 1 z\n",
372 corel_font, corel_fontsize, corel_fontsize);
375 fprintf(gpoutfile, "/_%s %d %d 0 2 z\n",
376 corel_font, corel_fontsize, corel_fontsize);
379 if (corel_ang == 0) {
380 fprintf(gpoutfile, "[1 0 0 1 %.2f %.2f]e\n0 g\n",
381 x / COREL_SC, y / COREL_SC - corel_fontsize / 3.0);
383 fprintf(gpoutfile, "[0 1 -1 0 %.2f %.2f]e\n0 g\n",
384 x / COREL_SC - corel_fontsize / 3.0, y / COREL_SC);
387 putc('(', gpoutfile);
390 if ((ch == '(') || (ch == ')') || (ch == '\\'))
391 putc('\\', gpoutfile);
395 fputs(")t\nT\n", gpoutfile);
396 corel_path_count = 0;
400 COREL_text_angle(int ang)
407 COREL_justify_text(enum JUSTIFY mode)
409 corel_justify = mode;
413 #endif /* TERM_BODY */
417 TERM_TABLE_START(corel_driver)
418 "corel", "EPS format for CorelDRAW",
419 CORELD_XMAX, CORELD_YMAX, CORELD_VCHAR, CORELD_HCHAR,
420 CORELD_VTIC, CORELD_HTIC, COREL_options, COREL_init, COREL_reset,
421 COREL_text, null_scale, COREL_graphics, COREL_move, COREL_vector,
422 COREL_linetype, COREL_put_text, COREL_text_angle,
423 COREL_justify_text, do_point, do_arrow, set_font_null
424 TERM_TABLE_END(corel_driver)
427 #define LAST_TERM corel_driver
429 #endif /* TERM_TABLE */
430 #endif /* TERM_PROTO_ONLY */
435 "?commands set terminal corel",
436 "?set terminal corel",
441 " The `corel` terminal driver supports CorelDraw.",
444 " set terminal corel { default",
445 " | {monochrome | color",
446 " {\"<font>\" {<fontsize> ",
447 " {<xsize> <ysize> {<linewidth> }}}}}",
449 " where the fontsize and linewidth are specified in points and the sizes in",
450 " inches. The defaults are monochrome, \"SwitzerlandLight\", 22, 8.2, 10 and 1.2."
452 #endif /* TERM_HELP */