ReactOS  0.4.15-dev-2534-geba00d1
bdf.h
Go to the documentation of this file.
1 /*
2  * Copyright 2000 Computing Research Labs, New Mexico State University
3  * Copyright 2001-2004, 2011 Francesco Zappa Nardelli
4  *
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:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
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.
22  */
23 
24 
25 #ifndef BDF_H_
26 #define BDF_H_
27 
28 
29 /*
30  * Based on bdf.h,v 1.16 2000/03/16 20:08:51 mleisher
31  */
32 
33 #include <ft2build.h>
34 #include FT_INTERNAL_OBJECTS_H
35 #include FT_INTERNAL_STREAM_H
36 #include FT_INTERNAL_HASH_H
37 
38 
40 
41 
42 /* Imported from bdfP.h */
43 
44 #define _bdf_glyph_modified( map, e ) \
45  ( (map)[(e) >> 5] & ( 1UL << ( (e) & 31 ) ) )
46 #define _bdf_set_glyph_modified( map, e ) \
47  ( (map)[(e) >> 5] |= ( 1UL << ( (e) & 31 ) ) )
48 #define _bdf_clear_glyph_modified( map, e ) \
49  ( (map)[(e) >> 5] &= ~( 1UL << ( (e) & 31 ) ) )
50 
51 /* end of bdfP.h */
52 
53 
54  /*************************************************************************/
55  /* */
56  /* BDF font options macros and types. */
57  /* */
58  /*************************************************************************/
59 
60 
61 #define BDF_CORRECT_METRICS 0x01 /* Correct invalid metrics when loading. */
62 #define BDF_KEEP_COMMENTS 0x02 /* Preserve the font comments. */
63 #define BDF_KEEP_UNENCODED 0x04 /* Keep the unencoded glyphs. */
64 #define BDF_PROPORTIONAL 0x08 /* Font has proportional spacing. */
65 #define BDF_MONOWIDTH 0x10 /* Font has mono width. */
66 #define BDF_CHARCELL 0x20 /* Font has charcell spacing. */
67 
68 #define BDF_ALL_SPACING ( BDF_PROPORTIONAL | \
69  BDF_MONOWIDTH | \
70  BDF_CHARCELL )
71 
72 #define BDF_DEFAULT_LOAD_OPTIONS ( BDF_CORRECT_METRICS | \
73  BDF_KEEP_COMMENTS | \
74  BDF_KEEP_UNENCODED | \
75  BDF_PROPORTIONAL )
76 
77 
78  typedef struct bdf_options_t_
79  {
84 
85  } bdf_options_t;
86 
87 
88  /* Callback function type for unknown configuration options. */
89  typedef int
91  char** params,
92  unsigned long nparams,
93  void* client_data );
94 
95 
96  /*************************************************************************/
97  /* */
98  /* BDF font property macros and types. */
99  /* */
100  /*************************************************************************/
101 
102 
103 #define BDF_ATOM 1
104 #define BDF_INTEGER 2
105 #define BDF_CARDINAL 3
106 
107 
108  /* This structure represents a particular property of a font. */
109  /* There are a set of defaults and each font has their own. */
110  typedef struct bdf_property_t_
111  {
112  char* name; /* Name of the property. */
113  int format; /* Format of the property. */
114  int builtin; /* A builtin property. */
115  union
116  {
117  char* atom;
118  long l;
119  unsigned long ul;
120 
121  } value; /* Value of the property. */
122 
123  } bdf_property_t;
124 
125 
126  /*************************************************************************/
127  /* */
128  /* BDF font metric and glyph types. */
129  /* */
130  /*************************************************************************/
131 
132 
133  typedef struct bdf_bbx_t_
134  {
135  unsigned short width;
136  unsigned short height;
137 
138  short x_offset;
139  short y_offset;
140 
141  short ascent;
142  short descent;
143 
144  } bdf_bbx_t;
145 
146 
147  typedef struct bdf_glyph_t_
148  {
149  char* name; /* Glyph name. */
150  long encoding; /* Glyph encoding. */
151  unsigned short swidth; /* Scalable width. */
152  unsigned short dwidth; /* Device width. */
153  bdf_bbx_t bbx; /* Glyph bounding box. */
154  unsigned char* bitmap; /* Glyph bitmap. */
155  unsigned long bpr; /* Number of bytes used per row. */
156  unsigned short bytes; /* Number of bytes used for the bitmap. */
157 
158  } bdf_glyph_t;
159 
160 
161  typedef struct bdf_glyphlist_t_
162  {
163  unsigned short pad; /* Pad to 4-byte boundary. */
164  unsigned short bpp; /* Bits per pixel. */
165  long start; /* Beginning encoding value of glyphs. */
166  long end; /* Ending encoding value of glyphs. */
167  bdf_glyph_t* glyphs; /* Glyphs themselves. */
168  unsigned long glyphs_size; /* Glyph structures allocated. */
169  unsigned long glyphs_used; /* Glyph structures used. */
170  bdf_bbx_t bbx; /* Overall bounding box of glyphs. */
171 
172  } bdf_glyphlist_t;
173 
174 
175  typedef struct bdf_font_t_
176  {
177  char* name; /* Name of the font. */
178  bdf_bbx_t bbx; /* Font bounding box. */
179 
180  unsigned long point_size; /* Point size of the font. */
181  unsigned long resolution_x; /* Font horizontal resolution. */
182  unsigned long resolution_y; /* Font vertical resolution. */
183 
184  int spacing; /* Font spacing value. */
185 
186  unsigned short monowidth; /* Logical width for monowidth font. */
187 
188  long default_char; /* Encoding of the default glyph. */
189 
190  long font_ascent; /* Font ascent. */
191  long font_descent; /* Font descent. */
192 
193  unsigned long glyphs_size; /* Glyph structures allocated. */
194  unsigned long glyphs_used; /* Glyph structures used. */
195  bdf_glyph_t* glyphs; /* Glyphs themselves. */
196 
197  unsigned long unencoded_size; /* Unencoded glyph struct. allocated. */
198  unsigned long unencoded_used; /* Unencoded glyph struct. used. */
199  bdf_glyph_t* unencoded; /* Unencoded glyphs themselves. */
200 
201  unsigned long props_size; /* Font properties allocated. */
202  unsigned long props_used; /* Font properties used. */
203  bdf_property_t* props; /* Font properties themselves. */
204 
205  char* comments; /* Font comments. */
206  unsigned long comments_len; /* Length of comment string. */
207 
208  bdf_glyphlist_t overflow; /* Storage used for glyph insertion. */
209 
210  void* internal; /* Internal data for the font. */
211 
212  /* The size of the next two arrays must be in sync with the */
213  /* size of the `have' array in the `bdf_parse_t' structure. */
214  unsigned long nmod[34816]; /* Bitmap indicating modified glyphs. */
215  unsigned long umod[34816]; /* Bitmap indicating modified */
216  /* unencoded glyphs. */
217  unsigned short modified; /* Boolean indicating font modified. */
218  unsigned short bpp; /* Bits per pixel. */
219 
221 
223  unsigned long nuser_props;
225 
226  } bdf_font_t;
227 
228 
229  /*************************************************************************/
230  /* */
231  /* Types for load/save callbacks. */
232  /* */
233  /*************************************************************************/
234 
235 
236  /* Error codes. */
237 #define BDF_MISSING_START -1
238 #define BDF_MISSING_FONTNAME -2
239 #define BDF_MISSING_SIZE -3
240 #define BDF_MISSING_CHARS -4
241 #define BDF_MISSING_STARTCHAR -5
242 #define BDF_MISSING_ENCODING -6
243 #define BDF_MISSING_BBX -7
244 
245 #define BDF_OUT_OF_MEMORY -20
246 
247 #define BDF_INVALID_LINE -100
248 
249 
250  /*************************************************************************/
251  /* */
252  /* BDF font API. */
253  /* */
254  /*************************************************************************/
255 
256  FT_LOCAL( FT_Error )
259  bdf_options_t* opts,
260  bdf_font_t* *font );
261 
262  FT_LOCAL( void )
264 
266  bdf_get_property( char* name,
267  bdf_font_t* font );
268 
271  const char* name );
272 
273 
275 
276 
277 #endif /* BDF_H_ */
278 
279 
280 /* END */
struct bdf_font_t_ bdf_font_t
int spacing
Definition: bdf.h:184
int FT_Error
Definition: fttypes.h:300
unsigned long unencoded_size
Definition: bdf.h:197
char * comments
Definition: bdf.h:205
bdf_property_t * user_props
Definition: bdf.h:222
struct bdf_property_t_ bdf_property_t
#define FT_END_HEADER
Definition: ftheader.h:54
Definition: mk_font.cpp:20
unsigned long glyphs_size
Definition: bdf.h:168
long encoding
Definition: bdf.h:150
unsigned long point_size
Definition: bdf.h:180
unsigned long glyphs_used
Definition: bdf.h:169
char * name
Definition: bdf.h:112
int format
Definition: bdf.h:113
struct bdf_bbx_t_ bdf_bbx_t
long font_ascent
Definition: bdf.h:190
bdf_glyph_t * unencoded
Definition: bdf.h:199
unsigned short monowidth
Definition: bdf.h:186
bdf_free_font(bdf_font_t *font)
Definition: bdflib.c:2366
unsigned short modified
Definition: bdf.h:217
unsigned long resolution_y
Definition: bdf.h:182
static char memory[1024 *256]
Definition: process.c:116
bdf_get_font_property(bdf_font_t *font, const char *name)
Definition: bdflib.c:2447
unsigned long resolution_x
Definition: bdf.h:181
bdf_bbx_t bbx
Definition: bdf.h:153
bdf_property_t * props
Definition: bdf.h:203
unsigned long props_size
Definition: bdf.h:201
unsigned short bpp
Definition: bdf.h:164
long start
Definition: bdf.h:165
GLenum const GLfloat * params
Definition: glext.h:5645
#define FT_BEGIN_HEADER
Definition: ftheader.h:36
int builtin
Definition: bdf.h:114
#define FT_LOCAL(x)
Definition: ftconfig.h:387
int correct_metrics
Definition: bdf.h:80
int(* bdf_options_callback_t)(bdf_options_t *opts, char **params, unsigned long nparams, void *client_data)
Definition: bdf.h:90
short descent
Definition: bdf.h:142
char * name
Definition: bdf.h:177
unsigned short dwidth
Definition: bdf.h:152
unsigned long ul
Definition: bdf.h:119
unsigned short bpp
Definition: bdf.h:218
bdf_bbx_t bbx
Definition: bdf.h:170
FT_HashRec proptbl
Definition: bdf.h:224
long default_char
Definition: bdf.h:188
unsigned long glyphs_size
Definition: bdf.h:193
short x_offset
Definition: bdf.h:138
long font_descent
Definition: bdf.h:191
long l
Definition: bdf.h:118
unsigned long bpr
Definition: bdf.h:155
int keep_unencoded
Definition: bdf.h:81
char * atom
Definition: bdf.h:117
unsigned long nuser_props
Definition: bdf.h:223
unsigned long unencoded_used
Definition: bdf.h:198
union bdf_property_t_::@4011 value
unsigned long comments_len
Definition: bdf.h:206
Definition: parse.h:22
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
bdf_glyphlist_t overflow
Definition: bdf.h:208
unsigned short pad
Definition: bdf.h:163
bdf_load_font(FT_Stream stream, FT_Memory memory, bdf_options_t *opts, bdf_font_t **font)
Definition: bdflib.c:2207
short y_offset
Definition: bdf.h:139
unsigned long nmod[34816]
Definition: bdf.h:214
char * name
Definition: bdf.h:149
FT_Memory memory
Definition: bdf.h:220
struct bdf_glyphlist_t_ bdf_glyphlist_t
unsigned short height
Definition: bdf.h:136
bdf_glyph_t * glyphs
Definition: bdf.h:167
short ascent
Definition: bdf.h:141
unsigned short swidth
Definition: bdf.h:151
unsigned short bytes
Definition: bdf.h:156
bdf_glyph_t * glyphs
Definition: bdf.h:195
Definition: name.c:38
unsigned short width
Definition: bdf.h:135
unsigned long glyphs_used
Definition: bdf.h:194
int font_spacing
Definition: bdf.h:83
bdf_get_property(char *name, bdf_font_t *font)
Definition: bdflib.c:884
struct bdf_glyph_t_ bdf_glyph_t
struct bdf_options_t_ bdf_options_t
unsigned long umod[34816]
Definition: bdf.h:215
unsigned char * bitmap
Definition: bdf.h:154
long end
Definition: bdf.h:166
bdf_bbx_t bbx
Definition: bdf.h:178
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
int keep_comments
Definition: bdf.h:82
unsigned long props_used
Definition: bdf.h:202