/* @(#)fontcache.h 9.2 88/01/19 SMI */ /* * Copyright (c) 1985 by Sun Microsystems, Inc. */ /*- Definitions for the font cacheing mechanism fontcache.h, Mon Dec 2 11:23:37 1985 James Gosling, Sun Microsystems */ #ifndef FONTHASHSIZE #ifndef NEW_FONT_MAGIC #include "font.h" #endif struct cachedfont { /* A cached font */ int hash; /* The matrix hash for this font */ char valid; /* True iff the font part of this cachedfont * is valid */ short refcnt; /* Pad out to 32 bits for compatibility with * machines that do long word int alignment */ struct cachedfont *next; /* Next font in same hash bucket */ struct font font; /* The actual font in this cache entry */ }; #define FONTHASHSIZE 37 /* Prime numbers are good */ #define FONTTABLESIZE 73 #define HASHFONT(m) ((m)[0][0]+(m)[0][1]+(m)[1][0]+(m)[1][1]) /* * The fonts in a font family are indexed two ways. First there is a chained * hash table where the encoding and transformation matrix are used as the * key. It is used for general font lookup. Second is a table of fonts which * all have the property that their transformation matrix is of the form [s 0 * 0 s] - uniform scaling with no rotation. This table is indexed by * roundfr(s). No slot of this table will ever be nil - "best match" * computations will have already been done. */ struct fontfamily { union { int magic; /* FONTFAMILYMAGIC */ int (*buildchar) (); /* Set if this font has a BuildChar */ } m; char *FamilyName; /* eg. "Times-Roman" */ char *directory; /* The directory that this family came from * (only used when validiating cache entries) */ struct cachedfont *printermatched; /* printer matching table */ struct cachedfont *hash[FONTHASHSIZE]; struct cachedfont *table[FONTTABLESIZE]; }; #define FONTFAMILYMAGIC 0x137A2947 struct psfont { struct fontfamily *family; fract matrix[2][2]; char simplescale; /* true iff matrix==[s 0 0 s] */ int refcnt; /* Number of references to this font */ unsigned short *remap; /* points to a translation table if this is * just a remapped font */ short revision; /* Matched against the last transform that * lasthit was validated against */ struct cachedfont *lasthit; }; #define psf_incref(psf) ((psf)->refcnt++) #define psf_decref(psf) {if (--(psf)->refcnt<=0) { qtfree(psf); }} #endif