1 //========================================================================
3 // SplashT1FontEngine.cc
5 //========================================================================
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
21 #include "goo/GooString.h"
22 #include "goo/gfile.h"
23 #include "fofi/FoFiType1C.h"
24 #include "SplashT1FontFile.h"
25 #include "SplashT1FontEngine.h"
28 #if (__VMS_VER < 70000000)
29 extern "C" int unlink(char *filename
);
33 //------------------------------------------------------------------------
35 int SplashT1FontEngine::t1libInitCount
= 0;
37 //------------------------------------------------------------------------
39 static void fileWrite(void *stream
, char *data
, int len
) {
40 fwrite(data
, 1, len
, (FILE *)stream
);
43 //------------------------------------------------------------------------
45 //------------------------------------------------------------------------
47 SplashT1FontEngine::SplashT1FontEngine(GBool aaA
) {
51 SplashT1FontEngine
*SplashT1FontEngine::init(GBool aaA
) {
52 // grayVals[i] = round(i * 255 / 16)
53 static unsigned long grayVals
[17] = {
54 0, 16, 32, 48, 64, 80, 96, 112, 128, 143, 159, 175, 191, 207, 223, 239, 255
57 //~ for multithreading: need a mutex here
58 if (t1libInitCount
== 0) {
60 if (!T1_InitLib(NO_LOGFILE
| IGNORE_CONFIGFILE
| IGNORE_FONTDATABASE
|
65 T1_AASetBitsPerPixel(8);
66 T1_AASetLevel(T1_AA_HIGH
);
67 T1_AAHSetGrayValues(grayVals
);
69 T1_AANSetGrayValues(0, 1);
74 return new SplashT1FontEngine(aaA
);
77 SplashT1FontEngine::~SplashT1FontEngine() {
78 //~ for multithreading: need a mutex here
79 if (--t1libInitCount
== 0) {
84 SplashFontFile
*SplashT1FontEngine::loadType1Font(SplashFontFileID
*idA
,
87 return SplashT1FontFile::loadType1Font(this, idA
, src
, enc
);
90 SplashFontFile
*SplashT1FontEngine::loadType1CFont(SplashFontFileID
*idA
,
94 GooString
*tmpFileName
;
98 SplashFontSrc
*newsrc
;
101 ff
= FoFiType1C::load(src
->fileName
);
103 ff
= new FoFiType1C(src
->buf
, src
->bufLen
, gFalse
);
108 if (!openTempFile(&tmpFileName
, &tmpFile
, "wb", NULL
)) {
112 ff
->convertToType1(NULL
, gTrue
, &fileWrite
, tmpFile
);
115 newsrc
= new SplashFontSrc
;
116 newsrc
->setFile(tmpFileName
, gTrue
);
118 ret
= SplashT1FontFile::loadType1Font(this, idA
, newsrc
, enc
);
123 #endif // HAVE_T1LIB_H