2 * Copyright 2000 Computing Research Labs, New Mexico State University
3 * Copyright 2001, 2002, 2003, 2004 Francesco Zappa Nardelli
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
20 * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 * Based on bdf.h,v 1.16 2000/03/16 20:08:51 mleisher
34 #include FT_INTERNAL_OBJECTS_H
35 #include FT_INTERNAL_STREAM_H
41 /* Imported from bdfP.h */
43 #define _bdf_glyph_modified( map, e ) \
44 ( (map)[(e) >> 5] & ( 1 << ( (e) & 31 ) ) )
45 #define _bdf_set_glyph_modified( map, e ) \
46 ( (map)[(e) >> 5] |= ( 1 << ( (e) & 31 ) ) )
47 #define _bdf_clear_glyph_modified( map, e ) \
48 ( (map)[(e) >> 5] &= ~( 1 << ( (e) & 31 ) ) )
53 /*************************************************************************/
55 /* BDF font options macros and types. */
57 /*************************************************************************/
60 #define BDF_CORRECT_METRICS 0x01 /* Correct invalid metrics when loading. */
61 #define BDF_KEEP_COMMENTS 0x02 /* Preserve the font comments. */
62 #define BDF_KEEP_UNENCODED 0x04 /* Keep the unencoded glyphs. */
63 #define BDF_PROPORTIONAL 0x08 /* Font has proportional spacing. */
64 #define BDF_MONOWIDTH 0x10 /* Font has mono width. */
65 #define BDF_CHARCELL 0x20 /* Font has charcell spacing. */
67 #define BDF_ALL_SPACING ( BDF_PROPORTIONAL | \
71 #define BDF_DEFAULT_LOAD_OPTIONS ( BDF_CORRECT_METRICS | \
73 BDF_KEEP_UNENCODED | \
77 typedef struct bdf_options_t_
87 /* Callback function type for unknown configuration options. */
89 (*bdf_options_callback_t
)( bdf_options_t
* opts
,
91 unsigned long nparams
,
95 /*************************************************************************/
97 /* BDF font property macros and types. */
99 /*************************************************************************/
103 #define BDF_INTEGER 2
104 #define BDF_CARDINAL 3
107 /* This structure represents a particular property of a font. */
108 /* There are a set of defaults and each font has their own. */
109 typedef struct bdf_property_t_
111 char* name
; /* Name of the property. */
112 int format
; /* Format of the property. */
113 int builtin
; /* A builtin property. */
120 } value
; /* Value of the property. */
125 /*************************************************************************/
127 /* BDF font metric and glyph types. */
129 /*************************************************************************/
132 typedef struct bdf_bbx_t_
134 unsigned short width
;
135 unsigned short height
;
146 typedef struct bdf_glyph_t_
148 char* name
; /* Glyph name. */
149 long encoding
; /* Glyph encoding. */
150 unsigned short swidth
; /* Scalable width. */
151 unsigned short dwidth
; /* Device width. */
152 bdf_bbx_t bbx
; /* Glyph bounding box. */
153 unsigned char* bitmap
; /* Glyph bitmap. */
154 unsigned long bpr
; /* Number of bytes used per row. */
155 unsigned short bytes
; /* Number of bytes used for the bitmap. */
160 typedef struct _hashnode_
165 } _hashnode
, *hashnode
;
168 typedef struct hashtable_
178 typedef struct bdf_glyphlist_t_
180 unsigned short pad
; /* Pad to 4-byte boundary. */
181 unsigned short bpp
; /* Bits per pixel. */
182 long start
; /* Beginning encoding value of glyphs. */
183 long end
; /* Ending encoding value of glyphs. */
184 bdf_glyph_t
* glyphs
; /* Glyphs themselves. */
185 unsigned long glyphs_size
; /* Glyph structures allocated. */
186 unsigned long glyphs_used
; /* Glyph structures used. */
187 bdf_bbx_t bbx
; /* Overall bounding box of glyphs. */
192 typedef struct bdf_font_t_
194 char* name
; /* Name of the font. */
195 bdf_bbx_t bbx
; /* Font bounding box. */
197 long point_size
; /* Point size of the font. */
198 unsigned long resolution_x
; /* Font horizontal resolution. */
199 unsigned long resolution_y
; /* Font vertical resolution. */
201 int spacing
; /* Font spacing value. */
203 unsigned short monowidth
; /* Logical width for monowidth font. */
205 long default_char
; /* Encoding of the default glyph. */
207 long font_ascent
; /* Font ascent. */
208 long font_descent
; /* Font descent. */
210 unsigned long glyphs_size
; /* Glyph structures allocated. */
211 unsigned long glyphs_used
; /* Glyph structures used. */
212 bdf_glyph_t
* glyphs
; /* Glyphs themselves. */
214 unsigned long unencoded_size
; /* Unencoded glyph struct. allocated. */
215 unsigned long unencoded_used
; /* Unencoded glyph struct. used. */
216 bdf_glyph_t
* unencoded
; /* Unencoded glyphs themselves. */
218 unsigned long props_size
; /* Font properties allocated. */
219 unsigned long props_used
; /* Font properties used. */
220 bdf_property_t
* props
; /* Font properties themselves. */
222 char* comments
; /* Font comments. */
223 unsigned long comments_len
; /* Length of comment string. */
225 bdf_glyphlist_t overflow
; /* Storage used for glyph insertion. */
227 void* internal
; /* Internal data for the font. */
229 unsigned long nmod
[2048]; /* Bitmap indicating modified glyphs. */
230 unsigned long umod
[2048]; /* Bitmap indicating modified */
231 /* unencoded glyphs. */
232 unsigned short modified
; /* Boolean indicating font modified. */
233 unsigned short bpp
; /* Bits per pixel. */
237 bdf_property_t
* user_props
;
238 unsigned long nuser_props
;
244 /*************************************************************************/
246 /* Types for load/save callbacks. */
248 /*************************************************************************/
252 #define BDF_MISSING_START -1
253 #define BDF_MISSING_FONTNAME -2
254 #define BDF_MISSING_SIZE -3
255 #define BDF_MISSING_CHARS -4
256 #define BDF_MISSING_STARTCHAR -5
257 #define BDF_MISSING_ENCODING -6
258 #define BDF_MISSING_BBX -7
260 #define BDF_OUT_OF_MEMORY -20
262 #define BDF_INVALID_LINE -100
265 /*************************************************************************/
269 /*************************************************************************/
272 bdf_load_font( FT_Stream stream
,
278 bdf_free_font( bdf_font_t
* font
);
280 FT_LOCAL( bdf_property_t
* )
281 bdf_get_property( char* name
,
284 FT_LOCAL( bdf_property_t
* )
285 bdf_get_font_property( bdf_font_t
* font
,
292 #endif /* __BDF_H__ */