ReactOS 0.4.16-dev-1067-ge98bba2
bdf.h File Reference
#include <ft2build.h>
Include dependency graph for bdf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  bdf_options_t_
 
struct  bdf_property_t_
 
struct  bdf_bbx_t_
 
struct  bdf_glyph_t_
 
struct  bdf_font_t_
 

Macros

#define _bdf_glyph_modified(map, e)    ( (map)[(e) >> 5] & ( 1UL << ( (e) & 31 ) ) )
 
#define _bdf_set_glyph_modified(map, e)    ( (map)[(e) >> 5] |= ( 1UL << ( (e) & 31 ) ) )
 
#define _bdf_clear_glyph_modified(map, e)    ( (map)[(e) >> 5] &= ~( 1UL << ( (e) & 31 ) ) )
 
#define BDF_CORRECT_METRICS   0x01 /* Correct invalid metrics when loading. */
 
#define BDF_KEEP_COMMENTS   0x02 /* Preserve the font comments. */
 
#define BDF_KEEP_UNENCODED   0x04 /* Keep the unencoded glyphs. */
 
#define BDF_PROPORTIONAL   0x08 /* Font has proportional spacing. */
 
#define BDF_MONOWIDTH   0x10 /* Font has mono width. */
 
#define BDF_CHARCELL   0x20 /* Font has charcell spacing. */
 
#define BDF_ALL_SPACING
 
#define BDF_DEFAULT_LOAD_OPTIONS
 
#define BDF_ATOM   1
 
#define BDF_INTEGER   2
 
#define BDF_CARDINAL   3
 
#define BDF_MISSING_START   -1
 
#define BDF_MISSING_FONTNAME   -2
 
#define BDF_MISSING_SIZE   -3
 
#define BDF_MISSING_CHARS   -4
 
#define BDF_MISSING_STARTCHAR   -5
 
#define BDF_MISSING_ENCODING   -6
 
#define BDF_MISSING_BBX   -7
 
#define BDF_OUT_OF_MEMORY   -20
 
#define BDF_INVALID_LINE   -100
 

Typedefs

typedef struct bdf_options_t_ bdf_options_t
 
typedef int(* bdf_options_callback_t) (bdf_options_t *opts, char **params, unsigned long nparams, void *client_data)
 
typedef struct bdf_property_t_ bdf_property_t
 
typedef struct bdf_bbx_t_ bdf_bbx_t
 
typedef struct bdf_glyph_t_ bdf_glyph_t
 
typedef struct bdf_font_t_ bdf_font_t
 

Functions

 bdf_load_font (FT_Stream stream, FT_Memory memory, bdf_options_t *opts, bdf_font_t **font)
 
 bdf_free_font (bdf_font_t *font)
 
 bdf_get_property (char *name, bdf_font_t *font)
 
 bdf_get_font_property (bdf_font_t *font, const char *name)
 

Macro Definition Documentation

◆ _bdf_clear_glyph_modified

#define _bdf_clear_glyph_modified (   map,
  e 
)     ( (map)[(e) >> 5] &= ~( 1UL << ( (e) & 31 ) ) )

Definition at line 48 of file bdf.h.

◆ _bdf_glyph_modified

#define _bdf_glyph_modified (   map,
  e 
)     ( (map)[(e) >> 5] & ( 1UL << ( (e) & 31 ) ) )

Definition at line 44 of file bdf.h.

◆ _bdf_set_glyph_modified

#define _bdf_set_glyph_modified (   map,
  e 
)     ( (map)[(e) >> 5] |= ( 1UL << ( (e) & 31 ) ) )

Definition at line 46 of file bdf.h.

◆ BDF_ALL_SPACING

#define BDF_ALL_SPACING
Value:
#define BDF_MONOWIDTH
Definition: bdf.h:65
#define BDF_PROPORTIONAL
Definition: bdf.h:64
#define BDF_CHARCELL
Definition: bdf.h:66

