]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/xpdf/XOutputDev.h
disable font embedding hack introduced on 2002-12-09 to fix build with
[evince.git] / pdf / xpdf / XOutputDev.h
index 57b2fe0913c0f09e42e1b3d84ca90dc760702ba6..dc6af01e88cd0ea9db9231174a5e41501474d005 100644 (file)
@@ -2,7 +2,7 @@
 //
 // XOutputDev.h
 //
-// Copyright 1996 Derek B. Noonburg
+// Copyright 1996-2002 Glyph & Cog, LLC
 //
 //========================================================================
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include "config.h"
+#include "Object.h"
+#include "CharTypes.h"
+#include "GlobalParams.h"
 #include "OutputDev.h"
 
 class GString;
+class GList;
 struct GfxRGB;
 class GfxFont;
 class GfxSubpath;
 class TextPage;
-class FontEncoding;
 class XOutputFontCache;
+struct T3FontCacheTag;
+class T3FontCache;
+struct T3GlyphStack;
+class XOutputDev;
 class Link;
 class Catalog;
+class DisplayFontParam;
+class UnicodeMap;
+class CharCodeToUnicode;
 
 #if HAVE_T1LIB_H
 class T1FontEngine;
@@ -35,7 +45,13 @@ class T1FontFile;
 class T1Font;
 #endif
 
-#if HAVE_FREETYPE_FREETYPE_H | HAVE_FREETYPE_H
+#if FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
+class FTFontEngine;
+class FTFontFile;
+class FTFont;
+#endif
+
+#if !FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
 class TTFontEngine;
 class TTFontFile;
 class TTFont;
@@ -45,7 +61,7 @@ class TTFont;
 // Constants
 //------------------------------------------------------------------------
 
-#define maxRGBCube 8           // max size of RGB color cube
+#define maxRGBCube 7           // max size of RGB color cube
 
 #define numTmpPoints 256       // number of XPoints in temporary array
 #define numTmpSubpaths 16      // number of elements in temporary arrays
@@ -60,68 +76,6 @@ struct BoundingRect {
   short yMin, yMax;            // min/max y values
 };
 
-//------------------------------------------------------------------------
-// Parameters
-//------------------------------------------------------------------------
-
-// Install a private colormap.
-extern GBool installCmap;
-
-// Size of RGB color cube.
-extern int rgbCubeSize;
-
-#if HAVE_T1LIB_H
-// Type of t1lib font rendering to use:
-//     "none"   -- don't use t1lib
-//     "plain"  -- t1lib, without anti-aliasing
-//     "low"    -- t1lib, with low-level anti-aliasing
-//     "high"   -- t1lib, with high-level anti-aliasing
-extern GString *t1libControl;
-#endif
-
-#if HAVE_FREETYPE_FREETYPE_H | HAVE_FREETYPE_H
-// Type of FreeType font rendering to use:
-//     "none"   -- don't use FreeType
-//     "plain"  -- FreeType, without anti-aliasing
-//     "aa"     -- FreeType, with anti-aliasing
-extern GString *freeTypeControl;
-#endif
-
-// If any of these are set, xpdf will use t1lib to render those font(s)
-// instead of using the X server font(s).
-extern GString *t1Courier;
-extern GString *t1CourierBold;
-extern GString *t1CourierBoldOblique;
-extern GString *t1CourierOblique;
-extern GString *t1Helvetica;
-extern GString *t1HelveticaBold;
-extern GString *t1HelveticaBoldOblique;
-extern GString *t1HelveticaOblique;
-extern GString *t1Symbol;
-extern GString *t1TimesBold;
-extern GString *t1TimesBoldItalic;
-extern GString *t1TimesItalic;
-extern GString *t1TimesRoman;
-extern GString *t1ZapfDingbats;
-
-// Use the EUC-JP encoding.
-extern GBool useEUCJP;
-
-#if JAPANESE_SUPPORT
-// X font name pattern to use for Japanese text.
-extern GString *japan12Font;
-#endif
-
-#if CHINESE_GB_SUPPORT
-// X font name pattern to use for Chinese GB text.
-extern GString *gb12Font;
-#endif
-
-#if CHINESE_CNS_SUPPORT
-// X font name pattern to use for Chinese CNS text.
-extern GString *cns13Font;
-#endif
-
 //------------------------------------------------------------------------
 // XOutputFont
 //------------------------------------------------------------------------
