1 //========================================================================
2 //
3 // SplashFontEngine.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) 2006 Takashi Iwai <tiwai@suse.de>
15 // Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com>
16 // Copyright (C) 2009, 2011 Albert Astals Cid <aacid@kde.org>
17 // Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com>
18 // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
19 //
20 // To see a description of the changes please see the Changelog file that
21 // came with your tarball or type make ChangeLog if you are building from git
22 //
23 //========================================================================
24 
25 #ifndef SPLASHFONTENGINE_H
26 #define SPLASHFONTENGINE_H
27 
28 #ifdef USE_GCC_PRAGMAS
29 #pragma interface
30 #endif
31 
32 #include "goo/gtypes.h"
33 #include "SplashTypes.h"
34 
35 class SplashT1FontEngine;
36 class SplashFTFontEngine;
37 class SplashDTFontEngine;
38 class SplashDT4FontEngine;
39 class SplashFontFile;
40 class SplashFontFileID;
41 class SplashFont;
42 class SplashFontSrc;
43 
44 //------------------------------------------------------------------------
45 
46 #define splashFontCacheSize 16
47 
48 //------------------------------------------------------------------------
49 // SplashFontEngine
50 //------------------------------------------------------------------------
51 
52 class SplashFontEngine {
53 public:
54 
55   // Create a font engine.
56   SplashFontEngine(
57 #if HAVE_T1LIB_H
58 		   GBool enableT1lib,
59 #endif
60 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
61 		   GBool enableFreeType,
62 		   GBool enableFreeTypeHinting,
63 		   GBool enableSlightHinting,
64 #endif
65 		   GBool aa);
66 
67   ~SplashFontEngine();
68 
69   // Get a font file from the cache.  Returns NULL if there is no
70   // matching entry in the cache.
71   SplashFontFile *getFontFile(SplashFontFileID *id);
72 
73   // Load fonts - these create new SplashFontFile objects.
74   SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, const char **enc);
75   SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, const char **enc);
76   SplashFontFile *loadOpenTypeT1CFont(SplashFontFileID *idA, SplashFontSrc *src, const char **enc);
77   SplashFontFile *loadCIDFont(SplashFontFileID *idA, SplashFontSrc *src);
78   SplashFontFile *loadOpenTypeCFFFont(SplashFontFileID *idA, SplashFontSrc *src,
79                                       int *codeToGID, int codeToGIDLen);
80   SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src,
81 				   int *codeToGID, int codeToGIDLen, int faceIndex = 0);
82 
83   // Get a font - this does a cache lookup first, and if not found,
84   // creates a new SplashFont object and adds it to the cache.  The
85   // matrix, mat = textMat * ctm:
86   //    [ mat[0] mat[1] ]
87   //    [ mat[2] mat[3] ]
88   // specifies the font transform in PostScript style:
89   //    [x' y'] = [x y] * mat
90   // Note that the Splash y axis points downward.
91   SplashFont *getFont(SplashFontFile *fontFile,
92 		      SplashCoord *textMat, SplashCoord *ctm);
93 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
94   GBool getAA();
95   void setAA(GBool aa);
96 #endif
97 
98 private:
99 
100   SplashFont *fontCache[splashFontCacheSize];
101 
102 #if HAVE_T1LIB_H
103   SplashT1FontEngine *t1Engine;
104 #endif
105 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
106   SplashFTFontEngine *ftEngine;
107 #endif
108 };
109 
110 #endif
111