1 //========================================================================
3 // SplashFTFontEngine.cc
5 //========================================================================
9 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
22 #include "FoFiTrueType.h"
23 #include "FoFiType1C.h"
24 #include "SplashFTFontFile.h"
25 #include "SplashFTFontEngine.h"
28 #if (__VMS_VER < 70000000)
29 extern "C" int unlink(char *filename);
33 //------------------------------------------------------------------------
35 static void fileWrite(void *stream, char *data, int len) {
36 fwrite(data, 1, len, (FILE *)stream);
39 //------------------------------------------------------------------------
41 //------------------------------------------------------------------------
43 SplashFTFontEngine::SplashFTFontEngine(GBool aaA, FT_Library libA) {
48 SplashFTFontEngine *SplashFTFontEngine::init(GBool aaA) {
51 if (FT_Init_FreeType(&libA)) {
54 return new SplashFTFontEngine(aaA, libA);
57 SplashFTFontEngine::~SplashFTFontEngine() {
58 FT_Done_FreeType(lib);
61 SplashFontFile *SplashFTFontEngine::loadType1Font(SplashFontFileID *idA,
65 return SplashFTFontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
68 SplashFontFile *SplashFTFontEngine::loadType1CFont(SplashFontFileID *idA,
72 return SplashFTFontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
75 SplashFontFile *SplashFTFontEngine::loadCIDFont(SplashFontFileID *idA,
83 // check for a CFF font
84 if ((ff = FoFiType1C::load(fileName))) {
85 cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
91 ret = SplashFTFontFile::loadCIDFont(this, idA, fileName, deleteFile,
99 SplashFontFile *SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID *idA,
105 GString *tmpFileName;
109 if (!(ff = FoFiTrueType::load(fileName))) {
113 if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) {
117 ff->writeTTF(&fileWrite, tmpFile);
120 ret = SplashFTFontFile::loadTrueTypeFont(this, idA,
121 tmpFileName->getCString(),
122 gTrue, codeToGID, codeToGIDLen);
128 unlink(tmpFileName->getCString());
134 #endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H