1/* Hello, Emacs, this is -*-C-*- */ 2 3/* GNUPLOT - hppj.trm */ 4 5/*[ 6 * Copyright 1990 - 1993, 1998, 2004 7 * 8 * Permission to use, copy, and distribute this software and its 9 * documentation for any purpose with or without fee is hereby granted, 10 * provided that the above copyright notice appear in all copies and 11 * that both that copyright notice and this permission notice appear 12 * in supporting documentation. 13 * 14 * Permission to modify the software is granted, but not the right to 15 * distribute the complete modified source code. Modifications are to 16 * be distributed as patches to the released version. Permission to 17 * distribute binaries produced by compiling modified sources is granted, 18 * provided you 19 * 1. distribute the corresponding source modifications from the 20 * released version in the form of a patch file along with the binaries, 21 * 2. add special version identification to distinguish your version 22 * in addition to the base release version number, 23 * 3. provide your name and address as the primary contact for the 24 * support of your modified version, and 25 * 4. retain our contact information in regard to use of the base 26 * software. 27 * Permission to distribute the released version of the source code along 28 * with corresponding source modifications in the form of a patch file is 29 * granted with same provisions 2 through 4 for binary distributions. 30 * 31 * This software is provided "as is" without express or implied warranty 32 * to the extent permitted by applicable law. 33]*/ 34 35/* 36 * This file is included by ../term.c. 37 * 38 * This terminal driver supports: 39 * hppj 40 * 41 * AUTHORS 42 * Dan Merget (danm@sr.hp.com) 43 * 44 * This file was based on the hpljii file by: 45 * John Engels 46 * Russell Lang 47 * Maurice Castro 48 * 49 * send your comments or suggestions to (gnuplot-info@lists.sourceforge.net). 50 * 51 */ 52 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. 55 */ 56 57/* 58 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995) 59 */ 60 61#include "driver.h" 62 63#ifdef TERM_REGISTER 64register_term(hppj) 65#endif 66 67#ifdef TERM_PROTO 68TERM_PUBLIC void HPPJ_options(void); 69TERM_PUBLIC void HPPJ_init(void); 70TERM_PUBLIC void HPPJ_reset(void); 71TERM_PUBLIC void HPPJ_graphics(void); 72TERM_PUBLIC void HPPJ_text(void); 73TERM_PUBLIC void HPPJ_linetype(int linetype); 74 75/* We define 3 different font sizes: 5x9, 9x17, and 13x25 */ 76 77#define HPPJ_DPI 180 /* dots per inch */ 78#define HPPJ_PLANES 3 /* color planes */ 79#define HPPJ_COLORS (1 << HPPJ_PLANES) 80/* make XMAX and YMAX a multiple of 8 */ 81#define HPPJ_XMAX (8*(unsigned int)(9.5 * HPPJ_DPI / 8.0 + 0.9)) 82#define HPPJ_YMAX (8 * HPPJ_DPI) 83 84/* default values for term_tbl */ 85#define HPPJ_9x17_VCHAR FNT9X17_VCHAR 86#define HPPJ_9x17_HCHAR FNT9X17_HCHAR 87#define HPPJ_9x17_VTIC (FNT9X17_VCHAR / 2) 88#define HPPJ_9x17_HTIC (FNT9X17_HCHAR / 2) 89#endif /* TERM_PROTO */ 90 91#ifndef TERM_PROTO_ONLY 92#ifdef TERM_BODY 93static int hppj_font = FNT9X17; 94 95TERM_PUBLIC void 96HPPJ_options() 97{ 98 char opt[10]; 99#define HPPJERROR "expecting font size FNT5X9, FNT9X17, or FNT13X25" 100 101 term_options[0] = NUL; /* default to empty string and 9x17 font */ 102 hppj_font = FNT9X17; /* in case of error or empty options */ 103 104 if (!END_OF_COMMAND) { 105 if (token[c_token].length > 8) { 106 int_error(c_token, HPPJERROR); 107 } 108 capture(opt, c_token, c_token, /*4 */ 9); /* HBB 980226 */ 109 if (!strcmp(opt, "FNT5X9")) { 110 hppj_font = FNT5X9; 111 strcpy(term_options, "FNT5X9"); 112 } else if (!strcmp(opt, "FNT9X17")) { 113 hppj_font = FNT9X17; 114 strcpy(term_options, "FNT9X17"); 115 } else if (!strcmp(opt, "FNT13X25")) { 116 hppj_font = FNT13X25; 117 strcpy(term_options, "FNT13X25"); 118 } else { 119 int_error(c_token, HPPJERROR); 120 } 121 c_token++; 122 } 123} 124 125 126TERM_PUBLIC void 127HPPJ_init() 128{ 129 /* HBB 980226: moved this here, from graphics(): only init() may 130 * change fields of *term ! */ 131 switch (hppj_font) { 132 case FNT5X9: 133 term->v_char = FNT5X9_VCHAR; 134 term->h_char = FNT5X9_HCHAR; 135 term->v_tic = FNT5X9_VCHAR / 2; 136 term->h_tic = FNT5X9_HCHAR / 2; 137 break; 138 case FNT9X17: 139 term->v_char = FNT9X17_VCHAR; 140 term->h_char = FNT9X17_HCHAR; 141 term->v_tic = FNT9X17_VCHAR / 2; 142 term->h_tic = FNT9X17_HCHAR / 2; 143 break; 144 case FNT13X25: 145 term->v_char = FNT13X25_VCHAR; 146 term->h_char = FNT13X25_HCHAR; 147 term->v_tic = FNT13X25_VCHAR / 2; 148 term->h_tic = FNT13X25_HCHAR / 2; 149 break; 150 } 151} 152 153 154TERM_PUBLIC void 155HPPJ_reset() 156{ 157 fflush_binary(); /* Only needed for VMS */ 158} 159 160 161TERM_PUBLIC void 162HPPJ_graphics() 163{ 164 /* HBB 980226: move a block of code from here to init() */ 165 b_charsize(hppj_font); 166 167 b_makebitmap(HPPJ_XMAX, HPPJ_YMAX, HPPJ_PLANES); 168} 169 170 171TERM_PUBLIC void 172HPPJ_text() 173{ 174 int x, plane, y; /* loop indexes */ 175 int minRow, maxRow; /* loop bounds */ 176 int numBytes; /* Number of run-length coded bytes to output */ 177 int numReps; /* Number of times the current byte is repeated */ 178 179 fprintf(gpoutfile, "\ 180\033E\033*t%dR\033*r%dS\ 181\033*b0X\033*b0Y\033*r%dU\ 182\033*v%dA\033*v%dB\033*v%dC\033*v%dI\ 183\033*v%dA\033*v%dB\033*v%dC\033*v%dI\ 184\033*v%dA\033*v%dB\033*v%dC\033*v%dI\ 185\033*v%dA\033*v%dB\033*v%dC\033*v%dI\ 186\033*v%dA\033*v%dB\033*v%dC\033*v%dI\ 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*b1M\033*r1A", 191 HPPJ_DPI, HPPJ_YMAX, 192 HPPJ_PLANES, 193 90, 88, 85, 0, 194 53, 8, 14, 1, 195 3, 26, 22, 2, 196 4, 4, 29, 3, 197 53, 5, 25, 4, 198 2, 22, 64, 5, 199 89, 83, 13, 6, 200 4, 4, 6, 7); 201 202 /* dump bitmap in raster mode using run-length encoding */ 203 for (x = HPPJ_XMAX - 1; x >= 0; --x) { 204 for (plane = 0; plane < HPPJ_PLANES; plane++) { 205 minRow = b_psize * plane; 206 maxRow = b_psize * plane + b_psize - 1; 207 208 /* Print column header */ 209 numBytes = 0; 210 for (y = maxRow; y >= minRow; --y) { 211 if (y == minRow || *((*b_p)[y] + x) != *((*b_p)[y - 1] + x)) { 212 numBytes += 2; 213 } 214 } 215 fprintf(gpoutfile, "\033*b%d", numBytes); 216 (void) fputc((char) (plane < HPPJ_PLANES - 1 ? 'V' : 'W'), gpoutfile); 217 218 /* Print remainder of column */ 219 numReps = 0; 220 for (y = maxRow; y >= minRow; --y) { 221 if (y == minRow || *((*b_p)[y] + x) != *((*b_p)[y - 1] + x)) { 222 (void) fputc((char) (numReps), gpoutfile); 223 (void) fputc((char) (*((*b_p)[y] + x)), gpoutfile); 224 numReps = 0; 225 } else { 226 numReps++; 227 } 228 } 229 } 230 } 231 fputs("\033*r1B\033E", gpoutfile); 232 233 b_freebitmap(); 234} 235 236 237TERM_PUBLIC void 238HPPJ_linetype(int linetype) 239{ 240 if (linetype >= 0) { 241 b_setlinetype(0); 242 b_setvalue((linetype % (HPPJ_COLORS - 1)) + 1); 243 } else { 244 b_setlinetype(linetype + 2); 245 b_setvalue(HPPJ_COLORS - 1); 246 } 247} 248 249#endif /* TERM_BODY */ 250 251#ifdef TERM_TABLE 252 253TERM_TABLE_START(hppj_driver) 254 "hppj", "HP PaintJet and HP3630 [FNT5X9 FNT9X17 FNT13X25]", 255 HPPJ_XMAX, HPPJ_YMAX, 256 HPPJ_9x17_VCHAR, HPPJ_9x17_HCHAR, HPPJ_9x17_VTIC, HPPJ_9x17_HTIC, 257 HPPJ_options, HPPJ_init, HPPJ_reset, HPPJ_text, null_scale, HPPJ_graphics, 258 b_move, b_vector, HPPJ_linetype, b_put_text, b_text_angle, 259 null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY, 260 0, 0, b_boxfill 261TERM_TABLE_END(hppj_driver) 262 263#undef LAST_TERM 264#define LAST_TERM hppj_driver 265 266#endif /* TERM_TABLE */ 267#endif /* TERM_PROTO_ONLY */ 268 269#ifdef TERM_HELP 270START_HELP(hppj) 271"1 hppj", 272"?commands set terminal hppj", 273"?set terminal hppj", 274"?set term hppj", 275"?terminal hppj", 276"?term hppj", 277"?hppj", 278" Note: only available if gnuplot is configured --with-bitmap-terminals.", 279" The `hppj` terminal driver supports the HP PaintJet and HP3630 printers. The", 280" only option is the choice of font.", 281"", 282" Syntax:", 283" set terminal hppj {FNT5X9 | FNT9X17 | FNT13X25}", 284"", 285" with the middle-sized font (FNT9X17) being the default." 286END_HELP(hppj) 287#endif 288