@@ -129,16 +83,19 @@ extern GString *cns13Font;
 class XOutputFont {
 public:
 
-  XOutputFont(GfxFont *gfxFont, double m11, double m12,
-             double m21, double m22, Display *display,
-             XOutputFontCache *cache);
+  XOutputFont(Ref *idA, double m11OrigA, double m12OrigA,
+             double m21OrigA, double m22OrigA,
+             double m11A, double m12A, double m21A, double m22A,
+             Display *displayA, XOutputDev *xOutA);
 
   virtual ~XOutputFont();
 
   // Does this font match the ID and transform?
-  GBool matches(Ref id1, double m11, double m12, double m21, double m22)
-    { return id.num == id1.num && id.gen == id1.gen &&
-            m11 == tm11 && m12 == tm12 && m21 == tm21 && m22 == tm22; }
+  GBool matches(Ref *idA, double m11OrigA, double m12OrigA,
+               double m21OrigA, double m22OrigA)
+    { return id.num == idA->num && id.gen == idA->gen &&
+            m11Orig == m11OrigA && m12Orig == m12OrigA &&
+            m21Orig == m21OrigA && m22Orig == m22OrigA; }
 
   // Was font created successfully?
   virtual GBool isOk() = 0;
@@ -146,21 +103,29 @@ public:
   // Update <gc> with this font.
   virtual void updateGC(GC gc) = 0;
 
-  // Draw character <c> at <x>,<y>.
+  // Draw character <c>/<u> at <x>,<y> (in device space).
   virtual void drawChar(GfxState *state, Pixmap pixmap, int w, int h,
-                       GC gc, double x, double y, int c) = 0;
+                       GC gc, GfxRGB *rgb,
+                       double x, double y, double dx, double dy,
+                       CharCode c, Unicode *u, int uLen) = 0;
 
-  // Does this font use hex char codes?
-  GBool isHex() { return hex; }
+  // Returns true if this XOutputFont subclass provides the
+  // getCharPath function.
+  virtual GBool hasGetCharPath() { return gFalse; }
+
+  // Add the character outline for <c>/<u> to the current path.
+  virtual void getCharPath(GfxState *state,
+                          CharCode c, Unicode *u, int ulen);
 
 protected:
 
   Ref id;                      // font ID
-  double tm11, tm12,           // original transform matrix
-         tm21, tm22;
+  double m11Orig, m12Orig,     // original transform matrix
+         m21Orig, m22Orig;
+  double m11, m12, m21, m22;   // actual transform matrix (possibly
+                               //   modified for font substitution)
   Display *display;            // X display
-  GBool hex;                   // subsetted font with hex char codes
-                               //   (this flag is used for text output)
+  XOutputDev *xOut;
 };
 
 #if HAVE_T1LIB_H
