]> git.karo-electronics.de Git - gbdfed.git/blob - hbf.h
Fixup several compile faults due to changes in recent distributions,
[gbdfed.git] / hbf.h
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 <ross@soi.city.ac.uk>
33  *
34  * Ross no longer maintains this code.  Please send bug reports to
35  * Werner Lemberg <wl@gnu.org>.
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, void *),
96                         void    *data
97 #endif
98                 );
99
100 extern  const   char    *hbfFileName(
101 #ifdef __STDC__
102                         HBF     *hbf
103 #endif
104                 );
105
106 extern  long    hbfChars(
107 #ifdef __STDC__
108                         HBF     *hbf
109 #endif
110                 );
111
112 extern  HBF_BBOX *hbfBitmapBBox(
113 #ifdef __STDC__
114                         HBF     *hbf
115 #endif
116                 );
117 /* but defined here as a macro */
118 #define hbfBitmapBBox(hbf)      (&((hbf)->hbf_bitmap_bbox))
119
120 extern  HBF_BBOX *hbfFontBBox(
121 #ifdef __STDC__
122                         HBF     *hbf
123 #endif
124                 );
125 /* but defined here as a macro */
126 #define hbfFontBBox(hbf)        (&((hbf)->hbf_font_bbox))
127
128 #define HBF_RowSize(hbf)\
129         ((hbfBitmapBBox(hbf)->hbf_width + 7)/8)
130
131 #define HBF_BitmapSize(hbf)\
132         (HBF_RowSize(hbf) * hbfBitmapBBox(hbf)->hbf_height)
133
134 #define HBF_GetBit(hbf,bitmap,x,y)\
135         (((bitmap)[(y)*HBF_RowSize(hbf) + (x)/8]>>(7 - (x)%8))&01)
136
137 extern  int     hbfDebug;       /* set non-zero for error reporting */
138
139 extern const void *hbfGetCodeRange(
140 #ifdef __STDC__
141                         HBF                     *hbfFile,
142                         const void              *code_pointer,
143                         HBF_CHAR                *startp,
144                         HBF_CHAR                *finishp
145 #endif
146                 );
147
148 extern const void *hbfGetByte2Range(
149 #ifdef __STDC__
150                         HBF                     *hbfFile,
151                         const void              *b2r_pointer,
152                         unsigned char           *startp,
153                         unsigned char           *finishp
154 #endif
155                 );
156
157 /*
158  *      #2: taken from Appendix 2 of the HBF draft.
159  */
160
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 ;
167
168 extern  int     HBF_OpenFont(
169 #ifdef __STDC__
170                 const   char *        filename,
171                 HBF_HandlePtr ptrHandleStorage
172 #endif
173 );
174
175 extern  int     HBF_CloseFont(
176 #ifdef __STDC__
177                 HBF_Handle handle
178 #endif
179 );
180
181 extern  const char * HBF_GetProperty(
182 #ifdef __STDC__
183                 HBF_Handle      handle,
184                 const   char *  propertyName
185 #endif
186 );
187
188 extern  int     HBF_GetFontBoundingBox(
189 #ifdef __STDC__
190                 HBF_Handle   handle,
191                 unsigned int *width,
192                 unsigned int *height,
193                 int *xDisplacement,
194                 int *yDisplacement
195 #endif
196 );
197
198 extern  int     HBF_GetBitmapBoundingBox(
199 #ifdef __STDC__
200                 HBF_Handle   handle,
201                 unsigned int *width,
202                 unsigned int *height,
203                 int *xDisplacement,
204                 int *yDisplacement
205 #endif
206 );
207
208 extern  int     HBF_GetBitmap(
209 #ifdef __STDC__
210                 HBF_Handle  handle,
211                 HBF_HzCode  hanziCode,
212                 HBF_BytePtr ptrBitmapBuffer
213 #endif
214 );
215
216 #endif /* ! _HBF_ */