]> www.fi.muni.cz Git - evince.git/blob - pdf/splash/SplashFont.h
My 2005-01-05 change didn't actually fix the problem. Now I just
[evince.git] / pdf / splash / SplashFont.h
1 //========================================================================
2 //
3 // SplashFont.h
4 //
5 //========================================================================
6
7 #ifndef SPLASHFONT_H
8 #define SPLASHFONT_H
9
10 #include <aconf.h>
11
12 #ifdef USE_GCC_PRAGMAS
13 #pragma interface
14 #endif
15
16 #include "gtypes.h"
17 #include "SplashTypes.h"
18
19 struct SplashGlyphBitmap;
20 struct SplashFontCacheTag;
21 class SplashFontFile;
22 class SplashPath;
23
24 //------------------------------------------------------------------------
25
26 // Fractional positioning uses this many bits to the right of the
27 // decimal points.
28 #define splashFontFractionBits 2
29 #define splashFontFraction     (1 << splashFontFractionBits)
30 #define splashFontFractionMul  (1 / (SplashCoord)splashFontFraction)
31
32 //------------------------------------------------------------------------
33 // SplashFont
34 //------------------------------------------------------------------------
35
36 class SplashFont {
37 public:
38
39   SplashFont(SplashFontFile *fontFileA, SplashCoord *matA, GBool aaA);
40
41   // This must be called after the constructor, so that the subclass
42   // constructor has a chance to compute the bbox.
43   void initCache();
44
45   virtual ~SplashFont();
46
47   SplashFontFile *getFontFile() { return fontFile; }
48
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];
54   }
55
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);
65
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;
70
71   // Return the path for a glyph.
72   virtual SplashPath *getGlyphPath(int c) = 0;
73
74 protected:
75
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
82     cacheTags;
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)
87 };
88
89 #endif