1 //========================================================================
3 // SplashT1FontEngine.cc
5 //========================================================================
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
23 #include "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,
88 return SplashT1FontFile::loadType1Font(this, idA, fileName, deleteFile, enc);
91 SplashFontFile *SplashT1FontEngine::loadType1CFont(SplashFontFileID *idA,
100 if (!(ff = FoFiType1C::load(fileName))) {
104 if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) {
108 ff->convertToType1(NULL, gTrue, &fileWrite, tmpFile);
111 ret = SplashT1FontFile::loadType1Font(this, idA, tmpFileName->getCString(),
118 unlink(tmpFileName->getCString());
124 #endif // HAVE_T1LIB_H