beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / splash / SplashFont.h
blob78b00d2dcaf008bf9a874326a4b94adeb715dc5c
1 //========================================================================
2 //
3 // SplashFont.h
4 //
5 //========================================================================
7 //========================================================================
8 //
9 // Modified under the Poppler project - http://poppler.freedesktop.org
11 // All changes made under the Poppler project to this file are licensed
12 // under GPL version 2 or later
14 // Copyright (C) 2007-2008 Albert Astals Cid <aacid@kde.org>
16 // To see a description of the changes please see the Changelog file that
17 // came with your tarball or type make ChangeLog if you are building from git
19 //========================================================================
21 #ifndef SPLASHFONT_H
22 #define SPLASHFONT_H
24 #ifdef USE_GCC_PRAGMAS
25 #pragma interface
26 #endif
28 #include "goo/gtypes.h"
29 #include "SplashTypes.h"
30 #include "SplashClip.h"
32 struct SplashGlyphBitmap;
33 struct SplashFontCacheTag;
34 class SplashFontFile;
35 class SplashPath;
37 //------------------------------------------------------------------------
39 // Fractional positioning uses this many bits to the right of the
40 // decimal points.
41 #define splashFontFractionBits 2
42 #define splashFontFraction (1 << splashFontFractionBits)
43 #define splashFontFractionMul \
44 ((SplashCoord)1 / (SplashCoord)splashFontFraction)
46 //------------------------------------------------------------------------
47 // SplashFont
48 //------------------------------------------------------------------------
50 class SplashFont {
51 public:
53 SplashFont(SplashFontFile *fontFileA, SplashCoord *matA,
54 SplashCoord *textMatA, GBool aaA);
56 // This must be called after the constructor, so that the subclass
57 // constructor has a chance to compute the bbox.
58 void initCache();
60 virtual ~SplashFont();
62 SplashFontFile *getFontFile() { return fontFile; }
64 // Return true if <this> matches the specified font file and matrix.
65 GBool matches(SplashFontFile *fontFileA, SplashCoord *matA,
66 SplashCoord *textMatA) {
67 return fontFileA == fontFile &&
68 matA[0] == mat[0] && matA[1] == mat[1] &&
69 matA[2] == mat[2] && matA[3] == mat[3] &&
70 textMatA[0] == textMat[0] && textMatA[1] == textMat[1] &&
71 textMatA[2] == textMat[2] && textMatA[3] == textMat[3];
74 // Get a glyph - this does a cache lookup first, and if not found,
75 // creates a new bitmap and adds it to the cache. The <xFrac> and
76 // <yFrac> values are splashFontFractionBits bits each, representing
77 // the numerators of fractions in [0, 1), where the denominator is
78 // splashFontFraction = 1 << splashFontFractionBits. Subclasses
79 // should override this to zero out xFrac and/or yFrac if they don't
80 // support fractional coordinates.
81 virtual GBool getGlyph(int c, int xFrac, int yFrac,
82 SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes);
84 // Rasterize a glyph. The <xFrac> and <yFrac> values are the same
85 // as described for getGlyph.
86 virtual GBool makeGlyph(int c, int xFrac, int yFrac,
87 SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) = 0;
89 // Return the path for a glyph.
90 virtual SplashPath *getGlyphPath(int c) = 0;
92 // Return the advance of a glyph. (in 0..1 range)
93 // < 0 means not known
94 virtual double getGlyphAdvance(int c) { return -1; }
96 // Return the font transform matrix.
97 SplashCoord *getMatrix() { return mat; }
99 // Return the glyph bounding box.
100 void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA)
101 { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }
103 protected:
105 SplashFontFile *fontFile;
106 SplashCoord mat[4]; // font transform matrix
107 // (text space -> device space)
108 SplashCoord textMat[4]; // text transform matrix
109 // (text space -> user space)
110 GBool aa; // anti-aliasing
111 int xMin, yMin, xMax, yMax; // glyph bounding box
112 Guchar *cache; // glyph bitmap cache
113 SplashFontCacheTag * // cache tags
114 cacheTags;
115 int glyphW, glyphH; // size of glyph bitmaps
116 int glyphSize; // size of glyph bitmaps, in bytes
117 int cacheSets; // number of sets in cache
118 int cacheAssoc; // cache associativity (glyphs per set)
121 #endif