00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __BDF_H__
00026 #define __BDF_H__
00027
00028
00029
00030
00031
00032
00033 #include <ft2build.h>
00034 #include FT_INTERNAL_OBJECTS_H
00035 #include FT_INTERNAL_STREAM_H
00036
00037
00038 FT_BEGIN_HEADER
00039
00040
00041
00042
00043 #define _bdf_glyph_modified( map, e ) \
00044 ( (map)[(e) >> 5] & ( 1 << ( (e) & 31 ) ) )
00045 #define _bdf_set_glyph_modified( map, e ) \
00046 ( (map)[(e) >> 5] |= ( 1 << ( (e) & 31 ) ) )
00047 #define _bdf_clear_glyph_modified( map, e ) \
00048 ( (map)[(e) >> 5] &= ~( 1 << ( (e) & 31 ) ) )
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #define BDF_CORRECT_METRICS 0x01
00061 #define BDF_KEEP_COMMENTS 0x02
00062 #define BDF_KEEP_UNENCODED 0x04
00063 #define BDF_PROPORTIONAL 0x08
00064 #define BDF_MONOWIDTH 0x10
00065 #define BDF_CHARCELL 0x20
00066
00067 #define BDF_ALL_SPACING ( BDF_PROPORTIONAL | \
00068 BDF_MONOWIDTH | \
00069 BDF_CHARCELL )
00070
00071 #define BDF_DEFAULT_LOAD_OPTIONS ( BDF_CORRECT_METRICS | \
00072 BDF_KEEP_COMMENTS | \
00073 BDF_KEEP_UNENCODED | \
00074 BDF_PROPORTIONAL )
00075
00076
00077 typedef struct bdf_options_t_
00078 {
00079 int correct_metrics;
00080 int keep_unencoded;
00081 int keep_comments;
00082 int font_spacing;
00083
00084 } bdf_options_t;
00085
00086
00087
00088 typedef int
00089 (*bdf_options_callback_t)( bdf_options_t* opts,
00090 char** params,
00091 unsigned long nparams,
00092 void* client_data );
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 #define BDF_ATOM 1
00103 #define BDF_INTEGER 2
00104 #define BDF_CARDINAL 3
00105
00106
00107
00108
00109 typedef struct bdf_property_t_
00110 {
00111 char* name;
00112 int format;
00113 int builtin;
00114 union
00115 {
00116 char* atom;
00117 long l;
00118 unsigned long ul;
00119
00120 } value;
00121
00122 } bdf_property_t;
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 typedef struct bdf_bbx_t_
00133 {
00134 unsigned short width;
00135 unsigned short height;
00136
00137 short x_offset;
00138 short y_offset;
00139
00140 short ascent;
00141 short descent;
00142
00143 } bdf_bbx_t;
00144
00145
00146 typedef struct bdf_glyph_t_
00147 {
00148 char* name;
00149 long encoding;
00150 unsigned short swidth;
00151 unsigned short dwidth;
00152 bdf_bbx_t bbx;
00153 unsigned char* bitmap;
00154 unsigned long bpr;
00155 unsigned short bytes;
00156
00157 } bdf_glyph_t;
00158
00159
00160 typedef struct _hashnode_
00161 {
00162 const char* key;
00163 size_t data;
00164
00165 } _hashnode, *hashnode;
00166
00167
00168 typedef struct hashtable_
00169 {
00170 int limit;
00171 int size;
00172 int used;
00173 hashnode* table;
00174
00175 } hashtable;
00176
00177
00178 typedef struct bdf_glyphlist_t_
00179 {
00180 unsigned short pad;
00181 unsigned short bpp;
00182 long start;
00183 long end;
00184 bdf_glyph_t* glyphs;
00185 unsigned long glyphs_size;
00186 unsigned long glyphs_used;
00187 bdf_bbx_t bbx;
00188
00189 } bdf_glyphlist_t;
00190
00191
00192 typedef struct bdf_font_t_
00193 {
00194 char* name;
00195 bdf_bbx_t bbx;
00196
00197 long point_size;
00198 unsigned long resolution_x;
00199 unsigned long resolution_y;
00200
00201 int spacing;
00202
00203 unsigned short monowidth;
00204
00205 long default_char;
00206
00207 long font_ascent;
00208 long font_descent;
00209
00210 unsigned long glyphs_size;
00211 unsigned long glyphs_used;
00212 bdf_glyph_t* glyphs;
00213
00214 unsigned long unencoded_size;
00215 unsigned long unencoded_used;
00216 bdf_glyph_t* unencoded;
00217
00218 unsigned long props_size;
00219 unsigned long props_used;
00220 bdf_property_t* props;
00221
00222 char* comments;
00223 unsigned long comments_len;
00224
00225 bdf_glyphlist_t overflow;
00226
00227 void* internal;
00228
00229 unsigned long nmod[2048];
00230 unsigned long umod[2048];
00231
00232 unsigned short modified;
00233 unsigned short bpp;
00234
00235 FT_Memory memory;
00236
00237 bdf_property_t* user_props;
00238 unsigned long nuser_props;
00239 hashtable proptbl;
00240
00241 } bdf_font_t;
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252 #define BDF_MISSING_START -1
00253 #define BDF_MISSING_FONTNAME -2
00254 #define BDF_MISSING_SIZE -3
00255 #define BDF_MISSING_CHARS -4
00256 #define BDF_MISSING_STARTCHAR -5
00257 #define BDF_MISSING_ENCODING -6
00258 #define BDF_MISSING_BBX -7
00259
00260 #define BDF_OUT_OF_MEMORY -20
00261
00262 #define BDF_INVALID_LINE -100
00263
00264
00265
00266
00267
00268
00269
00270
00271 FT_LOCAL( FT_Error )
00272 bdf_load_font( FT_Stream stream,
00273 FT_Memory memory,
00274 bdf_options_t* opts,
00275 bdf_font_t* *font );
00276
00277 FT_LOCAL( void )
00278 bdf_free_font( bdf_font_t* font );
00279
00280 FT_LOCAL( bdf_property_t * )
00281 bdf_get_property( char* name,
00282 bdf_font_t* font );
00283
00284 FT_LOCAL( bdf_property_t * )
00285 bdf_get_font_property( bdf_font_t* font,
00286 const char* name );
00287
00288
00289 FT_END_HEADER
00290
00291
00292 #endif
00293
00294
00295