1 /* 2 Copyright (c) 1991 - 1994 Heinz W. Werntges. All rights reserved. 3 Distributed by Free Software Foundation, Inc. 4 5 This file is part of HP2xx. 6 7 HP2xx is distributed in the hope that it will be useful, but 8 WITHOUT ANY WARRANTY. No author or distributor accepts responsibility 9 to anyone for the consequences of using it or for whether it serves any 10 particular purpose or works at all, unless he says so in writing. Refer 11 to the GNU General Public License, Version 2 or later, for full details. 12 13 Everyone is granted permission to copy, modify and redistribute 14 HP2xx, but only under the conditions described in the GNU General Public 15 License. A copy of this license is supposed to have been 16 given to you along with HP2xx so you can know your rights and 17 responsibilities. It should be in a file named COPYING. Among other 18 things, the copyright notice and this notice must be preserved on all 19 copies. 20 21 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 22 */ 23 24 /** chardraw.h 25 ** 26 ** 92/02/19 V 1.01 HWW Derived from sprite.h (V 2.01) 27 ** 92/05/28 V 1.02 HWW plot_symbol_char() added 28 ** 99/02/01 V 1.03 MK charsets 5 and 7 added 29 ** 30 ** Structure definition as used by pplib for character drawing 31 **/ 32 33 34 #define JOFF 4 35 36 #define _BS '\010' /* Backspace */ 37 #define _HT '\011' /* Horizontal Tab */ 38 #define _LF '\012' /* Line Feed */ 39 #define _VT '\013' /* Vertical Tab */ 40 #define _CR '\015' /* Carriage Return */ 41 #define _SO '\016' /* Shift Out */ 42 #define _SI '\017' /* Shift In */ 43 44 /** 45 ** Description of struct TextPar (used for internal font drawing): 46 ** 47 ** A character size is defined by its WIDTH and HEIGHT. 48 ** The distance from char. to char. is given by SPACE, from 49 ** text line to text line by LINE. 50 ** WIDTH, SPACE are fractions of the P1,P2 window width, 51 ** SPACE, LINE are fractions of the P1,P2 window height. 52 ** The writing direction is DIR, which is the angle [0,2*M_PI] 53 ** between text line & x direction. 54 ** Set SLANT to an angle != 0 if characters are to appear e.g. italics-like. 55 ** Stroked fonts selectable by setting FONT to > 0 56 ** (not yet supported). 57 ** 58 ** NOTE: struct TextPar was inherited from former project "plib" (a plot 59 ** library which also featured character drawing). It was not 60 ** designed from scratch for the purpose of HP-GL font management. 61 ** However, for charset 0 it does a fair job here, mainly because 62 ** plib itself had been inspired by HP-GL. 63 **/ 64 65 typedef struct { 66 float width; /* Width of a char (x dirc.) */ 67 float height; /* Height of a char (y dirc.) */ 68 float space; /* Distance between characters */ 69 float line; /* Distance betw. char. lines */ 70 float espace; /* Extra char space rel. to 'space' */ 71 float eline; /* Extra line space rel. to 'line' */ 72 float dir; /* Direction to x axis (rad) */ 73 float slant; /* Character slant (tan angle) */ 74 int font; /* Active Font number */ 75 int stdfont; /* Designated tandard font number */ 76 int altfont; /* Designated alternate font number */ 77 int orig; /* Label origin code */ 78 79 80 /** 81 ** Internally needed for character resizing and positioning 82 ** 83 ** T = matrix, mapping (relative) sprite coordinates into norm coord., 84 ** chardiff & linediff are used to advance the graphical text cursor, 85 ** pref is a pointer to the current text reference point (origin): 86 **/ 87 88 double Txx, Txy, Tyx, Tyy; /* Transformation matrix */ 89 HPGL_Pt chardiff, /* Horiz. distance between characters */ 90 linediff, /* Vertical distance between characters */ 91 refpoint, /* Current reference point */ 92 CR_point, /* Returns point after a <CR> */ 93 offset; /* Needed for HP-GL command ``LO;'' */ 94 double strokewidth; /* current stroke weight (or 9999. for current PW */ 95 double sstrokewidth; /* stdfont stroke weight (or 9999. for current PW */ 96 double astrokewidth; /* altfont stroke weight (or 9999. for current PW */ 97 } TEXTPAR, *TextPar; 98 99 100 101 102 typedef enum { LB_direct, LB_buffered, LB_buffered_in_use } LB_Mode; /* LB and PB work differently ! */ 103 104 105 /** 106 ** Remnant of former BGI font support by project plib, 107 ** currently inactive. Leave it here in case of a future revival 108 **/ 109 110 #ifdef STROKED_FONTS 111 typedef struct { 112 unsigned int buff[16000]; /* Buffer for font data */ 113 unsigned int vector_off; /* Offset of start of plot data */ 114 unsigned int size_off; /* Offset of size tab */ 115 unsigned int first; /* ASCII code of first character */ 116 unsigned int num; /* Number of defined character */ 117 unsigned int height; 118 unsigned int depth; 119 char *name; 120 } FONT, *Font; 121 #endif 122 123 124 /** 125 ** Prototypes: 126 **/ 127 128 #ifdef __cplusplus 129 extern "C" { 130 #endif 131 132 /* void code_to_ucoord (char, HPGL_Pt *); */ 133 134 int init_font(int); 135 void init_text_par(void); 136 void adjust_text_par(void); 137 /* void ASCII_to_char (int);*/ 138 void plot_string(char *, LB_Mode, short); 139 void plot_symbol_char(char); 140 141 #ifdef __cplusplus 142 } 143 #endif 144