diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 9477762..08cb65c 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -20,6 +20,7 @@ // Copyright (C) 2007, 2008 Brad Hards // Copyright (C) 2008 Koji Otani // Copyright (C) 2008 Hib Eris +// Copyright (C) 2009 Thomas Freitag // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -493,6 +494,8 @@ static char *prolog[] = { " pdfTextMat dtransform rmoveto } def", "/Tclip { pdfTextClipPath cvx exec clip newpath", " /pdfTextClipPath [] def } def", + "/Tclip* { pdfTextClipPath cvx exec eoclip newpath", + " /pdfTextClipPath [] def } def", "~1ns", "% Level 1 image operators", "~1n", @@ -990,6 +993,7 @@ PSOutputDev::PSOutputDev(const char *fileName, XRef *xrefA, Catalog *catalog, embFontList = NULL; customColors = NULL; haveTextClip = gFalse; + haveCSPattern = gFalse; t3String = NULL; forceRasterize = forceRasterizeA; @@ -1053,6 +1057,7 @@ PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, embFontList = NULL; customColors = NULL; haveTextClip = gFalse; + haveCSPattern = gFalse; t3String = NULL; forceRasterize = forceRasterizeA; @@ -4283,8 +4288,28 @@ void PSOutputDev::drawString(GfxState *state, GooString *s) { } } +void PSOutputDev::beginTextObject(GfxState *state) { + if (state->getFillColorSpace()->getMode() == csPattern) { + saveState(state); + haveTextClip = gTrue; + haveCSPattern = gTrue; + savedRender = state->getRender(); + state->setRender(7); + updateRender(state); + } +} + void PSOutputDev::endTextObject(GfxState *state) { - if (haveTextClip) { + if (haveCSPattern) { + writePS("Tclip*\n"); + haveTextClip = gFalse; + state->setRender(savedRender); + haveCSPattern = gFalse; + if (state->getFillColorSpace()->getMode() != csPattern) { + restoreState(state); + updateFillColor(state); + } + } else if (haveTextClip) { writePS("Tclip\n"); haveTextClip = gFalse; } @@ -4899,7 +4924,7 @@ void PSOutputDev::doImageL2(Object *ref, GfxImageColorMap *colorMap, colorMap ? colorMap->getBits() : 1); } - // decode + // decode if (colorMap) { writePS(" /Decode ["); if ((level == psLevel2Sep || level == psLevel3Sep) && @@ -5192,7 +5217,7 @@ void PSOutputDev::doImageL3(Object *ref, GfxImageColorMap *colorMap, colorMap ? colorMap->getBits() : 1); } - // decode + // decode if (colorMap) { writePS(" /Decode ["); if ((level == psLevel2Sep || level == psLevel3Sep) && diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h index e490110..b718473 100644 --- a/poppler/PSOutputDev.h +++ b/poppler/PSOutputDev.h @@ -17,6 +17,7 @@ // Copyright (C) 2005 Kristian Høgsberg // Copyright (C) 2006-2008 Albert Astals Cid // Copyright (C) 2007 Brad Hards +// Copyright (C) 2009 Thomas Freitag // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -125,6 +126,10 @@ public: // text in Type 3 fonts will be drawn with drawChar/drawString. virtual GBool interpretType3Chars() { return gFalse; } + // This device now supports text in pattern colorspace! + virtual GBool supportTextCSPattern(GfxState *state) + { return state->getFillColorSpace()->getMode() == csPattern; } + //----- header/trailer (used only if manualCtrl is true) // Write the document-level header. @@ -400,6 +405,9 @@ private: GBool haveTextClip; // set if text has been drawn with a // clipping render mode + GBool haveCSPattern; // set if text has been drawn with a + // clipping render mode because of pattern colorspace + int savedRender; // use if pattern colorspace GBool inType3Char; // inside a Type 3 CharProc GooString *t3String; // Type 3 content string