2 * Copyright 1993,1994,1995,2005 by Ross Paterson
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
30 * Two interfaces to HBF files -- take your pick.
32 * Ross Paterson <ross@soi.city.ac.uk>
34 * Ross no longer maintains this code. Please send bug reports to
35 * Werner Lemberg <wl@gnu.org>.
48 * #1: a lightweight C interface.
51 typedef unsigned int HBF_CHAR;
54 unsigned short hbf_width;
55 unsigned short hbf_height;
56 short hbf_xDisplacement;
57 short hbf_yDisplacement;
61 /* fields corresponding to the definition */
62 HBF_BBOX hbf_bitmap_bbox; /* HBF_BITMAP_BOUNDING_BOX */
63 HBF_BBOX hbf_font_bbox; /* FONTBOUNDINGBOX */
78 extern const char *hbfProperty(
85 extern const unsigned char *hbfGetBitmap(
92 extern void hbfForEach(
95 void (*func)(HBF *sameHbf, HBF_CHAR code, void *),
100 extern const char *hbfFileName(
106 extern long hbfChars(
112 extern HBF_BBOX *hbfBitmapBBox(
117 /* but defined here as a macro */
118 #define hbfBitmapBBox(hbf) (&((hbf)->hbf_bitmap_bbox))
120 extern HBF_BBOX *hbfFontBBox(
125 /* but defined here as a macro */
126 #define hbfFontBBox(hbf) (&((hbf)->hbf_font_bbox))
128 #define HBF_RowSize(hbf)\
129 ((hbfBitmapBBox(hbf)->hbf_width + 7)/8)
131 #define HBF_BitmapSize(hbf)\
132 (HBF_RowSize(hbf) * hbfBitmapBBox(hbf)->hbf_height)
134 #define HBF_GetBit(hbf,bitmap,x,y)\
135 (((bitmap)[(y)*HBF_RowSize(hbf) + (x)/8]>>(7 - (x)%8))&01)
137 extern int hbfDebug; /* set non-zero for error reporting */
139 extern const void *hbfGetCodeRange(
142 const void *code_pointer,
148 extern const void *hbfGetByte2Range(
151 const void *b2r_pointer,
152 unsigned char *startp,
153 unsigned char *finishp
158 * #2: taken from Appendix 2 of the HBF draft.
161 typedef unsigned int HBF_HzCode;
162 typedef unsigned char HBF_Byte ;
163 typedef HBF_Byte * HBF_BytePtr ;
164 typedef HBF * HBF_Handle ;
165 typedef HBF_Handle * HBF_HandlePtr ;
166 typedef char * String ;
168 extern int HBF_OpenFont(
170 const char * filename,
171 HBF_HandlePtr ptrHandleStorage
175 extern int HBF_CloseFont(
181 extern const char * HBF_GetProperty(
184 const char * propertyName
188 extern int HBF_GetFontBoundingBox(
192 unsigned int *height,
198 extern int HBF_GetBitmapBoundingBox(
202 unsigned int *height,
208 extern int HBF_GetBitmap(
211 HBF_HzCode hanziCode,
212 HBF_BytePtr ptrBitmapBuffer