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 >
C/C++ Source or Header  |  1992-03-17  |  3KB  |  73 lines

  1. /* This structure caches an 8 bit font or a row of a 16 bit font. */
  2.  
  3. #define CACHE_ROWS_PER_FONT_ROW 1    /* max number of cache rows per
  4.                        font row */
  5.  
  6. typedef struct apa16Font *apa16FontPtr;
  7.  
  8. typedef struct apa16FontCache
  9. {
  10.   unsigned short xorg, yorg, w, h;    /* position and size of rectangle */
  11.   struct apa16FontCache *prev, *next;    /* neighbors */
  12.   unsigned short row;            /* row in owner (usually 0) */
  13.   unsigned short used;            /* in use (this could be a bitfield
  14.                        but it is faster this way) */
  15.   unsigned int referenced;        /* last time referenced */
  16.   apa16FontPtr owner;            /* font to which this cache entry belongs */
  17. } apa16FontCache;
  18.  
  19. /* This structure records the location of all the characters in a cache
  20.    row.  Currently characters can not be freed.  */
  21.  
  22. typedef struct apa16FCCharInfo
  23. {
  24.   int x;            /* allocated point */
  25.   int xmax;            /* end of allocated width */
  26.   int yorg;            /* lower edge of band */
  27.   int cmin, cmax;        /* min and max valid char value */
  28.   int cached;            /* has cache area assigned */
  29.   char char_cached[256];    /* char is cached, xorg is valid */
  30.   unsigned short xorg[256];    /* right edge of char + 1 */
  31.   CharInfoPtr chars[256];    /* The bounds and sizes of the chars */
  32. } apa16FCCharInfo;
  33.  
  34. typedef struct apa16Font
  35. {
  36.   FontPtr afFont;
  37.   apa16FontCache **afCache;    /* This is an array of pointers because
  38.                    it is easier to merge and free cache
  39.                    entries that way. */
  40.   apa16FCCharInfo *afChars;
  41.   unsigned short afHeight;
  42.   unsigned short afNChars;
  43.   unsigned short afNrows;
  44.   short afWidth;        /* For a constant width font, the constant
  45.                    width. */
  46.   short afDefChar;
  47.   short afDefWidth;        /* Width of default character. */
  48. } apa16Font;
  49.  
  50. #define    APA16_FONT_CACHED(font) ((font)->afChars->cached || apa16CacheFontRow(font,0))
  51. #define    APA16_CHAR8_CACHED(font,char) (font)->afChars->char_cached[char]
  52. #define    APA16_CHAR8_CACHE_X(fci,char) (fci)->xorg[char]
  53. #define    APA16_CHAR8_CACHE_Y(fci,char) (fci)->yorg
  54. #define    APA16_TOUCH_FONT(font,row) ((font)->afCache[row]->referenced = apa16_fontcache_counter++)
  55. extern int apa16_fontcache_counter;
  56.  
  57. #ifndef NO_FUNCTION_PROTOTYPES
  58. extern void apa16InitFontCache(void);
  59. Bool apa16RealizeFont(ScreenPtr, FontPtr);
  60. Bool apa16UnrealizeFont(ScreenPtr, FontPtr);
  61. Bool apa16CacheFont(apa16FontPtr);
  62. Bool apa16CacheFontRow(apa16FontPtr, int);
  63. Bool apa16CacheChars(apa16FontPtr, unsigned char *, unsigned int);
  64. #else
  65. extern void apa16InitFontCache();
  66. Bool apa16RealizeFont();
  67. Bool apa16UnrealizeFont();
  68. Bool apa16CacheFont();
  69. Bool apa16CacheFontRow();
  70. Bool apa16CacheChars();
  71. #endif
  72.  
  73.