1 /* Hello, Emacs, this is -*-C-*-
2 * $Id: hppj.trm,v 1.15 2006/07/21 02:35:47 sfeam Exp $
6 /* GNUPLOT - hppj.trm */
9 * Copyright 1990 - 1993, 1998, 2004
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:
45 * Dan Merget (danm@sr.hp.com)
47 * This file was based on the hpljii file by:
52 * send your comments or suggestions to (gnuplot-info@lists.sourceforge.net).
56 /* The following HP laserjet series II driver uses generic bit mapped graphics
57 * routines from bitmap.c to build up a bit map in memory.
61 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
71 TERM_PUBLIC void HPPJ_options __PROTO((void));
72 TERM_PUBLIC void HPPJ_init __PROTO((void));
73 TERM_PUBLIC void HPPJ_reset __PROTO((void));
74 TERM_PUBLIC void HPPJ_graphics __PROTO((void));
75 TERM_PUBLIC void HPPJ_text __PROTO((void));
76 TERM_PUBLIC void HPPJ_linetype __PROTO((int linetype));
78 /* We define 3 different font sizes: 5x9, 9x17, and 13x25 */
80 #define HPPJ_DPI 180 /* dots per inch */
81 #define HPPJ_PLANES 3 /* color planes */
82 #define HPPJ_COLORS (1 << HPPJ_PLANES)
83 /* make XMAX and YMAX a multiple of 8 */
84 #define HPPJ_XMAX (8*(unsigned int)(9.5 * HPPJ_DPI / 8.0 + 0.9))
85 #define HPPJ_YMAX (8 * HPPJ_DPI)
87 /* default values for term_tbl */
88 #define HPPJ_9x17_VCHAR FNT9X17_VCHAR
89 #define HPPJ_9x17_HCHAR FNT9X17_HCHAR
90 #define HPPJ_9x17_VTIC (FNT9X17_VCHAR / 2)
91 #define HPPJ_9x17_HTIC (FNT9X17_HCHAR / 2)
92 #endif /* TERM_PROTO */
94 #ifndef TERM_PROTO_ONLY
96 static int hppj_font = FNT9X17;
102 #define HPPJERROR "expecting font size FNT5X9, FNT9X17, or FNT13X25"
104 term_options[0] = NUL; /* default to empty string and 9x17 font */
105 hppj_font = FNT9X17; /* in case of error or empty options */
107 if (!END_OF_COMMAND) {
108 if (token[c_token].length > 8) {
109 int_error(c_token, HPPJERROR);
111 capture(opt, c_token, c_token, /*4 */ 9); /* HBB 980226 */
112 if (!strcmp(opt, "FNT5X9")) {
114 strcpy(term_options, "FNT5X9");
115 } else if (!strcmp(opt, "FNT9X17")) {
117 strcpy(term_options, "FNT9X17");
118 } else if (!strcmp(opt, "FNT13X25")) {
119 hppj_font = FNT13X25;
120 strcpy(term_options, "FNT13X25");
122 int_error(c_token, HPPJERROR);
132 /* HBB 980226: moved this here, from graphics(): only init() may
133 * change fields of *term ! */
136 term->v_char = FNT5X9_VCHAR;
137 term->h_char = FNT5X9_HCHAR;
138 term->v_tic = FNT5X9_VCHAR / 2;
139 term->h_tic = FNT5X9_HCHAR / 2;
142 term->v_char = FNT9X17_VCHAR;
143 term->h_char = FNT9X17_HCHAR;
144 term->v_tic = FNT9X17_VCHAR / 2;
145 term->h_tic = FNT9X17_HCHAR / 2;
148 term->v_char = FNT13X25_VCHAR;
149 term->h_char = FNT13X25_HCHAR;
150 term->v_tic = FNT13X25_VCHAR / 2;
151 term->h_tic = FNT13X25_HCHAR / 2;
169 /* HBB 980226: move a block of code from here to init() */
170 b_charsize(hppj_font);
172 b_makebitmap(HPPJ_XMAX, HPPJ_YMAX, HPPJ_PLANES);
179 int x, plane, y; /* loop indexes */
180 int minRow, maxRow; /* loop bounds */
181 int numBytes; /* Number of run-length coded bytes to output */
182 int numReps; /* Number of times the current byte is repeated */
184 fprintf(gpoutfile, "\
185 \033E\033*t%dR\033*r%dS\
186 \033*b0X\033*b0Y\033*r%dU\
187 \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
188 \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
189 \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
190 \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
191 \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
192 \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
193 \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
194 \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
207 /* dump bitmap in raster mode using run-length encoding */
208 for (x = HPPJ_XMAX - 1; x >= 0; --x) {
209 for (plane = 0; plane < HPPJ_PLANES; plane++) {
210 minRow = b_psize * plane;
211 maxRow = b_psize * plane + b_psize - 1;
213 /* Print column header */
215 for (y = maxRow; y >= minRow; --y) {
216 if (y == minRow || *((*b_p)[y] + x) != *((*b_p)[y - 1] + x)) {
220 fprintf(gpoutfile, "\033*b%d", numBytes);
221 (void) fputc((char) (plane < HPPJ_PLANES - 1 ? 'V' : 'W'), gpoutfile);
223 /* Print remainder of column */
225 for (y = maxRow; y >= minRow; --y) {
226 if (y == minRow || *((*b_p)[y] + x) != *((*b_p)[y - 1] + x)) {
227 (void) fputc((char) (numReps), gpoutfile);
228 (void) fputc((char) (*((*b_p)[y] + x)), gpoutfile);
236 fputs("\033*r1B\033E", gpoutfile);
243 HPPJ_linetype(int linetype)
247 b_setvalue((linetype % (HPPJ_COLORS - 1)) + 1);
249 b_setlinetype(linetype + 2);
250 b_setvalue(HPPJ_COLORS - 1);
254 #endif /* TERM_BODY */
258 TERM_TABLE_START(hppj_driver)
259 "hppj", "HP PaintJet and HP3630 [FNT5X9 FNT9X17 FNT13X25]",
260 HPPJ_XMAX, HPPJ_YMAX,
261 HPPJ_9x17_VCHAR, HPPJ_9x17_HCHAR, HPPJ_9x17_VTIC, HPPJ_9x17_HTIC,
262 HPPJ_options, HPPJ_init, HPPJ_reset, HPPJ_text, null_scale, HPPJ_graphics,
263 b_move, b_vector, HPPJ_linetype, b_put_text, b_text_angle,
264 null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY,
266 TERM_TABLE_END(hppj_driver)
269 #define LAST_TERM hppj_driver
271 #endif /* TERM_TABLE */
272 #endif /* TERM_PROTO_ONLY */
277 "?commands set terminal hppj",
278 "?set terminal hppj",
283 " The `hppj` terminal driver supports the HP PaintJet and HP3630 printers. The",
284 " only option is the choice of font.",
287 " set terminal hppj {FNT5X9 | FNT9X17 | FNT13X25}",
289 " with the middle-sized font (FNT9X17) being the default."