ReactOS 0.4.15-dev-7961-gdcf9eb0
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_glyphlist_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_glyphlist_t_ bdf_glyphlist_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 247 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 243 of file bdf.h.

◆ BDF_MISSING_CHARS

#define BDF_MISSING_CHARS   -4

Definition at line 240 of file bdf.h.

◆ BDF_MISSING_ENCODING

#define BDF_MISSING_ENCODING   -6

Definition at line 242 of file bdf.h.

◆ BDF_MISSING_FONTNAME

#define BDF_MISSING_FONTNAME   -2

Definition at line 238 of file bdf.h.

◆ BDF_MISSING_SIZE

#define BDF_MISSING_SIZE   -3

Definition at line 239 of file bdf.h.

◆ BDF_MISSING_START

#define BDF_MISSING_START   -1

Definition at line 237 of file bdf.h.

◆ BDF_MISSING_STARTCHAR

#define BDF_MISSING_STARTCHAR   -5

Definition at line 241 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 245 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_glyphlist_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 2366 of file bdflib.c.

2367 {
2368 bdf_property_t* prop;
2369 unsigned long i;
2372
2373
2374 if ( font == 0 )
2375 return;
2376
2377 memory = font->memory;
2378
2379 FT_FREE( font->name );
2380
2381 /* Free up the internal hash table of property names. */
2382 if ( font->internal )
2383 {
2384 ft_hash_str_free( (FT_Hash)font->internal, memory );
2385 FT_FREE( font->internal );
2386 }
2387
2388 /* Free up the comment info. */
2389 FT_FREE( font->comments );
2390
2391 /* Free up the properties. */
2392 for ( i = 0; i < font->props_size; i++ )
2393 {
2394 if ( font->props[i].format == BDF_ATOM )
2395 FT_FREE( font->props[i].value.atom );
2396 }
2397
2398 FT_FREE( font->props );
2399
2400 /* Free up the character info. */
2401 for ( i = 0, glyphs = font->glyphs;
2402 i < font->glyphs_used; i++, glyphs++ )
2403 {
2404 FT_FREE( glyphs->name );
2405 FT_FREE( glyphs->bitmap );
2406 }
2407
2408 for ( i = 0, glyphs = font->unencoded; i < font->unencoded_used;
2409 i++, glyphs++ )
2410 {
2411 FT_FREE( glyphs->name );
2412 FT_FREE( glyphs->bitmap );
2413 }
2414
2415 FT_FREE( font->glyphs );
2416 FT_FREE( font->unencoded );
2417
2418 /* Free up the overflow storage if it was used. */
2419 for ( i = 0, glyphs = font->overflow.glyphs;
2420 i < font->overflow.glyphs_used; i++, glyphs++ )
2421 {
2422 FT_FREE( glyphs->name );
2423 FT_FREE( glyphs->bitmap );
2424 }
2425
2426 FT_FREE( font->overflow.glyphs );
2427
2428 /* bdf_cleanup */
2429 ft_hash_str_free( &(font->proptbl), memory );
2430
2431 /* Free up the user defined properties. */
2432 for ( prop = font->user_props, i = 0;
2433 i < font->nuser_props; i++, prop++ )
2434 {
2435 FT_FREE( prop->name );
2436 if ( prop->format == BDF_ATOM )
2437 FT_FREE( prop->value.atom );
2438 }
2439
2440 FT_FREE( font->user_props );
2441
2442 /* FREE( font ); */ /* XXX Fixme */
2443 }
#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:329
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
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
char * atom
Definition: bdf.h:117
union bdf_property_t_::@4235 value

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 2447 of file bdflib.c.

2449 {
2450 size_t* propid;
2451
2452
2453 if ( font == 0 || font->props_size == 0 || name == 0 || *name == 0 )
2454 return 0;
2455
2456 propid = ft_hash_str_lookup( name, (FT_Hash)font->internal );
2457
2458 return propid ? ( font->props + *propid ) : 0;
2459 }
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 884 of file bdflib.c.

886 {
887 size_t* propid;
888
889
890 if ( name == 0 || *name == 0 )
891 return 0;
892
893 if ( ( propid = ft_hash_str_lookup( name, &(font->proptbl) ) ) == NULL )
894 return 0;
895
896 if ( *propid >= _num_bdf_properties )
897 return font->user_props + ( *propid - _num_bdf_properties );
898
899 return (bdf_property_t*)_bdf_properties + *propid;
900 }
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 2207 of file bdflib.c.