Definition at line 68 of file bdf.h.

◆ BDF_ATOM

#define BDF_ATOM   1

Definition at line 103 of file bdf.h.

◆ BDF_CARDINAL

#define BDF_CARDINAL   3

Definition at line 105 of file bdf.h.

◆ BDF_CHARCELL

#define BDF_CHARCELL   0x20 /* Font has charcell spacing. */

Definition at line 66 of file bdf.h.

◆ BDF_CORRECT_METRICS

#define BDF_CORRECT_METRICS   0x01 /* Correct invalid metrics when loading. */

Definition at line 61 of file bdf.h.

◆ BDF_DEFAULT_LOAD_OPTIONS

#define BDF_DEFAULT_LOAD_OPTIONS
Value:
#define BDF_KEEP_UNENCODED
Definition: bdf.h:63
#define BDF_KEEP_COMMENTS
Definition: bdf.h:62
#define BDF_CORRECT_METRICS
Definition: bdf.h:61

Definition at line 72 of file bdf.h.

◆ BDF_INTEGER

#define BDF_INTEGER   2

Definition at line 104 of file bdf.h.

◆ BDF_INVALID_LINE

#define BDF_INVALID_LINE   -100

Definition at line 225 of file bdf.h.

◆ BDF_KEEP_COMMENTS

#define BDF_KEEP_COMMENTS   0x02 /* Preserve the font comments. */

Definition at line 62 of file bdf.h.

◆ BDF_KEEP_UNENCODED

#define BDF_KEEP_UNENCODED   0x04 /* Keep the unencoded glyphs. */

Definition at line 63 of file bdf.h.

◆ BDF_MISSING_BBX

#define BDF_MISSING_BBX   -7

Definition at line 221 of file bdf.h.

◆ BDF_MISSING_CHARS

#define BDF_MISSING_CHARS   -4

Definition at line 218 of file bdf.h.

◆ BDF_MISSING_ENCODING

#define BDF_MISSING_ENCODING   -6

Definition at line 220 of file bdf.h.

◆ BDF_MISSING_FONTNAME

#define BDF_MISSING_FONTNAME   -2

Definition at line 216 of file bdf.h.

◆ BDF_MISSING_SIZE

#define BDF_MISSING_SIZE   -3

Definition at line 217 of file bdf.h.

◆ BDF_MISSING_START

#define BDF_MISSING_START   -1

Definition at line 215 of file bdf.h.

◆ BDF_MISSING_STARTCHAR

#define BDF_MISSING_STARTCHAR   -5

Definition at line 219 of file bdf.h.

◆ BDF_MONOWIDTH

#define BDF_MONOWIDTH   0x10 /* Font has mono width. */

Definition at line 65 of file bdf.h.

◆ BDF_OUT_OF_MEMORY

#define BDF_OUT_OF_MEMORY   -20

Definition at line 223 of file bdf.h.

◆ BDF_PROPORTIONAL

#define BDF_PROPORTIONAL   0x08 /* Font has proportional spacing. */

Definition at line 64 of file bdf.h.

Typedef Documentation

◆ bdf_bbx_t

◆ bdf_font_t

◆ bdf_glyph_t

◆ bdf_options_callback_t

typedef int(* bdf_options_callback_t) (bdf_options_t *opts, char **params, unsigned long nparams, void *client_data)

Definition at line 89 of file bdf.h.

◆ bdf_options_t

◆ bdf_property_t

Function Documentation

◆ bdf_free_font()

bdf_free_font ( bdf_font_t font)

Definition at line 2330 of file bdflib.c.

