| 1 |
/* |
| 2 |
* Copyright 1993,1994,1995,2005 by Ross Paterson |
| 3 |
* |
| 4 |
* Redistribution and use in source and binary forms, with or without |
| 5 |
* modification, are permitted provided that the following conditions are |
| 6 |
* met: |
| 7 |
* |
| 8 |
* 1. Redistributions of source code must retain the above copyright |
| 9 |
* notice, this list of conditions and the following disclaimer. |
| 10 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 11 |
* notice, this list of conditions and the following disclaimer in the |
| 12 |
* documentation and/or other materials provided with the distribution. |
| 13 |
* 3. The name of the author may not be used to endorse or promote |
| 14 |
* products derived from this software without specific prior written |
| 15 |
* permission. |
| 16 |
* |
| 17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 18 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 19 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 |
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
| 21 |
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 23 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 25 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 26 |
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 27 |
* POSSIBILITY OF SUCH DAMAGE. |
| 28 |
* |
| 29 |
* |
| 30 |
* Two interfaces to HBF files -- take your pick. |
| 31 |
* |
| 32 |
* Ross Paterson <[email protected]> |
| 33 |
* |
| 34 |
* Ross no longer maintains this code. Please send bug reports to |
| 35 |
* Werner Lemberg <[email protected]>. |
| 36 |
* |
| 37 |
*/ |
| 38 |
#ifndef _HBF_ |
| 39 |
#define _HBF_ |
| 40 |
|
| 41 |
#ifndef __STDC__ |
| 42 |
# ifndef const |
| 43 |
# define const |
| 44 |
# endif |
| 45 |
#endif |
| 46 |
|
| 47 |
/* |
| 48 |
* #1: a lightweight C interface. |
| 49 |
*/ |
| 50 |
|
| 51 |
typedef unsigned int HBF_CHAR; |
| 52 |
|
| 53 |
typedef struct { |
| 54 |
unsigned short hbf_width; |
| 55 |
unsigned short hbf_height; |
| 56 |
short hbf_xDisplacement; |
| 57 |
short hbf_yDisplacement; |
| 58 |
} HBF_BBOX; |
| 59 |
|
| 60 |
typedef struct { |
| 61 |
/* fields corresponding to the definition */ |
| 62 |
HBF_BBOX hbf_bitmap_bbox; /* HBF_BITMAP_BOUNDING_BOX */ |
| 63 |
HBF_BBOX hbf_font_bbox; /* FONTBOUNDINGBOX */ |
| 64 |
} HBF; |
| 65 |
|
| 66 |
extern HBF *hbfOpen( |
| 67 |
#ifdef __STDC__ |
| 68 |
const char *filename |
| 69 |
#endif |
| 70 |
); |
| 71 |
|
| 72 |
extern void hbfClose( |
| 73 |
#ifdef __STDC__ |
| 74 |
HBF *hbf |
| 75 |
#endif |
| 76 |
); |
| 77 |
|
| 78 |
extern const char *hbfProperty( |
| 79 |
#ifdef __STDC__ |
| 80 |
HBF *hbf, |
| 81 |
const char *propName |
| 82 |
#endif |
| 83 |
); |
| 84 |
|
| 85 |
extern const unsigned char *hbfGetBitmap( |
| 86 |
#ifdef __STDC__ |
| 87 |
HBF *hbf, |
| 88 |
HBF_CHAR code |
| 89 |
#endif |
| 90 |
); |
| 91 |
|
| 92 |
extern void hbfForEach( |
| 93 |
#ifdef __STDC__ |
| 94 |
HBF *hbf, |
| 95 |
void (*func)(HBF *sameHbf, HBF_CHAR code) |
| 96 |
#endif |
| 97 |
); |
| 98 |
|
| 99 |
extern const char *hbfFileName( |
| 100 |
#ifdef __STDC__ |
| 101 |
HBF *hbf |
| 102 |
#endif |
| 103 |
); |
| 104 |
|
| 105 |
extern long hbfChars( |
| 106 |
#ifdef __STDC__ |
| 107 |
HBF *hbf |
| 108 |
#endif |
| 109 |
); |
| 110 |
|
| 111 |
extern HBF_BBOX *hbfBitmapBBox( |
| 112 |
#ifdef __STDC__ |
| 113 |
HBF *hbf |
| 114 |
#endif |
| 115 |
); |
| 116 |
/* but defined here as a macro */ |
| 117 |
#define hbfBitmapBBox(hbf) (&((hbf)->hbf_bitmap_bbox)) |
| 118 |
|
| 119 |
extern HBF_BBOX *hbfFontBBox( |
| 120 |
#ifdef __STDC__ |
| 121 |
HBF *hbf |
| 122 |
#endif |
| 123 |
); |
| 124 |
/* but defined here as a macro */ |
| 125 |
#define hbfFontBBox(hbf) (&((hbf)->hbf_font_bbox)) |
| 126 |
|
| 127 |
#define HBF_RowSize(hbf)\ |
| 128 |
((hbfBitmapBBox(hbf)->hbf_width + 7)/8) |
| 129 |
|
| 130 |
#define HBF_BitmapSize(hbf)\ |
| 131 |
(HBF_RowSize(hbf) * hbfBitmapBBox(hbf)->hbf_height) |
| 132 |
|
| 133 |
#define HBF_GetBit(hbf,bitmap,x,y)\ |
| 134 |
(((bitmap)[(y)*HBF_RowSize(hbf) + (x)/8]>>(7 - (x)%8))&01) |
| 135 |
|
| 136 |
extern int hbfDebug; /* set non-zero for error reporting */ |
| 137 |
|
| 138 |
extern const void *hbfGetCodeRange( |
| 139 |
#ifdef __STDC__ |
| 140 |
HBF *hbfFile, |
| 141 |
const void *code_pointer, |
| 142 |
HBF_CHAR *startp, |
| 143 |
HBF_CHAR *finishp |
| 144 |
#endif |
| 145 |
); |
| 146 |
|
| 147 |
extern const void *hbfGetByte2Range( |
| 148 |
#ifdef __STDC__ |
| 149 |
HBF *hbfFile, |
| 150 |
const void *b2r_pointer, |
| 151 |
unsigned char *startp, |
| 152 |
unsigned char *finishp |
| 153 |
#endif |
| 154 |
); |
| 155 |
|
| 156 |
/* |
| 157 |
* #2: taken from Appendix 2 of the HBF draft. |
| 158 |
*/ |
| 159 |
|
| 160 |
typedef unsigned int HBF_HzCode; |
| 161 |
typedef unsigned char HBF_Byte ; |
| 162 |
typedef HBF_Byte * HBF_BytePtr ; |
| 163 |
typedef HBF * HBF_Handle ; |
| 164 |
typedef HBF_Handle * HBF_HandlePtr ; |
| 165 |
typedef char * String ; |
| 166 |
|
| 167 |
extern int HBF_OpenFont( |
| 168 |
#ifdef __STDC__ |
| 169 |
const char * filename, |
| 170 |
HBF_HandlePtr ptrHandleStorage |
| 171 |
#endif |
| 172 |
); |
| 173 |
|
| 174 |
extern int HBF_CloseFont( |
| 175 |
#ifdef __STDC__ |
| 176 |
HBF_Handle handle |
| 177 |
#endif |
| 178 |
); |
| 179 |
|
| 180 |
extern const char * HBF_GetProperty( |
| 181 |
#ifdef __STDC__ |
| 182 |
HBF_Handle handle, |
| 183 |
const char * propertyName |
| 184 |
#endif |
| 185 |
); |
| 186 |
|
| 187 |
extern int HBF_GetFontBoundingBox( |
| 188 |
#ifdef __STDC__ |
| 189 |
HBF_Handle handle, |
| 190 |
unsigned int *width, |
| 191 |
unsigned int *height, |
| 192 |
int *xDisplacement, |
| 193 |
int *yDisplacement |
| 194 |
#endif |
| 195 |
); |
| 196 |
|
| 197 |
extern int HBF_GetBitmapBoundingBox( |
| 198 |
#ifdef __STDC__ |
| 199 |
HBF_Handle handle, |
| 200 |
unsigned int *width, |
| 201 |
unsigned int *height, |
| 202 |
int *xDisplacement, |
| 203 |
int *yDisplacement |
| 204 |
#endif |
| 205 |
); |
| 206 |
|
| 207 |
extern int HBF_GetBitmap( |
| 208 |
#ifdef __STDC__ |
| 209 |
HBF_Handle handle, |
| 210 |
HBF_HzCode hanziCode, |
| 211 |
HBF_BytePtr ptrBitmapBuffer |
| 212 |
#endif |
| 213 |
); |
| 214 |
|
| 215 |
#endif /* ! _HBF_ */ |