2211 {
2212 unsigned long lineno = 0; /* make compiler happy */
2213 _bdf_parse_t *p = NULL;
2214
2215 FT_Memory memory = extmemory; /* needed for FT_NEW */
2217
2218
2219 if ( FT_NEW( p ) )
2220 goto Exit;
2221
2222 memory = NULL;
2223 p->opts = (bdf_options_t*)( ( opts != 0 ) ? opts : &_bdf_opts );
2224 p->minlb = 32767;
2225 p->size = stream->size;
2226 p->memory = extmemory; /* only during font creation */
2227
2228 _bdf_list_init( &p->list, extmemory );
2229
2231 (void *)p, &lineno );
2232 if ( error )
2233 goto Fail;
2234
2235 if ( p->font != 0 )
2236 {
2237 /* If the font is not proportional, set the font's monowidth */
2238 /* field to the width of the font bounding box. */
2239
2240 if ( p->font->spacing != BDF_PROPORTIONAL )
2241 p->font->monowidth = p->font->bbx.width;
2242
2243 /* If the number of glyphs loaded is not that of the original count, */
2244 /* indicate the difference. */
2245 if ( p->cnt != p->font->glyphs_used + p->font->unencoded_used )
2246 {
2247 FT_TRACE2(( "bdf_load_font: " ACMSG15, p->cnt,
2248 p->font->glyphs_used + p->font->unencoded_used ));
2249 p->font->modified = 1;
2250 }
2251
2252 /* Once the font has been loaded, adjust the overall font metrics if */
2253 /* necessary. */
2254 if ( p->opts->correct_metrics != 0 &&
2255 ( p->font->glyphs_used > 0 || p->font->unencoded_used > 0 ) )
2256 {
2257 if ( p->maxrb - p->minlb != p->font->bbx.width )
2258 {
2259 FT_TRACE2(( "bdf_load_font: " ACMSG3,
2260 p->font->bbx.width, p->maxrb - p->minlb ));
2261 p->font->bbx.width = (unsigned short)( p->maxrb - p->minlb );
2262 p->font->modified = 1;
2263 }
2264
2265 if ( p->font->bbx.x_offset != p->minlb )
2266 {
2267 FT_TRACE2(( "bdf_load_font: " ACMSG4,
2268 p->font->bbx.x_offset, p->minlb ));
2269 p->font->bbx.x_offset = p->minlb;
2270 p->font->modified = 1;
2271 }
2272
2273 if ( p->font->bbx.ascent != p->maxas )
2274 {
2275 FT_TRACE2(( "bdf_load_font: " ACMSG5,
2276 p->font->bbx.ascent, p->maxas ));
2277 p->font->bbx.ascent = p->maxas;
2278 p->font->modified = 1;
2279 }
2280
2281 if ( p->font->bbx.descent != p->maxds )
2282 {
2283 FT_TRACE2(( "bdf_load_font: " ACMSG6,
2284 p->font->bbx.descent, p->maxds ));
2285 p->font->bbx.descent = p->maxds;
2286 p->font->bbx.y_offset = (short)( -p->maxds );
2287 p->font->modified = 1;
2288 }
2289
2290 if ( p->maxas + p->maxds != p->font->bbx.height )
2291 {
2292 FT_TRACE2(( "bdf_load_font: " ACMSG7,
2293 p->font->bbx.height, p->maxas + p->maxds ));
2294 p->font->bbx.height = (unsigned short)( p->maxas + p->maxds );
2295 }
2296
2297 if ( p->flags & BDF_SWIDTH_ADJ_ )
2298 FT_TRACE2(( "bdf_load_font: " ACMSG8 ));
2299 }
2300 }
2301
2302 if ( p->flags & BDF_START_ )
2303 {
2304 /* The ENDFONT field was never reached or did not exist. */
2305 if ( !( p->flags & BDF_GLYPHS_ ) )
2306 {
2307 /* Error happened while parsing header. */
2308 FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno ));
2309 error = FT_THROW( Corrupted_Font_Header );
2310 goto Fail;
2311 }
2312 else
2313 {
2314 /* Error happened when parsing glyphs. */
2315 FT_ERROR(( "bdf_load_font: " ERRMSG3, lineno ));
2316 error = FT_THROW( Corrupted_Font_Glyphs );
2317 goto Fail;
2318 }
2319 }
2320
2321 if ( p->font != 0 )
2322 {
2323 /* Make sure the comments are NULL terminated if they exist. */
2324 memory = p->font->memory;
2325
2326 if ( p->font->comments_len > 0 )
2327 {
2328 if ( FT_RENEW_ARRAY( p->font->comments,
2329 p->font->comments_len,
2330 p->font->comments_len + 1 ) )
2331 goto Fail;
2332
2333 p->font->comments[p->font->comments_len] = 0;
2334 }
2335 }
2336 else if ( !error )
2337 error = FT_THROW( Invalid_File_Format );
2338
2339 *font = p->font;
2340
2341 Exit:
2342 if ( p )
2343 {
2344 _bdf_list_done( &p->list );
2345
2346 memory = extmemory;
2347
2348 FT_FREE( p->glyph_name );
2349 FT_FREE( p );
2350 }
2351
2352 return error;
2353
2354 Fail:
2355 bdf_free_font( p->font );
2356
2357 memory = extmemory;
2358
2359 FT_FREE( p->font );
2360
2361 goto Exit;
2362 }
static void _bdf_list_init(_bdf_list_t *list, FT_Memory memory)
Definition: bdflib.c:290
static const bdf_options_t _bdf_opts
Definition: bdflib.c:62
#define ACMSG3
Definition: bdflib.c:189
#define BDF_START_
Definition: bdflib.c:912
#define ACMSG6
Definition: bdflib.c:193
#define ACMSG15
Definition: bdflib.c:202
#define ERRMSG2
Definition: bdflib.c:208
#define BDF_GLYPHS_
Definition: bdflib.c:917
#define BDF_SWIDTH_ADJ_
Definition: bdflib.c:925
#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:521
static FT_Error _bdf_parse_start(char *line, unsigned long linelen, unsigned long lineno, void *call_data, void *client_data)
Definition: bdflib.c:1898
static void _bdf_list_done(_bdf_list_t *list)
Definition: bdflib.c:299
bdf_free_font(bdf_font_t *font)
Definition: bdflib.c:2366
#define ACMSG5
Definition: bdflib.c:192
#define ACMSG8
Definition: bdflib.c:195
#define ERRMSG3
Definition: bdflib.c:209
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
int Fail
Definition: ehthrow.cxx:24
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_TRACE2(varformat)
Definition: ftdebug.h:159
#define FT_NEW(ptr)
Definition: ftmemory.h:331
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
Definition: ftmemory.h:336
int FT_Error
Definition: fttypes.h:300
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().