@@ -171,9 +136,12 @@ protected:
 class XOutputT1Font: public XOutputFont {
 public:
 
-  XOutputT1Font(GfxFont *gfxFont, GString *pdfBaseFont,
-               double m11, double m12, double m21, double m22,
-               Display *display, XOutputFontCache *cache);
+  XOutputT1Font(Ref *idA, T1FontFile *fontFileA,
+               double m11OrigA, double m12OrigA,
+               double m21OrigA, double m22OrigA,
+               double m11A, double m12A,
+               double m21A, double m22A,
+               Display *displayA, XOutputDev *xOutA);
 
   virtual ~XOutputT1Font();
 
@@ -183,18 +151,72 @@ public:
   // Update <gc> with this font.
   virtual void updateGC(GC gc);
 
-  // Draw character <c> at <x>,<y>.
+  // Draw character <c>/<u> at <x>,<y>.
   virtual void drawChar(GfxState *state, Pixmap pixmap, int w, int h,
-                       GC gc, double x, double y, int c);
+                       GC gc, GfxRGB *rgb,
+                       double x, double y, double dx, double dy,
+                       CharCode c, Unicode *u, int uLen);
+
+  // Returns true if this XOutputFont subclass provides the
+  // getCharPath function.
+  virtual GBool hasGetCharPath() { return gTrue; }
+
+  // Add the character outline for <c>/<u> to the current path.
+  virtual void getCharPath(GfxState *state,
+                          CharCode c, Unicode *u, int ulen);
 
 private:
 
   T1FontFile *fontFile;
   T1Font *font;
 };
-#endif
+#endif // HAVE_T1LIB_H
 
-#if HAVE_FREETYPE_FREETYPE_H | HAVE_FREETYPE_H
+#if FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
+//------------------------------------------------------------------------
+// XOutputFTFont
+//------------------------------------------------------------------------
+
+class XOutputFTFont: public XOutputFont {
+public:
+
+  XOutputFTFont(Ref *idA, FTFontFile *fontFileA,
+               double m11OrigA, double m12OrigA,
+               double m21OrigA, double m22OrigA,
+               double m11A, double m12A,
+               double m21A, double m22A,
+               Display *displayA, XOutputDev *xOutA);
+
+  virtual ~XOutputFTFont();
+
+  // Was font created successfully?
+  virtual GBool isOk();
+
+  // Update <gc> with this font.
+  virtual void updateGC(GC gc);
+
+  // Draw character <c>/<u> at <x>,<y>.
+  virtual void drawChar(GfxState *state, Pixmap pixmap, int w, int h,
+                       GC gc, GfxRGB *rgb,
+                       double x, double y, double dx, double dy,
+                       CharCode c, Unicode *u, int uLen);
+
+  // Returns true if this XOutputFont subclass provides the
+  // getCharPath function.
+  virtual GBool hasGetCharPath() { return gTrue; }
+
+  // Add the character outline for <c>/<u> to the current path.
+  virtual void getCharPath(GfxState *state,
+                          CharCode c, Unicode *u, int ulen);
+
+private:
+
+  FTFontFile *fontFile;
+  FTFont *font;
+};
+#endif // FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
+
+#if !FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
 //------------------------------------------------------------------------
 // XOutputTTFont
 //------------------------------------------------------------------------
@@ -202,9 +224,12 @@ private:
 class XOutputTTFont: public XOutputFont {
 public:
 
-  XOutputTTFont(GfxFont *gfxFont, double m11, double m12,
-               double m21, double m22, Display *display,
-               XOutputFontCache *cache);
+  XOutputTTFont(Ref *idA, TTFontFile *fontFileA,
+               double m11OrigA, double m12OrigA,
+               double m21OrigA, double m22OrigA,
+               double m11A, double m12A,
+               double m21A, double m22A,
+               Display *displayA, XOutputDev *xOutA);
 
   virtual ~XOutputTTFont();
 
@@ -214,32 +239,34 @@ public:
   // Update <gc> with this font.
   virtual void updateGC(GC gc);
 
-  // Draw character <c> at <x>,<y>.
+  // Draw character <c>/<u> at <x>,<y>.
   virtual void drawChar(GfxState *state, Pixmap pixmap, int w, int h,
-                       GC gc, double x, double y, int c);
+                       GC gc, GfxRGB *rgb,
+                       double x, double y, double dx, double dy,
+                       CharCode c, Unicode *u, int uLen);
 
 private:
 
   TTFontFile *fontFile;
   TTFont *font;
 };
