1 //========================================================================
3 // SplashT1FontEngine.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 Albert Astals Cid <aacid@kde.org>
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 //========================================================================
26 #ifdef USE_GCC_PRAGMAS
27 #pragma implementation
36 #include "goo/GooString.h"
37 #include "goo/gfile.h"
38 #include "fofi/FoFiType1C.h"
39 #include "SplashT1FontFile.h"
40 #include "SplashT1FontEngine.h"
43 #if (__VMS_VER < 70000000)
44 extern "C" int unlink(char *filename
);
48 //------------------------------------------------------------------------
50 int SplashT1FontEngine::t1libInitCount
= 0;
52 //------------------------------------------------------------------------
54 static void fileWrite(void *stream
, const char *data
, int len
) {
55 fwrite(data
, 1, len
, (FILE *)stream
);
58 //------------------------------------------------------------------------
60 //------------------------------------------------------------------------
62 SplashT1FontEngine::SplashT1FontEngine(GBool aaA
) {
66 SplashT1FontEngine
*SplashT1FontEngine::init(GBool aaA
) {
67 // grayVals[i] = round(i * 255 / 16)
68 static unsigned long grayVals
[17] = {
69 0, 16, 32, 48, 64, 80, 96, 112, 128, 143, 159, 175, 191, 207, 223, 239, 255
72 //~ for multithreading: need a mutex here
73 if (t1libInitCount
== 0) {
75 if (!T1_InitLib(NO_LOGFILE
| IGNORE_CONFIGFILE
| IGNORE_FONTDATABASE
|
80 T1_AASetBitsPerPixel(8);
81 T1_AASetLevel(T1_AA_HIGH
);
82 T1_AAHSetGrayValues(grayVals
);
84 T1_AANSetGrayValues(0, 1);
89 return new SplashT1FontEngine(aaA
);
92 SplashT1FontEngine::~SplashT1FontEngine() {
93 //~ for multithreading: need a mutex here
94 if (--t1libInitCount
== 0) {
99 SplashFontFile
*SplashT1FontEngine::loadType1Font(SplashFontFileID
*idA
,
102 return SplashT1FontFile::loadType1Font(this, idA
, src
, enc
);
105 SplashFontFile
*SplashT1FontEngine::loadType1CFont(SplashFontFileID
*idA
,
109 GooString
*tmpFileName
;
113 SplashFontSrc
*newsrc
;
116 ff
= FoFiType1C::load(src
->fileName
->getCString());
118 ff
= FoFiType1C::make(src
->buf
, src
->bufLen
);
123 if (!openTempFile(&tmpFileName
, &tmpFile
, "wb")) {
127 ff
->convertToType1(NULL
, NULL
, gTrue
, &fileWrite
, tmpFile
);
130 newsrc
= new SplashFontSrc
;
131 newsrc
->setFile(tmpFileName
, gTrue
);
133 ret
= SplashT1FontFile::loadType1Font(this, idA
, newsrc
, enc
);
138 #endif // HAVE_T1LIB_H