1 /* Hello, Emacs, this is -*-C-*-
2 * $Id: hpljii.trm,v 1.24 2006/07/21 02:35:47 sfeam Exp $
6 /* GNUPLOT - hpljii.trm */
9 * Copyright 1990 - 1993, 1998, 2004 Thomas Williams, Colin Kelley
11 * Permission to use, copy, and distribute this software and its
12 * documentation for any purpose with or without fee is hereby granted,
13 * provided that the above copyright notice appear in all copies and
14 * that both that copyright notice and this permission notice appear
15 * in supporting documentation.
17 * Permission to modify the software is granted, but not the right to
18 * distribute the complete modified source code. Modifications are to
19 * be distributed as patches to the released version. Permission to
20 * distribute binaries produced by compiling modified sources is granted,
22 * 1. distribute the corresponding source modifications from the
23 * released version in the form of a patch file along with the binaries,
24 * 2. add special version identification to distinguish your version
25 * in addition to the base release version number,
26 * 3. provide your name and address as the primary contact for the
27 * support of your modified version, and
28 * 4. retain our contact information in regard to use of the base
30 * Permission to distribute the released version of the source code along
31 * with corresponding source modifications in the form of a patch file is
32 * granted with same provisions 2 through 4 for binary distributions.
34 * This software is provided "as is" without express or implied warranty
35 * to the extent permitted by applicable law.
39 * This file is included by ../term.c.
41 * This terminal driver supports:
49 * send your comments or suggestions to (gnuplot-info@lists.sourceforge.net).
53 /* The following HP laserjet series II driver uses generic bit mapped graphics
54 routines from bitmap.c to build up a bit map in memory. The driver
55 interchanges colomns and lines in order to access entire lines
56 easily and returns the lines to get bits in the right order :
57 (x,y) -> (y,XMAX-1-x). */
58 /* This interchange is done by calling b_makebitmap() with reversed
59 xmax and ymax, and then setting b_rastermode to TRUE. b_setpixel()
60 will then perform the interchange before each pixel is plotted */
61 /* by John Engels JENGELS@BNANDP51.BITNET, inspired by the hpljet driver
62 of Jyrki Yli-Nokari */
65 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
76 TERM_PUBLIC void HPLJII_options __PROTO((void));
77 TERM_PUBLIC void HPLJII_init __PROTO((void));
78 TERM_PUBLIC void HPLJII_graphics __PROTO((void));
79 TERM_PUBLIC void HPLJII_text __PROTO((void));
80 TERM_PUBLIC void HPLJII_linetype __PROTO((int linetype));
81 TERM_PUBLIC void HPLJII_put_text __PROTO((unsigned int x, unsigned int y, const char *str));
82 TERM_PUBLIC void HPLJII_reset __PROTO((void));
84 TERM_PUBLIC void HPDJ_graphics __PROTO((void));
85 TERM_PUBLIC void HPDJ_text __PROTO((void));
87 /* default values for term_tbl */
88 #define HPLJII_75PPI_XMAX (1920/4)
89 #define HPLJII_75PPI_YMAX (1920/4)
90 #define HPLJII_75PPI_HCHAR (1920/4/6)
91 #define HPLJII_75PPI_VCHAR (1920/4/10)
92 #define HPLJII_75PPI_VTIC 5
93 #define HPLJII_75PPI_HTIC 5
96 #ifndef TERM_PROTO_ONLY
99 /* We define 4 different print qualities : 300ppi, 150ppi, 100ppi and
100 75ppi. (Pixel size = 1, 2, 3, 4 dots) */
102 #define HPLJII_DPP (hplj_dpp) /* dots per pixel */
103 #define HPLJII_PPI (300/HPLJII_DPP) /* pixel per inch */
104 /* make XMAX and YMAX a multiple of 8 */
105 #define HPLJII_XMAX (8*(unsigned int)(xsize*1920/HPLJII_DPP/8.0+0.9))
106 #define HPLJII_YMAX (8*(unsigned int)(ysize*1920/HPLJII_DPP/8.0+0.9))
108 /* Courier font with 6 lines per inch */
109 #define HPLJII_VCHAR (HPLJII_PPI/6)
110 /* Courier font with 10 caracters per inch */
111 #define HPLJII_HCHAR (HPLJII_PPI/10)
112 /* Save current cursor position */
113 #define HPLJII_PUSH_CURSOR fputs("\033&f0S",gpoutfile)
114 /* Restore cursor position */
115 #define HPLJII_POP_CURSOR fputs("\033&f1S",gpoutfile)
116 /* be sure to use courier font with 6lpi and 10cpi */
117 #define HPLJII_COURIER fputs("\033(0N\033(s0p10.0h12.0v0s0b3T\033&l6D",gpoutfile)
120 static void HPLJII_putc __PROTO((unsigned int x, unsigned int y, int c, int ang));
121 /* note: c is char, but must be declared int due to an old K&R ANSI-C strict HP cc */
122 static int hplj_dpp = 4;
123 /* bm_pattern not appropriate for 300ppi graphics */
124 #ifndef GOT_300_PATTERN
125 # define GOT_300_PATTERN
126 static unsigned int b_300ppi_pattern[] =
128 0xffff, 0x1111, 0xffff, 0x3333,
129 0x0f0f, 0x3f3f, 0x0fff, 0x00ff, 0x33ff
139 if (END_OF_COMMAND) {
140 term_options[0] = NUL;
142 if (token[c_token].length > 3) {
143 parse_error = 1; /* see below */
145 /* almost_equals() won't accept numbers - use strcmp() instead */
146 capture(opt, c_token, c_token, 4);
147 if (!strcmp(opt, "75")) {
149 } else if (!strcmp(opt, "100")) {
151 } else if (!strcmp(opt, "150")) {
153 } else if (!strcmp(opt, "300")) {
156 /* error, but set dpi anyway, since term it already set */
163 term->xmax = HPLJII_XMAX;
164 term->ymax = HPLJII_YMAX;
167 strcpy(term_options, "300");
172 strcpy(term_options, "150");
177 strcpy(term_options, "100");
182 strcpy(term_options, "75");
189 int_error(c_token, "expecting dots per inch size 75, 100, 150 or 300");
196 term->v_char = HPLJII_VCHAR;
197 term->h_char = HPLJII_HCHAR;
206 /* rotate plot -90 degrees by reversing XMAX and YMAX and by
207 setting b_rastermode to TRUE */
208 b_makebitmap(HPLJII_YMAX, HPLJII_XMAX, 1);
213 /* HPLJIItext by rjl - no compression */
217 register int x, j, row;
219 fprintf(gpoutfile, "\033*t%dR", HPLJII_PPI);
221 fputs("\033*r1A", gpoutfile);
223 /* dump bitmap in raster mode */
224 for (x = b_xsize - 1; x >= 0; x--) {
225 row = (b_ysize / 8) - 1;
226 fprintf(gpoutfile, "\033*b0m%dW", b_ysize / 8);
227 for (j = row; j >= 0; j--) {
228 (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile);
231 fputs("\033*rB", gpoutfile);
236 /* most vms spoolers add a formfeed character */
237 putc('\f', gpoutfile);
244 HPLJII_linetype(int linetype)
250 /* b_pattern not appropriate for 300ppi graphics */
251 b_linemask = b_300ppi_pattern[linetype + 2];
254 b_setlinetype(linetype);
259 HPLJII_put_text(unsigned int x, unsigned int y, const char *str)
263 y -= HPLJII_VCHAR / 5;
266 /* (0,0) is the upper left point of the paper */
267 fprintf(gpoutfile, "\033*p%+dx%+dY", x * HPLJII_DPP
268 ,(HPLJII_YMAX - y - 1) * HPLJII_DPP);
269 fputs(str, gpoutfile);
270 /* for (; *str; ++str, x += HPLJII_HCHAR)
271 HPLJII_putc (x, y, *str, b_angle);*/
274 y += (HPLJII_HCHAR - 2 * HPLJII_VCHAR) / 2;
275 y += (HPLJII_VCHAR + HPLJII_HCHAR) * strlen(str) / 2;
276 for (; *str; ++str, y -= HPLJII_VCHAR)
277 HPLJII_putc(x, y, *str, b_angle);
283 HPLJII_putc(unsigned int x, unsigned int y, int c, int ang)
287 (void) ang; /* avoid -Wunused warnings */
288 /* (0,0) is the upper left point of the paper */
289 fprintf(gpoutfile, "\033*p%+dx%+dY",
290 x * HPLJII_DPP, (HPLJII_YMAX - y - 1) * HPLJII_DPP);
304 /* HP DeskJet routines */
310 b_charsize(FNT13X25);
311 term->v_char = FNT13X25_VCHAR;
312 term->h_char = FNT13X25_HCHAR;
315 b_charsize(FNT13X25);
316 term->v_char = FNT13X25_VCHAR;
317 term->h_char = FNT13X25_HCHAR;
321 term->v_char = FNT9X17_VCHAR;
322 term->h_char = FNT9X17_HCHAR;
326 term->v_char = FNT5X9_VCHAR;
327 term->h_char = FNT5X9_HCHAR;
330 /* rotate plot -90 degrees by reversing XMAX and YMAX and by
331 setting b_rastermode to TRUE */
332 b_makebitmap(HPLJII_YMAX, HPLJII_XMAX, 1);
337 /* 0 compression raster bitmap dump. Compatible with HP DeskJet 500
338 hopefully compatible with other HP Deskjet printers */
342 register int x, j, row;
344 fprintf(gpoutfile, "\
350 /* dump bitmap in raster mode */
351 for (x = b_xsize - 1; x >= 0; x--) {
352 row = (b_ysize / 8) - 1;
353 fprintf(gpoutfile, "\033*b%dW", b_ysize / 8);
354 for (j = row; j >= 0; j--) {
355 (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile);
358 fputs("\033*rbC", gpoutfile);
362 #ifndef VMS /* most vms spoolers add a formfeed character */
363 putc('\f', gpoutfile);
371 TERM_TABLE_START(hpljii_driver)
372 "hpljii", "HP Laserjet series II, [75 100 150 300]",
373 HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
374 HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJII_options,
375 HPLJII_init, HPLJII_reset, HPLJII_text, null_scale,
376 HPLJII_graphics, b_move, b_vector, HPLJII_linetype,
377 HPLJII_put_text, b_text_angle, null_justify_text, line_and_point,
378 do_arrow, set_font_null, 0, TERM_BINARY,
380 TERM_TABLE_END(hpljii_driver)
383 #define LAST_TERM hpljii_driver
385 TERM_TABLE_START(hpdj_driver)
386 "hpdj", "HP DeskJet 500, [75 100 150 300]",
387 HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
388 HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJII_options,
389 HPLJII_init, HPLJII_reset, HPDJ_text, null_scale,
390 HPDJ_graphics, b_move, b_vector, HPLJII_linetype,
391 b_put_text, b_text_angle, null_justify_text, line_and_point,
392 do_arrow, set_font_null, 0, TERM_BINARY,
394 TERM_TABLE_END(hpdj_driver)
397 #define LAST_TERM hpdj_driver
405 "?commands set terminal hpljii",
406 "?set terminal hpljii",
411 "?commands set terminal hpdj",
412 "?set terminal hpdj",
417 " The `hpljii` terminal driver supports the HP Laserjet Series II printer. The",
418 " `hpdj` driver supports the HP DeskJet 500 printer. These drivers allow a",
419 " choice of resolutions.",
422 " set terminal hpljii | hpdj {<res>}",
424 " where `res` may be 75, 100, 150 or 300 dots per inch; the default is 75.",
425 " Rasterization at the higher resolutions may require a large amount of memory.",
427 " The `hp500c` terminal is similar to `hpdj`; `hp500c` additionally supports",
428 " color and compression."
430 #endif /* TERM_HELP */