~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/poppler/splash/SplashFont.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//========================================================================
 
2
//
 
3
// SplashFont.h
 
4
//
 
5
//========================================================================
 
6
 
 
7
//========================================================================
 
8
//
 
9
// Modified under the Poppler project - http://poppler.freedesktop.org
 
10
//
 
11
// All changes made under the Poppler project to this file are licensed
 
12
// under GPL version 2 or later
 
13
//
 
14
// Copyright (C) 2007-2008 Albert Astals Cid <aacid@kde.org>
 
15
//
 
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
 
18
//
 
19
//========================================================================
 
20
 
 
21
#ifndef SPLASHFONT_H
 
22
#define SPLASHFONT_H
 
23
 
 
24
#ifdef USE_GCC_PRAGMAS
 
25
#pragma interface
 
26
#endif
 
27
 
 
28
#include "goo/gtypes.h"
 
29
#include "SplashTypes.h"
 
30
#include "SplashClip.h"
 
31
 
 
32
struct SplashGlyphBitmap;
 
33
struct SplashFontCacheTag;
 
34
class SplashFontFile;
 
35
class SplashPath;
 
36
 
 
37
//------------------------------------------------------------------------
 
38
 
 
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)
 
45
 
 
46
//------------------------------------------------------------------------
 
47
// SplashFont
 
48
//------------------------------------------------------------------------
 
49
 
 
50
class SplashFont {
 
51
public:
 
52
 
 
53
  SplashFont(SplashFontFile *fontFileA, SplashCoord *matA,
 
54
             SplashCoord *textMatA, GBool aaA);
 
55
 
 
56
  // This must be called after the constructor, so that the subclass
 
57
  // constructor has a chance to compute the bbox.
 
58
  void initCache();
 
59
 
 
60
  virtual ~SplashFont();
 
61
 
 
62
  SplashFontFile *getFontFile() { return fontFile; }
 
63
 
 
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];
 
72
  }
 
73
 
 
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);
 
83
 
 
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;
 
88
 
 
89
  // Return the path for a glyph.
 
90
  virtual SplashPath *getGlyphPath(int c) = 0;
 
91
 
 
92
  // Return the advance of a glyph. (in 0..1 range)
 
93
  // < 0 means not known
 
94
  virtual double getGlyphAdvance(int c) { return -1; }
 
95
 
 
96
  // Return the font transform matrix.
 
97
  SplashCoord *getMatrix() { return mat; }
 
98
 
 
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; }
 
102
 
 
103
protected:
 
104
 
 
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)
 
119
};
 
120
 
 
121
#endif