source: trunk/poppler/mypoppler/splash/SplashFont.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 16 years ago

First import

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