-#endif
+#endif // !FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
 
 //------------------------------------------------------------------------
-// XOutputServerFont
+// XOutputServer8BitFont
 //------------------------------------------------------------------------
 
-class XOutputServerFont: public XOutputFont {
+class XOutputServer8BitFont: public XOutputFont {
 public:
 
-  XOutputServerFont(GfxFont *gfxFont, char *fontNameFmt,
-                   FontEncoding *encoding,
-                   double m11, double m12, double m21, double m22,
-                   double size, double ntm11, double ntm12,
-                   double ntm21, double ntm22,
-                   Display *display, XOutputFontCache *cache);
+  XOutputServer8BitFont(Ref *idA, GString *xlfdFmt,
+                       UnicodeMap *xUMapA, CharCodeToUnicode *fontUMap,
+                       double m11OrigA, double m12OrigA,
+                       double m21OrigA, double m22OrigA,
+                       double m11A, double m12A, double m21A, double m22A,
+                       Display *displayA, XOutputDev *xOutA);
 
-  virtual ~XOutputServerFont();
+  virtual ~XOutputServer8BitFont();
 
   // Was font created successfully?
   virtual GBool isOk();
@@ -247,15 +274,51 @@ public:
   // Update <gc> with this font.
   virtual void updateGC(GC gc);
 
-  // Draw character <c> at <x>,<y>.
+  // Draw character <c>/<u> at <x>,<y>.
   virtual void drawChar(GfxState *state, Pixmap pixmap, int w, int h,
-                       GC gc, double x, double y, int c);
+                       GC gc, GfxRGB *rgb,
+                       double x, double y, double dx, double dy,
+                       CharCode c, Unicode *u, int uLen);
 
 private:
 
   XFontStruct *xFont;          // the X font
-  Gushort map[256];            // forward map (PDF code -> font code)
-  Guchar revMap[256];          // reverese map (font code -> PDF code)
+  Gushort map[256];            // forward map (char code -> X font code)
+  UnicodeMap *xUMap;
+};
+
+//------------------------------------------------------------------------
+// XOutputServer16BitFont
+//------------------------------------------------------------------------
+
+class XOutputServer16BitFont: public XOutputFont {
+public:
+
+  XOutputServer16BitFont(Ref *idA, GString *xlfdFmt,
+                        UnicodeMap *xUMapA, CharCodeToUnicode *fontUMap,
+                        double m11OrigA, double m12OrigA,
+                        double m21OrigA, double m22OrigA,
+                        double m11A, double m12A, double m21A, double m22A,
+                        Display *displayA, XOutputDev *xOutA);
+
+  virtual ~XOutputServer16BitFont();
+
+  // Was font created successfully?
+  virtual GBool isOk();
+
+  // Update <gc> with this font.
+  virtual void updateGC(GC gc);
+
+  // Draw character <c>/<u> at <x>,<y>.
+  virtual void drawChar(GfxState *state, Pixmap pixmap, int w, int h,
+                       GC gc, GfxRGB *rgb,
+                       double x, double y, double dx, double dy,
+                       CharCode c, Unicode *u, int uLen);
+
+private:
+
+  XFontStruct *xFont;          // the X font
+  UnicodeMap *xUMap;
 };
 
 //------------------------------------------------------------------------
@@ -263,15 +326,37 @@ private:
 //------------------------------------------------------------------------
 
 #if HAVE_T1LIB_H
