1 //========================================================================
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) 2014 Adrian Johnson <ajohnson@redneon.com>
17 // To see a description of the changes please see the Changelog file that
18 // came with your tarball or type make ChangeLog if you are building from git
20 //========================================================================
24 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
26 #ifdef USE_GCC_PRAGMAS
27 #pragma implementation
31 #include "goo/GooString.h"
32 #include "poppler/GfxFont.h"
33 #include "SplashFTFontEngine.h"
34 #include "SplashFTFont.h"
35 #include "SplashFTFontFile.h"
37 //------------------------------------------------------------------------
39 //------------------------------------------------------------------------
41 SplashFontFile
*SplashFTFontFile::loadType1Font(SplashFTFontEngine
*engineA
,
42 SplashFontFileID
*idA
,
51 if (FT_New_Face(engineA
->lib
, src
->fileName
->getCString(), 0, &faceA
))
54 if (FT_New_Memory_Face(engineA
->lib
, (const FT_Byte
*)src
->buf
, src
->bufLen
, 0, &faceA
))
57 codeToGIDA
= (int *)gmallocn(256, sizeof(int));
58 for (i
= 0; i
< 256; ++i
) {
60 if ((name
= encA
[i
])) {
61 codeToGIDA
[i
] = (int)FT_Get_Name_Index(faceA
, (char *)name
);
62 if (codeToGIDA
[i
] == 0) {
63 name
= GfxFont::getAlternateName(name
);
65 codeToGIDA
[i
] = FT_Get_Name_Index(faceA
, (char *)name
);
71 return new SplashFTFontFile(engineA
, idA
, src
,
72 faceA
, codeToGIDA
, 256, gFalse
, gTrue
);
75 SplashFontFile
*SplashFTFontFile::loadCIDFont(SplashFTFontEngine
*engineA
,
76 SplashFontFileID
*idA
,
83 if (FT_New_Face(engineA
->lib
, src
->fileName
->getCString(), 0, &faceA
))
86 if (FT_New_Memory_Face(engineA
->lib
, (const FT_Byte
*)src
->buf
, src
->bufLen
, 0, &faceA
))
90 return new SplashFTFontFile(engineA
, idA
, src
,
91 faceA
, codeToGIDA
, codeToGIDLenA
, gFalse
, gFalse
);
94 SplashFontFile
*SplashFTFontFile::loadTrueTypeFont(SplashFTFontEngine
*engineA
,
95 SplashFontFileID
*idA
,
103 if (FT_New_Face(engineA
->lib
, src
->fileName
->getCString(), faceIndexA
, &faceA
))
106 if (FT_New_Memory_Face(engineA
->lib
, (const FT_Byte
*)src
->buf
, src
->bufLen
, faceIndexA
, &faceA
))
110 return new SplashFTFontFile(engineA
, idA
, src
,
111 faceA
, codeToGIDA
, codeToGIDLenA
, gTrue
, gFalse
);
114 SplashFTFontFile::SplashFTFontFile(SplashFTFontEngine
*engineA
,
115 SplashFontFileID
*idA
,
118 int *codeToGIDA
, int codeToGIDLenA
,
119 GBool trueTypeA
, GBool type1A
):
120 SplashFontFile(idA
, src
)
124 codeToGID
= codeToGIDA
;
125 codeToGIDLen
= codeToGIDLenA
;
126 trueType
= trueTypeA
;
130 SplashFTFontFile::~SplashFTFontFile() {
139 SplashFont
*SplashFTFontFile::makeFont(SplashCoord
*mat
,
140 SplashCoord
*textMat
) {
143 font
= new SplashFTFont(this, mat
, textMat
);
148 #endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H