2331 {
2332 bdf_property_t* prop;
2333 unsigned long i;
2336
2337
2338 if ( font == 0 )
2339 return;
2340
2341 memory = font->memory;
2342
2343 FT_FREE( font->name );
2344
2345 /* Free up the internal hash table of property names. */
2346 if ( font->internal )
2347 {
2348 ft_hash_str_free( (FT_Hash)font->internal, memory );
2349 FT_FREE( font->internal );
2350 }
2351
2352 /* Free up the comment info. */
2353 FT_FREE( font->comments );
2354
2355 /* Free up the properties. */
2356 for ( i = 0; i < font->props_size; i++ )
2357 {
2358 if ( font->props[i].format == BDF_ATOM )
2359 FT_FREE( font->props[i].value.atom );
2360 }
2361
2362 FT_FREE( font->props );
2363
2364 /* Free up the character info. */
2365 for ( i = 0, glyphs = font->glyphs;
2366 i < font->glyphs_used; i++, glyphs++ )
2367 {
2368 FT_FREE( glyphs->name );
2369 FT_FREE( glyphs->bitmap );
2370 }
2371
2372 for ( i = 0, glyphs = font->unencoded; i < font->unencoded_used;
2373 i++, glyphs++ )
2374 {
2375 FT_FREE( glyphs->name );
2376 FT_FREE( glyphs->bitmap );
2377 }
2378
2379 FT_FREE( font->glyphs );
2380 FT_FREE( font->unencoded );
2381
2382 /* bdf_cleanup */
2383 ft_hash_str_free( &(font->proptbl), memory );
2384
2385 /* Free up the user defined properties. */
2386 for ( prop = font->user_props, i = 0;
2387 i < font->nuser_props; i++, prop++ )
2388 {
2389 FT_FREE( prop->name );
2390 if ( prop->format == BDF_ATOM )
2391 FT_FREE( prop->value.atom );
2392 }
2393
2394 FT_FREE( font->user_props );
2395
2396 /* FREE( font ); */ /* XXX Fixme */
2397 }
#define BDF_ATOM
Definition: bdf.h:103
void ft_hash_str_free(FT_Hash hash, FT_Memory memory)
Definition: fthash.c:212
#define FT_FREE(ptr)
Definition: ftmemory.h:328
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:65
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static UINT UINT LPWORD glyphs
Definition: font.c:44
static char memory[1024 *256]
Definition: process.c:116
Definition: mk_font.cpp:20
int format
Definition: bdf.h:113
char * name
Definition: bdf.h:112
union bdf_property_t_::@4367 value
char * atom
Definition: bdf.h:117

Referenced by BDF_Face_Done(), and bdf_load_font().

◆ bdf_get_font_property()

bdf_get_font_property ( bdf_font_t font,
const char name 
)

Definition at line 2401 of file bdflib.c.

2403 {
2404 size_t* propid;
2405
2406
2407 if ( font == 0 || font->props_size == 0 || name == 0 || *name == 0 )
2408 return 0;
2409
2410 propid = ft_hash_str_lookup( name, (FT_Hash)font->internal );
2411
2412 return propid ? ( font->props + *propid ) : 0;
2413 }
size_t * ft_hash_str_lookup(const char *key, FT_Hash hash)
Definition: fthash.c:314
Definition: name.c:39

Referenced by _bdf_parse_properties(), BDF_Face_Init(), bdf_get_bdf_property(), and bdf_interpret_style().

◆ bdf_get_property()

bdf_get_property ( char name,
bdf_font_t font 
)

Definition at line 881 of file bdflib.c.

883 {
884 size_t* propid;
885
886
887 if ( name == 0 || *name == 0 )
888 return 0;
889
890 if ( ( propid = ft_hash_str_lookup( name, &(font->proptbl) ) ) == NULL )
891 return 0;
892
893 if ( *propid >= _num_bdf_properties )
894 return font->user_props + ( *propid - _num_bdf_properties );
895
896 return (bdf_property_t*)_bdf_properties + *propid;
897 }
static const bdf_property_t _bdf_properties[]
Definition: bdflib.c:80
static const unsigned long _num_bdf_properties
Definition: bdflib.c:168
#define NULL
Definition: types.h:112

