1 //========================================================================
3 // SplashFTFontEngine.cc
5 //========================================================================
7 //========================================================================
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) 2006 Takashi Iwai <tiwai@suse.de>
15 // Copyright (C) 2009, 2011, 2012 Albert Astals Cid <aacid@kde.org>
16 // Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com>
17 // Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com>
19 // To see a description of the changes please see the Changelog file that
20 // came with your tarball or type make ChangeLog if you are building from git
22 //========================================================================
26 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
28 #ifdef USE_GCC_PRAGMAS
29 #pragma implementation
37 #include "goo/GooString.h"
38 #include "goo/gfile.h"
39 #include "fofi/FoFiTrueType.h"
40 #include "fofi/FoFiType1C.h"
41 #include "SplashFTFontFile.h"
42 #include "SplashFTFontEngine.h"
45 #if (__VMS_VER < 70000000)
46 extern "C" int unlink(char *filename
);
50 //------------------------------------------------------------------------
52 //------------------------------------------------------------------------
54 SplashFTFontEngine::SplashFTFontEngine(GBool aaA
, GBool enableFreeTypeHintingA
,
55 GBool enableSlightHintingA
, FT_Library libA
) {
56 FT_Int major
, minor
, patch
;
59 enableFreeTypeHinting
= enableFreeTypeHintingA
;
60 enableSlightHinting
= enableSlightHintingA
;
63 // as of FT 2.1.8, CID fonts are indexed by CID instead of GID
64 FT_Library_Version(lib
, &major
, &minor
, &patch
);
65 useCIDs
= major
> 2 ||
66 (major
== 2 && (minor
> 1 || (minor
== 1 && patch
> 7)));
69 SplashFTFontEngine
*SplashFTFontEngine::init(GBool aaA
, GBool enableFreeTypeHintingA
,
70 GBool enableSlightHintingA
) {
73 if (FT_Init_FreeType(&libA
)) {
76 return new SplashFTFontEngine(aaA
, enableFreeTypeHintingA
, enableSlightHintingA
, libA
);
79 SplashFTFontEngine::~SplashFTFontEngine() {
80 FT_Done_FreeType(lib
);
83 SplashFontFile
*SplashFTFontEngine::loadType1Font(SplashFontFileID
*idA
,
86 return SplashFTFontFile::loadType1Font(this, idA
, src
, enc
);
89 SplashFontFile
*SplashFTFontEngine::loadType1CFont(SplashFontFileID
*idA
,
92 return SplashFTFontFile::loadType1Font(this, idA
, src
, enc
);
95 SplashFontFile
*SplashFTFontEngine::loadOpenTypeT1CFont(SplashFontFileID
*idA
,
98 return SplashFTFontFile::loadType1Font(this, idA
, src
, enc
);
101 SplashFontFile
*SplashFTFontEngine::loadCIDFont(SplashFontFileID
*idA
,
102 SplashFontSrc
*src
) {
108 // check for a CFF font
114 ff
= FoFiType1C::load(src
->fileName
->getCString());
116 ff
= FoFiType1C::make(src
->buf
, src
->bufLen
);
119 cidToGIDMap
= ff
->getCIDToGIDMap(&nCIDs
);
126 ret
= SplashFTFontFile::loadCIDFont(this, idA
, src
, cidToGIDMap
, nCIDs
);
133 SplashFontFile
*SplashFTFontEngine::loadOpenTypeCFFFont(SplashFontFileID
*idA
,
147 ff
= FoFiTrueType::load(src
->fileName
->getCString());
149 ff
= FoFiTrueType::make(src
->buf
, src
->bufLen
);
152 if (ff
->isOpenTypeCFF()) {
153 cidToGIDMap
= ff
->getCIDToGIDMap(&nCIDs
);
159 ret
= SplashFTFontFile::loadCIDFont(this, idA
, src
,
160 codeToGID
? codeToGID
: cidToGIDMap
,
161 codeToGID
? codeToGIDLen
: nCIDs
);
168 SplashFontFile
*SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID
*idA
,
174 ret
= SplashFTFontFile::loadTrueTypeFont(this, idA
, src
,
175 codeToGID
, codeToGIDLen
,
180 #endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H