]> git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/SplashFTFontFile.cxx
Load cups into easysw/current.
[thirdparty/cups.git] / pdftops / SplashFTFontFile.cxx
1 //========================================================================
2 //
3 // SplashFTFontFile.cc
4 //
5 //========================================================================
6
7 #include <config.h>
8
9 #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
10
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
13 #endif
14
15 #include "gmem.h"
16 #include "SplashFTFontEngine.h"
17 #include "SplashFTFont.h"
18 #include "SplashFTFontFile.h"
19
20 //------------------------------------------------------------------------
21 // SplashFTFontFile
22 //------------------------------------------------------------------------
23
24 SplashFontFile *SplashFTFontFile::loadType1Font(SplashFTFontEngine *engineA,
25 SplashFontFileID *idA,
26 char *fileNameA,
27 GBool deleteFileA,
28 char **encA) {
29 FT_Face faceA;
30 Gushort *codeToGIDA;
31 char *name;
32 int i;
33
34 if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
35 return NULL;
36 }
37 codeToGIDA = (Gushort *)gmallocn(256, sizeof(int));
38 for (i = 0; i < 256; ++i) {
39 codeToGIDA[i] = 0;
40 if ((name = encA[i])) {
41 codeToGIDA[i] = (Gushort)FT_Get_Name_Index(faceA, name);
42 }
43 }
44
45 return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
46 faceA, codeToGIDA, 256);
47 }
48
49 SplashFontFile *SplashFTFontFile::loadCIDFont(SplashFTFontEngine *engineA,
50 SplashFontFileID *idA,
51 char *fileNameA,
52 GBool deleteFileA,
53 Gushort *codeToGIDA,
54 int codeToGIDLenA) {
55 FT_Face faceA;
56
57 if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
58 return NULL;
59 }
60
61 return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
62 faceA, codeToGIDA, codeToGIDLenA);
63 }
64
65 SplashFontFile *SplashFTFontFile::loadTrueTypeFont(SplashFTFontEngine *engineA,
66 SplashFontFileID *idA,
67 char *fileNameA,
68 GBool deleteFileA,
69 Gushort *codeToGIDA,
70 int codeToGIDLenA) {
71 FT_Face faceA;
72
73 if (FT_New_Face(engineA->lib, fileNameA, 0, &faceA)) {
74 return NULL;
75 }
76
77 return new SplashFTFontFile(engineA, idA, fileNameA, deleteFileA,
78 faceA, codeToGIDA, codeToGIDLenA);
79 }
80
81 SplashFTFontFile::SplashFTFontFile(SplashFTFontEngine *engineA,
82 SplashFontFileID *idA,
83 char *fileNameA, GBool deleteFileA,
84 FT_Face faceA,
85 Gushort *codeToGIDA, int codeToGIDLenA):
86 SplashFontFile(idA, fileNameA, deleteFileA)
87 {
88 engine = engineA;
89 face = faceA;
90 codeToGID = codeToGIDA;
91 codeToGIDLen = codeToGIDLenA;
92 }
93
94 SplashFTFontFile::~SplashFTFontFile() {
95 if (face) {
96 FT_Done_Face(face);
97 }
98 if (codeToGID) {
99 gfree(codeToGID);
100 }
101 }
102
103 SplashFont *SplashFTFontFile::makeFont(SplashCoord *mat) {
104 SplashFont *font;
105
106 font = new SplashFTFont(this, mat);
107 font->initCache();
108 return font;
109 }
110
111 #endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H