/* Generated by convbdf_dct on Thu Dec  2 20:23:23 2010. */

#ifndef __FONT_H__
#define __FONT_H__

#ifdef __cplusplus
extern "C"
{
#endif


/* bitmap_t image unit */
typedef unsigned short bitmap_t;

/* bitmap_t helper macros */
#define BITMAP_BITSPERIMAGE     (sizeof(bitmap_t) * 8)                            /* Bits per bitmap_t */
#define BITMAP_WORDS(x)         (((x)+BITMAP_BITSPERIMAGE-1)/BITMAP_BITSPERIMAGE) /* Number of words to hold a pixel line of width x pixels */
#define BITMAP_BYTES(x)         (BITMAP_WORDS(x)*sizeof(bitmap_t))                /* Number of bytes to hold a pixel line of width x pixels */
#define BITMAP_BITVALUE(n)      ((bitmap_t) (((bitmap_t) 1) << (n)))              /* Value of bit n in a bitmap_t */
#define BITMAP_FIRSTBIT         (BITMAP_BITVALUE(BITMAP_BITSPERIMAGE - 1))        /* Value of first (= most significant) bit in a bitmap_t */
#define BITMAP_TESTBIT(m)       ((m) & BITMAP_FIRSTBIT)                           /* Test value of first bit of given bitmap_t */
#define BITMAP_SHIFTBIT(m)      ((bitmap_t) ((m) << 1))                           /* Shift bitmap_t left by one */

/* C-based proportional/fixed font structure */
/* based on The Microwindows Project http://microwindows.org */
typedef struct font_s
{
    int                    maxwidth;       /* max width in pixels */
    int                    height;         /* height in pixels */
    int                    ascent;         /* ascent (baseline) height */
    int                    descent;        /* descent (baseline) depth */
    int                    firstchar;      /* first character in bitmap */
    int                    size;           /* font size in glyphs ('holes' included) */
    const bitmap_t*        bits;           /* 16-bit right-padded bitmap data */
    const unsigned short*  offsets;        /* offsets into bitmap data or NULL if contiguous */
    const unsigned char*   widths;         /* character widths or NULL if fixed */
    int                    defaultchar;    /* default char (not glyph index!) */
    int                    bits_size;      /* # words of bitmap_t bits */
    const char*            name;           /* the font name */
} font_t;

/* List of all available fonts; NULL marks end of list */
extern const font_t *fonts[];

/* Number of available fonts */
extern const unsigned long num_fonts;


#ifdef __cplusplus
}
#endif

#endif /* __FONT_H__ */

