1 //========================================================================
5 //========================================================================
12 #ifdef USE_GCC_PRAGMAS
17 #include "SplashTypes.h"
19 struct SplashGlyphBitmap;
20 struct SplashFontCacheTag;
24 //------------------------------------------------------------------------
26 // Fractional positioning uses this many bits to the right of the
28 #define splashFontFractionBits 2
29 #define splashFontFraction (1 << splashFontFractionBits)
30 #define splashFontFractionMul (1 / (SplashCoord)splashFontFraction)
32 //------------------------------------------------------------------------
34 //------------------------------------------------------------------------
39 SplashFont(SplashFontFile *fontFileA, SplashCoord *matA, GBool aaA);
41 // This must be called after the constructor, so that the subclass
42 // constructor has a chance to compute the bbox.
45 virtual ~SplashFont();
47 SplashFontFile *getFontFile() { return fontFile; }
49 // Return true if <this> matches the specified font file and matrix.
50 GBool matches(SplashFontFile *fontFileA, SplashCoord *matA) {
51 return fontFileA == fontFile &&
52 matA[0] == mat[0] && matA[1] == mat[1] &&
53 matA[2] == mat[2] && matA[3] == mat[3];
56 // Get a glyph - this does a cache lookup first, and if not found,
57 // creates a new bitmap and adds it to the cache. The <xFrac> and
58 // <yFrac> values are splashFontFractionBits bits each, representing
59 // the numerators of fractions in [0, 1), where the denominator is
60 // splashFontFraction = 1 << splashFontFractionBits. Subclasses
61 // should override this to zero out xFrac and/or yFrac if they don't
62 // support fractional coordinates.
63 virtual GBool getGlyph(int c, int xFrac, int yFrac,
64 SplashGlyphBitmap *bitmap);
66 // Rasterize a glyph. The <xFrac> and <yFrac> values are the same
67 // as described for getGlyph.
68 virtual GBool makeGlyph(int c, int xFrac, int yFrac,
69 SplashGlyphBitmap *bitmap) = 0;
71 // Return the path for a glyph.
72 virtual SplashPath *getGlyphPath(int c) = 0;
76 SplashFontFile *fontFile;
77 SplashCoord mat[4]; // font transform matrix
78 GBool aa; // anti-aliasing
79 int xMin, yMin, xMax, yMax; // glyph bounding box
80 Guchar *cache; // glyph bitmap cache
81 SplashFontCacheTag * // cache tags
83 int glyphW, glyphH; // size of glyph bitmaps
84 int glyphSize; // size of glyph bitmaps, in bytes
85 int cacheSets; // number of sets in cache
86 int cacheAssoc; // cache associativity (glyphs per set)