-struct XOutputT1FontFile {
+class XOutputT1FontFile {
+public:
+  XOutputT1FontFile(int numA, int genA, GBool substA, T1FontFile *fontFileA)
+    { num = numA; gen = genA; subst = substA; fontFile = fontFileA; }
+  ~XOutputT1FontFile();
   int num, gen;
+  GBool subst;
   T1FontFile *fontFile;
 };
 #endif
 
-#if HAVE_FREETYPE_FREETYPE_H | HAVE_FREETYPE_H
-struct XOutputTTFontFile {
+#if FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
+class XOutputFTFontFile {
+public:
+  XOutputFTFontFile(int numA, int genA, GBool substA, FTFontFile *fontFileA)
+    { num = numA; gen = genA; subst = substA; fontFile = fontFileA; }
+  ~XOutputFTFontFile();
+  int num, gen;
+  GBool subst;
+  FTFontFile *fontFile;
+};
+#endif
+
+#if !FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
+class XOutputTTFontFile {
+public:
+  XOutputTTFontFile(int numA, int genA, GBool substA, TTFontFile *fontFileA)
+    { num = numA; gen = genA; subst = substA; fontFile = fontFileA; }
+  ~XOutputTTFontFile();
   int num, gen;
+  GBool subst;
   TTFontFile *fontFile;
 };
 #endif
@@ -280,7 +365,10 @@ class XOutputFontCache {
 public:
 
   // Constructor.
-  XOutputFontCache(Display *display, Guint depth);
+  XOutputFontCache(Display *displayA, Guint depthA,
+                  XOutputDev *xOutA,
+                  FontRastControl t1libControlA,
+                  FontRastControl freetypeControlA);
 
   // Destructor.
   ~XOutputFontCache();
@@ -293,58 +381,84 @@ public:
                Gulong *colors, int numColors);
 
   // Get a font.  This creates a new font if necessary.
-  XOutputFont *getFont(GfxFont *gfxFont, double m11, double m12,
+  XOutputFont *getFont(XRef *xref, GfxFont *gfxFont, double m11, double m12,
                       double m21, double m22);
 
-#if HAVE_T1LIB_H
-  // Get a t1lib font file.
-  T1FontFile *getT1Font(GfxFont *gfxFont, GString *pdfBaseFont);
-
-  // Use anti-aliased Type 1 fonts?
-  GBool getT1libAA() { return t1libAA; }
-#endif
-
-#if HAVE_FREETYPE_FREETYPE_H | HAVE_FREETYPE_H
-  // Get a FreeType font file.
-  TTFontFile *getTTFont(GfxFont *gfxFont);
-#endif
-
 private:
 
   void delFonts();
   void clear();
+  XOutputFont *tryGetFont(XRef *xref, DisplayFontParam *dfp, GfxFont *gfxFont,
+                         double m11Orig, double m12Orig,
+                         double m21Orig, double m22Orig,
+                         double m11, double m12, double m21, double m22,
+                         GBool subst);
+#if HAVE_T1LIB_H
+  XOutputFont *tryGetT1Font(XRef *xref, GfxFont *gfxFont,
+                           double m11, double m12, double m21, double m22);
+  XOutputFont *tryGetT1FontFromFile(XRef *xref, GString *fileName,
+                                   GfxFont *gfxFont,
+                                   double m11Orig, double m12Orig,
+                                   double m21Orig, double m22Orig,
+                                   double m11, double m12,
+                                   double m21, double m22, GBool subst);
+#endif
+#if FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
+  XOutputFont *tryGetFTFont(XRef *xref, GfxFont *gfxFont,
+                           double m11, double m12, double m21, double m22);
+  XOutputFont *tryGetFTFontFromFile(XRef *xref, GString *fileName,
+                                   GfxFont *gfxFont,
+                                   double m11Orig, double m12Orig,
+                                   double m21Orig, double m22Orig,
+                                   double m11, double m12,
+                                   double m21, double m22, GBool subst);
+#endif
+#if !FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
+  XOutputFont *tryGetTTFont(XRef *xref, GfxFont *gfxFont,
+                           double m11, double m12, double m21, double m22);
+  XOutputFont *tryGetTTFontFromFile(XRef *xref, GString *fileName,
+                                   GfxFont *gfxFont,
+                                   double m11Orig, double m12Orig,
+                                   double m21Orig, double m22Orig,
+                                   double m11, double m12,
+                                   double m21, double m22, GBool subst);
+#endif
+  XOutputFont *tryGetServerFont(GString *xlfd, GString *encodingName,
+                               GfxFont *gfxFont,
+                               double m11Orig, double m12Orig,
+                               double m21Orig, double m22Orig,
+                               double m11, double m12,
+                               double m21, double m22);
 
   Display *display;            // X display pointer
+  XOutputDev *xOut;
   Guint depth;                 // pixmap depth
 
+  XOutputFont *
+    fonts[xOutFontCacheSize];
+  int nFonts;
+
 #if HAVE_T1LIB_H
-  GBool useT1lib;              // if false, t1lib is not used at all
-  GBool t1libAA;               // true for anti-aliased fonts
-  GBool t1libAAHigh;           // low or high-level anti-aliasing
+  FontRastControl t1libControl;        // t1lib settings
   T1FontEngine *t1Engine;      // Type 1 font engine
-  XOutputT1Font *              // Type 1 fonts in reverse-LRU order
-    t1Fonts[t1FontCacheSize];
-  int nT1Fonts;                        // number of valid entries in t1Fonts[]
-  XOutputT1FontFile *          // list of Type 1 font files
-    t1FontFiles;
-  int t1FontFilesSize;         // size of t1FontFiles array
+  GList *t1FontFiles;          // list of Type 1 font files
+                               //   [XOutputT1FontFile]
 #endif
 
-#if HAVE_FREETYPE_FREETYPE_H | HAVE_FREETYPE_H
-  GBool useFreeType;           // if false, FreeType is not used at all
-  GBool freeTypeAA;            // true for anti-aliased fonts
+#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+  FontRastControl              // FreeType settings
+    freetypeControl;
+#endif
+#if FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
+  FTFontEngine *ftEngine;      // FreeType font engine
+  GList *ftFontFiles;          // list of FreeType font files
+                               //   [XOutputFTFontFile]
+#endif
+#if !FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
   TTFontEngine *ttEngine;      // TrueType font engine
-  XOutputTTFont *              // TrueType fonts in reverse-LRU order
-    ttFonts[ttFontCacheSize];
-  int nTTFonts;                        // number of valid entries in ttFonts[]
-  XOutputTTFontFile *          // list of TrueType font files
-    ttFontFiles;
-  int ttFontFilesSize;         // size of ttFontFiles array
+  GList *ttFontFiles;          // list of TrueType font files
+                               //   [XOutputTTFontFile]
 #endif
-
-  XOutputServerFont *          // X server fonts in reverse-LRU order
-    serverFonts[serverFontCacheSize];
-  int nServerFonts;            // number of valid entries in serverFonts[]
 };
 
 //------------------------------------------------------------------------
@@ -366,8 +480,10 @@ class XOutputDev: public OutputDev {
 public:
 
   // Constructor.
-  XOutputDev(Display *display1, Pixmap pixmap1, Guint depth1,
-            Colormap colormap, unsigned long paperColor);
+  XOutputDev(Display *displayA, Pixmap pixmapA, Guint depthA,
+            Colormap colormapA, GBool reverseVideoA,
+            unsigned long paperColor, GBool installCmap,
+            int rgbCubeSize);
 
   // Destructor.
   virtual ~XOutputDev();
@@ -381,6 +497,10 @@ public:
   // Does this device use drawChar() or drawString()?
   virtual GBool useDrawChar() { return gTrue; }
 
+  // Does this device use beginType3Char/endType3Char?  Otherwise,
+  // text in Type 3 fonts will be drawn with drawChar/drawString.
+  virtual GBool interpretType3Chars() { return gTrue; }
+
   //----- initialization and control
 
   // Start a page.
@@ -425,9 +545,12 @@ public:
   virtual void beginString(GfxState *state, GString *s);
   virtual void endString(GfxState *state);
   virtual void drawChar(GfxState *state, double x, double y,
-                       double dx, double dy, Guchar c);
-  virtual void drawChar16(GfxState *state, double x, double y,
-                         double dx, double dy, int c);
+                       double dx, double dy,
+                       double originX, double originY,
+                       CharCode code, Unicode *u, int uLen);
+  virtual GBool beginType3Char(GfxState *state,
+                              CharCode code, Unicode *u, int uLen);
+  virtual void endType3Char(GfxState *state);
 
   //----- image drawing
   virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
@@ -435,24 +558,31 @@ public:
                             GBool inlineImg);
   virtual void drawImage(GfxState *state, Object *ref, Stream *str,
                         int width, int height, GfxImageColorMap *colorMap,
-                        GBool inlineImg);
+                        int *maskColors, GBool inlineImg);
+
+  //----- Type 3 font operators
+  virtual void type3D0(GfxState *state, double wx, double wy);
+  virtual void type3D1(GfxState *state, double wx, double wy,
+                      double llx, double lly, double urx, double ury);
 
   //----- special access
 
   // Called to indicate that a new PDF document has been loaded.
