]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/TTFont.h
distribute gpdf-window-ui.xml
[evince.git] / pdf / xpdf / TTFont.h
1 //========================================================================
2 //
3 // TTFont.h
4 //
5 // An X wrapper for the FreeType TrueType font rasterizer.
6 //
7 // Copyright 2001-2002 Glyph & Cog, LLC
8 //
9 //========================================================================
10
11 #ifndef TTFONT_H
12 #define TTFONT_H
13
14 #if !FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
15
16 #ifdef __GNUC__
17 #pragma interface
18 #endif
19
20 #if HAVE_FREETYPE_FREETYPE_H
21 #include <freetype/freetype.h>
22 #include <freetype/ftxpost.h>
23 #else
24 #include <freetype.h>
25 #include <ftxpost.h>
26 #endif
27 #include "gtypes.h"
28 #include "SFont.h"
29
30 //------------------------------------------------------------------------
31
32 class TTFontEngine: public SFontEngine {
33 public:
34
35   TTFontEngine(Display *displayA, Visual *visualA, int depthA,
36                Colormap colormapA, GBool aaA);
37   GBool isOk() { return ok; }
38   virtual ~TTFontEngine();
39
40 private:
41
42   TT_Engine engine;
43   GBool aa;
44   Gulong palette[5];
45   GBool ok;
46
47   friend class TTFontFile;
48   friend class TTFont;
49 };
50
51 //------------------------------------------------------------------------
52
53 enum TTFontIndexMode {
54   ttFontModeUnicode,
55   ttFontModeCharCode,
56   ttFontModeCharCodeOffset,
57   ttFontModeCodeMap,
58   ttFontModeCIDToGIDMap
59 };
60
61 class TTFontFile: public SFontFile {
62 public:
63
64   // 8-bit font, TrueType or Type 1/1C
65   TTFontFile(TTFontEngine *engineA, char *fontFileName,
66              char **fontEnc, GBool pdfFontHasEncoding);
67
68   // CID font, TrueType
69   TTFontFile(TTFontEngine *engineA, char *fontFileName,
70              Gushort *cidToGIDA, int cidToGIDLenA);
71
72   GBool isOk() { return ok; }
73   virtual ~TTFontFile();
74
75 private:
76
77   TTFontEngine *engine;
78   TT_Face face;
79   TT_CharMap charMap;
80   TTFontIndexMode mode;
81   int charMapOffset;
82   Guchar *codeMap;
83   Gushort *cidToGID;
84   int cidToGIDLen;
85   GBool ok;
86
87   friend class TTFont;
88 };
89
90 //------------------------------------------------------------------------
91
92 struct TTFontCacheTag {
93   Gushort code;
94   Gushort mru;                  // valid bit (0x8000) and MRU index
95 };
96
97 class TTFont: public SFont {
98 public:
99
100   TTFont(TTFontFile *fontFileA, double *m);
101   GBool isOk() { return ok; }
102   virtual ~TTFont();
103   virtual GBool drawChar(Drawable d, int w, int h, GC gc,
104                          int x, int y, int r, int g, int b,
105                          CharCode c, Unicode u);
106
107 private:
108
109   GBool getGlyphPixmap(CharCode c, Unicode u);
110
111   TTFontFile *fontFile;
112   TT_Instance instance;
113   TT_Glyph glyph;
114   TT_Raster_Map ras;
115   XImage *image;
116   TT_Matrix matrix;
117   TT_F26Dot6 xOffset, yOffset;
118   Guchar *cache;                // glyph pixmap cache
119   TTFontCacheTag *cacheTags;    // cache tags, i.e., char codes
120   int cacheSets;                // number of sets in cache
121   int cacheAssoc;               // cache associativity (glyphs per set)
122   GBool ok;
123 };
124
125 #endif // !FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
126
127 #endif