home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
x
/
xibm.zip
/
apa16
/
apa16Font.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-17
|
3KB
|
73 lines
/* This structure caches an 8 bit font or a row of a 16 bit font. */
#define CACHE_ROWS_PER_FONT_ROW 1 /* max number of cache rows per
font row */
typedef struct apa16Font *apa16FontPtr;
typedef struct apa16FontCache
{
unsigned short xorg, yorg, w, h; /* position and size of rectangle */
struct apa16FontCache *prev, *next; /* neighbors */
unsigned short row; /* row in owner (usually 0) */
unsigned short used; /* in use (this could be a bitfield
but it is faster this way) */
unsigned int referenced; /* last time referenced */
apa16FontPtr owner; /* font to which this cache entry belongs */
} apa16FontCache;
/* This structure records the location of all the characters in a cache
row. Currently characters can not be freed. */
typedef struct apa16FCCharInfo
{
int x; /* allocated point */
int xmax; /* end of allocated width */
int yorg; /* lower edge of band */
int cmin, cmax; /* min and max valid char value */
int cached; /* has cache area assigned */
char char_cached[256]; /* char is cached, xorg is valid */
unsigned short xorg[256]; /* right edge of char + 1 */
CharInfoPtr chars[256]; /* The bounds and sizes of the chars */
} apa16FCCharInfo;
typedef struct apa16Font
{
FontPtr afFont;
apa16FontCache **afCache; /* This is an array of pointers because
it is easier to merge and free cache
entries that way. */
apa16FCCharInfo *afChars;
unsigned short afHeight;
unsigned short afNChars;
unsigned short afNrows;
short afWidth; /* For a constant width font, the constant
width. */
short afDefChar;
short afDefWidth; /* Width of default character. */
} apa16Font;
#define APA16_FONT_CACHED(font) ((font)->afChars->cached || apa16CacheFontRow(font,0))
#define APA16_CHAR8_CACHED(font,char) (font)->afChars->char_cached[char]
#define APA16_CHAR8_CACHE_X(fci,char) (fci)->xorg[char]
#define APA16_CHAR8_CACHE_Y(fci,char) (fci)->yorg
#define APA16_TOUCH_FONT(font,row) ((font)->afCache[row]->referenced = apa16_fontcache_counter++)
extern int apa16_fontcache_counter;
#ifndef NO_FUNCTION_PROTOTYPES
extern void apa16InitFontCache(void);
Bool apa16RealizeFont(ScreenPtr, FontPtr);
Bool apa16UnrealizeFont(ScreenPtr, FontPtr);
Bool apa16CacheFont(apa16FontPtr);
Bool apa16CacheFontRow(apa16FontPtr, int);
Bool apa16CacheChars(apa16FontPtr, unsigned char *, unsigned int);
#else
extern void apa16InitFontCache();
Bool apa16RealizeFont();
Bool apa16UnrealizeFont();
Bool apa16CacheFont();
Bool apa16CacheFontRow();
Bool apa16CacheChars();
#endif