]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | //======================================================================== |
2 | // | |
3 | // SplashFont.h | |
4 | // | |
5 | //======================================================================== | |
6 | ||
7 | #ifndef SPLASHFONT_H | |
8 | #define SPLASHFONT_H | |
9 | ||
10 | #include <config.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 \ | |
31 | ((SplashCoord)1 / (SplashCoord)splashFontFraction) | |
32 | ||
33 | //------------------------------------------------------------------------ | |
34 | // SplashFont | |
35 | //------------------------------------------------------------------------ | |
36 | ||
37 | class SplashFont { | |
38 | public: | |
39 | ||
40 | SplashFont(SplashFontFile *fontFileA, SplashCoord *matA, GBool aaA); | |
41 | ||
42 | // This must be called after the constructor, so that the subclass | |
43 | // constructor has a chance to compute the bbox. | |
44 | void initCache(); | |
45 | ||
46 | virtual ~SplashFont(); | |
47 | ||
48 | SplashFontFile *getFontFile() { return fontFile; } | |
49 | ||
50 | // Return true if <this> matches the specified font file and matrix. | |
51 | GBool matches(SplashFontFile *fontFileA, SplashCoord *matA) { | |
52 | return fontFileA == fontFile && | |
53 | matA[0] == mat[0] && matA[1] == mat[1] && | |
54 | matA[2] == mat[2] && matA[3] == mat[3]; | |
55 | } | |
56 | ||
57 | // Get a glyph - this does a cache lookup first, and if not found, | |
58 | // creates a new bitmap and adds it to the cache. The <xFrac> and | |
59 | // <yFrac> values are splashFontFractionBits bits each, representing | |
60 | // the numerators of fractions in [0, 1), where the denominator is | |
61 | // splashFontFraction = 1 << splashFontFractionBits. Subclasses | |
62 | // should override this to zero out xFrac and/or yFrac if they don't | |
63 | // support fractional coordinates. | |
64 | virtual GBool getGlyph(int c, int xFrac, int yFrac, | |
65 | SplashGlyphBitmap *bitmap); | |
66 | ||
67 | // Rasterize a glyph. The <xFrac> and <yFrac> values are the same | |
68 | // as described for getGlyph. | |
69 | virtual GBool makeGlyph(int c, int xFrac, int yFrac, | |
70 | SplashGlyphBitmap *bitmap) = 0; | |
71 | ||
72 | // Return the path for a glyph. | |
73 | virtual SplashPath *getGlyphPath(int c) = 0; | |
74 | ||
75 | // Return the font transform matrix. | |
76 | SplashCoord *getMatrix() { return mat; } | |
77 | ||
78 | // Return the glyph bounding box. | |
79 | void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA) | |
80 | { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; } | |
81 | ||
82 | protected: | |
83 | ||
84 | SplashFontFile *fontFile; | |
85 | SplashCoord mat[4]; // font transform matrix | |
86 | GBool aa; // anti-aliasing | |
87 | int xMin, yMin, xMax, yMax; // glyph bounding box | |
88 | Guchar *cache; // glyph bitmap cache | |
89 | SplashFontCacheTag * // cache tags | |
90 | cacheTags; | |
91 | int glyphW, glyphH; // size of glyph bitmaps | |
92 | int glyphSize; // size of glyph bitmaps, in bytes | |
93 | int cacheSets; // number of sets in cache | |
94 | int cacheAssoc; // cache associativity (glyphs per set) | |
95 | }; | |
96 | ||
97 | #endif |