]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/xpdf/T1Font.cc
Import of Xpdf 2.00 for merge
[evince.git] / pdf / xpdf / T1Font.cc
index 7b79d8747fe4a9e8685244ae1045e344b4f6a42a..9815e490147c5278de8a9d55ee9d9964cec96f31 100644 (file)
@@ -6,14 +6,14 @@
 //
 //========================================================================
 
-#ifdef __GNUC__
-#pragma implementation
-#endif
-
 #include <aconf.h>
 
 #if HAVE_T1LIB_H
 
+#ifdef USE_GCC_PRAGMAS
+#pragma implementation
+#endif
+
 #include <math.h>
 #include <string.h>
 #include <X11/Xlib.h>
 
 //------------------------------------------------------------------------
 
+int T1FontEngine::t1libInitCount = 0;
+
+//------------------------------------------------------------------------
+
 T1FontEngine::T1FontEngine(Display *displayA, Visual *visualA, int depthA,
                           Colormap colormapA, GBool aaA, GBool aaHighA):
   SFontEngine(displayA, visualA, depthA, colormapA)
@@ -32,30 +36,37 @@ T1FontEngine::T1FontEngine(Display *displayA, Visual *visualA, int depthA,
   };
 
   ok = gFalse;
-  T1_SetBitmapPad(8);
-  if (!T1_InitLib(NO_LOGFILE | IGNORE_CONFIGFILE | IGNORE_FONTDATABASE |
-                 T1_NO_AFM)) {
-    return;
-  }
   aa = aaA;
   aaHigh = aaHighA;
-  if (aa) {
-    T1_AASetBitsPerPixel(8);
-    if (aaHigh) {
-      T1_AASetLevel(T1_AA_HIGH);
-      T1_AAHSetGrayValues(grayVals);
+  //~ for multithreading: need a mutex here
+  if (t1libInitCount == 0) {
+    T1_SetBitmapPad(8);
+    if (!T1_InitLib(NO_LOGFILE | IGNORE_CONFIGFILE | IGNORE_FONTDATABASE |
+                   T1_NO_AFM)) {
+      return;
+    }
+    if (aa) {
+      T1_AASetBitsPerPixel(8);
+      if (aaHigh) {
+       T1_AASetLevel(T1_AA_HIGH);
+       T1_AAHSetGrayValues(grayVals);
+      } else {
+       T1_AASetLevel(T1_AA_LOW);
+       T1_AASetGrayValues(0, 1, 2, 3, 4);
+      }
     } else {
-      T1_AASetLevel(T1_AA_LOW);
-      T1_AASetGrayValues(0, 1, 2, 3, 4);
+      T1_AANSetGrayValues(0, 1);
     }
-  } else {
-    T1_AANSetGrayValues(0, 1);
   }
+  ++t1libInitCount;
   ok = gTrue;
 }
 
 T1FontEngine::~T1FontEngine() {
-  T1_CloseLib();
+  //~ for multithreading: need a mutex here
+  if (--t1libInitCount == 0) {
+    T1_CloseLib();
+  }
 }
 
 //------------------------------------------------------------------------