Referenced by _bdf_is_atom().

◆ bdf_load_font()

bdf_load_font ( FT_Stream  stream,
FT_Memory  memory,
bdf_options_t opts,
bdf_font_t **  font 
)

Definition at line 2176 of file bdflib.c.

2180 {
2181 unsigned long lineno = 0; /* make compiler happy */
2182 _bdf_parse_t *p = NULL;
2183
2184 FT_Memory memory = extmemory; /* needed for FT_NEW */
2186
2187
2188 if ( FT_NEW( p ) )
2189 goto Exit;
2190
2191 memory = NULL;
2192 p->opts = (bdf_options_t*)( ( opts != 0 ) ? opts : &_bdf_opts );
2193 p->minlb = 32767;
2194 p->size = stream->size;
2195 p->memory = extmemory; /* only during font creation */
2196
2197 _bdf_list_init( &p->list, extmemory );
2198
2200 (void *)p, &lineno );
2201 if ( error )
2202 goto Fail;
2203
2204 if ( p->font != 0 )
2205 {
2206 /* If the font is not proportional, set the font's monowidth */
2207 /* field to the width of the font bounding box. */
2208
2209 if ( p->font->spacing != BDF_PROPORTIONAL )
2210 p->font->monowidth = p->font->bbx.width;
2211
2212 /* If the number of glyphs loaded is not that of the original count, */
2213 /* indicate the difference. */
2214 if ( p->cnt != p->font->glyphs_used + p->font->unencoded_used )
2215 {
2216 FT_TRACE2(( "bdf_load_font: " ACMSG15, p->cnt,
2217 p->font->glyphs_used + p->font->unencoded_used ));
2218 }
2219
2220 /* Once the font has been loaded, adjust the overall font metrics if */
2221 /* necessary. */
2222 if ( p->opts->correct_metrics != 0 &&
2223 ( p->font->glyphs_used > 0 || p->font->unencoded_used > 0 ) )
2224 {
2225 if ( p->maxrb - p->minlb != p->font->bbx.width )
2226 {
2227 FT_TRACE2(( "bdf_load_font: " ACMSG3,
2228 p->font->bbx.width, p->maxrb - p->minlb ));
2229 p->font->bbx.width = (unsigned short)( p->maxrb - p->minlb );
2230 }
2231
2232 if ( p->font->bbx.x_offset != p->minlb )
2233 {
2234 FT_TRACE2(( "bdf_load_font: " ACMSG4,
2235 p->font->bbx.x_offset, p->minlb ));
2236 p->font->bbx.x_offset = p->minlb;
2237 }
2238
2239 if ( p->font->bbx.ascent != p->maxas )
2240 {
2241 FT_TRACE2(( "bdf_load_font: " ACMSG5,
2242 p->font->bbx.ascent, p->maxas ));
2243 p->font->bbx.ascent = p->maxas;
2244 }
2245
2246 if ( p->font->bbx.descent != p->maxds )
2247 {
2248 FT_TRACE2(( "bdf_load_font: " ACMSG6,
2249 p->font->bbx.descent, p->maxds ));
2250 p->font->bbx.descent = p->maxds;
2251 p->font->bbx.y_offset = (short)( -p->maxds );
2252 }
2253
2254 if ( p->maxas + p->maxds != p->font->bbx.height )
2255 {
2256 FT_TRACE2(( "bdf_load_font: " ACMSG7,
2257 p->font->bbx.height, p->maxas + p->maxds ));
2258 p->font->bbx.height = (unsigned short)( p->maxas + p->maxds );
2259 }
2260
2261 if ( p->flags & BDF_SWIDTH_ADJ_ )
2262 FT_TRACE2(( "bdf_load_font: " ACMSG8 ));
2263 }
2264 }
2265
2266 if ( p->flags & BDF_START_ )
2267 {
2268 /* The ENDFONT field was never reached or did not exist. */
2269 if ( !( p->flags & BDF_GLYPHS_ ) )
2270 {
2271 /* Error happened while parsing header. */
2272 FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno ));
2273 error = FT_THROW( Corrupted_Font_Header );
2274 goto Fail;
2275 }
2276 else
2277 {
2278 /* Error happened when parsing glyphs. */
2279 FT_ERROR(( "bdf_load_font: " ERRMSG3, lineno ));
2280 error = FT_THROW( Corrupted_Font_Glyphs );
2281 goto Fail;
2282 }
2283 }
2284
2285 if ( p->font != 0 )
2286 {
2287 /* Make sure the comments are NULL terminated if they exist. */
2288 memory = p->font->memory;
2289
2290 if ( p->font->comments_len > 0 )
2291 {
2292 if ( FT_RENEW_ARRAY( p->font->comments,
2293 p->font->comments_len,
2294 p->font->comments_len + 1 ) )
2295 goto Fail;
2296
2297 p->font->comments[p->font->comments_len] = 0;
2298 }
2299 }
2300 else if ( !error )
2301 error = FT_THROW( Invalid_File_Format );
2302
2303 *font = p->font;
2304
2305 Exit:
2306 if ( p )
2307 {
2308 _bdf_list_done( &p->list );
2309
2310 memory = extmemory;
2311
2312 FT_FREE( p->glyph_name );
2313 FT_FREE( p );
2314 }
2315
2316 return error;
2317
2318 Fail:
2319 bdf_free_font( p->font );
2320
2321 memory = extmemory;
2322
2323 FT_FREE( p->font );
2324
2325 goto Exit;
2326 }
static void _bdf_list_init(_bdf_list_t *list, FT_Memory memory)
Definition: bdflib.c:287
static const bdf_options_t _bdf_opts
Definition: bdflib.c:62
#define ACMSG3
Definition: bdflib.c:189
#define BDF_START_
Definition: bdflib.c:909
#define ACMSG6
Definition: bdflib.c:193
#define ACMSG15
Definition: bdflib.c:201
#define ERRMSG2
Definition: bdflib.c:207
#define BDF_GLYPHS_
Definition: bdflib.c:914
#define BDF_SWIDTH_ADJ_
Definition: bdflib.c:922
#define ACMSG4
Definition: bdflib.c:190
#define ACMSG7
Definition: bdflib.c:194
static FT_Error _bdf_readstream(FT_Stream stream, _bdf_line_func_t callback, void *client_data, unsigned long *lno)
Definition: bdflib.c:518
static FT_Error _bdf_parse_start(char *line, unsigned long linelen, unsigned long lineno, void *call_data, void *client_data)
Definition: bdflib.c:1869
static void _bdf_list_done(_bdf_list_t *list)
Definition: bdflib.c:296
bdf_free_font(bdf_font_t *font)
Definition: bdflib.c:2330
#define ACMSG5
Definition: bdflib.c:192
#define ACMSG8
Definition: bdflib.c:195
#define ERRMSG3
Definition: bdflib.c:208
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
int Fail
Definition: ehthrow.cxx:24
return FT_Err_Ok
Definition: ftbbox.c:527
#define FT_ERROR(varformat)
Definition: ftdebug.h:209
#define FT_THROW(e)
Definition: ftdebug.h:241
#define FT_TRACE2(varformat)
Definition: ftdebug.h:187
#define FT_NEW(ptr)
Definition: ftmemory.h:330
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
Definition: ftmemory.h:335
int FT_Error
Definition: fttypes.h:299
GLfloat GLfloat p
Definition: glext.h:8902
#define error(str)
Definition: mkdosfs.c:1605
static void Exit(void)
Definition: sock.c:1330
Definition: parse.h:23
unsigned int size
Definition: parse.h:27

Referenced by BDF_Face_Init().