-  void startDoc();
+  void startDoc(XRef *xrefA);
 
   // Find a string.  If <top> is true, starts looking at <xMin>,<yMin>;
   // otherwise starts looking at top of page.  If <bottom> is true,
   // stops looking at <xMax>,<yMax>; otherwise stops looking at bottom
   // of page.  If found, sets the text bounding rectange and returns
   // true; otherwise returns false.
-  GBool findText(char *s, GBool top, GBool bottom,
+  GBool findText(Unicode *s, int len, GBool top, GBool bottom,
                 int *xMin, int *yMin, int *xMax, int *yMax);
 
   // Get the text which is inside the specified rectangle.
   GString *getText(int xMin, int yMin, int xMax, int yMax);
 
+  GBool isReverseVideo() { return reverseVideo; }
+
 protected:
 
   // Update pixmap ID after a page change.
@@ -461,6 +591,7 @@ protected:
 
 private:
 
+  XRef *xref;                  // the xref table for this PDF file
   Display *display;            // X display pointer
   int screenNum;               // X screen number
   Pixmap pixmap;               // pixmap to draw into
@@ -478,6 +609,8 @@ private:
   Gulong                       // color cube
     colors[maxRGBCube * maxRGBCube * maxRGBCube];
   int numColors;               // size of color cube
+  double redMap[256];          // map pixel (from color cube) to red value
+  GBool reverseVideo;          // reverse video mode
   XPoint                       // temporary points array
     tmpPoints[numTmpPoints];
   int                          // temporary arrays for fill/clip
@@ -487,9 +620,13 @@ private:
   GfxFont *gfxFont;            // current PDF font
   XOutputFont *font;           // current font
   XOutputFontCache *fontCache; // font cache
+  T3FontCache *                        // Type 3 font cache
+    t3FontCache[xOutT3FontCacheSize];
+  int nT3Fonts;                        // number of valid entries in t3FontCache
+  T3GlyphStack *t3GlyphStack;  // Type 3 glyph context stack
   XOutputState *save;          // stack of saved states
+
   TextPage *text;              // text from the current page
-  GBool type3Warning;          // only show the Type 3 font warning once
 
   void updateLineAttrs(GfxState *state, GBool updateDash);
   void doFill(GfxState *state, int rule);
@@ -502,6 +639,9 @@ private:
               double x0, double y0, double x1, double y1,
               double x2, double y2, double x3, double y3);
   void addPoint(XPoint **points, int *size, int *k, int x, int y);
+  void drawType3Glyph(T3FontCache *t3Font,
+                     T3FontCacheTag *tag, Guchar *data,
+                     double x, double y, GfxRGB *color);
   Gulong findColor(GfxRGB *rgb);
   Gulong findColor(GfxRGB *x, GfxRGB *err);
 };