diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 179a494..defe1eb 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -125,7 +125,7 @@ static char *prolog[] = { "~1sn", "/pdfOpNames [", " /pdfFill /pdfStroke /pdfLastFill /pdfLastStroke", - " /pdfTextMat /pdfFontSize /pdfCharSpacing /pdfTextRender", + " /pdfTextMat /pdfFontSize /pdfCharSpacing /pdfTextRender /pdfPatternCS", " /pdfTextRise /pdfWordSpacing /pdfHorizScaling /pdfTextClipPath", "] def", "~123sn", @@ -157,6 +157,7 @@ static char *prolog[] = { " /pdfFontSize 0 def", " /pdfCharSpacing 0 def", " /pdfTextRender 0 def", + " /pdfPatternCS false def", " /pdfTextRise 0 def", " /pdfWordSpacing 0 def", " /pdfHorizScaling 1 def", @@ -397,7 +398,8 @@ static char *prolog[] = { " dup pdfHorizScaling mul exch matrix scale", " pdfTextMat matrix concatmatrix dup 4 0 put dup 5 0 put", " exch findfont exch makefont setfont } def", - "/Tr { /pdfTextRender exch def } def", + "/Tr { /pdfTextRender exch def } def", + "/Tp { /pdfPatternCS exch def } def", "/Ts { /pdfTextRise exch def } def", "/Tw { /pdfWordSpacing exch def } def", "/Tz { /pdfHorizScaling exch def } def", @@ -469,7 +471,7 @@ static char *prolog[] = { "/Tj1 {", " 0 pdfTextRise pdfTextMat dtransform rmoveto", " currentpoint 8 2 roll", - " pdfTextRender 1 and 0 eq {", + " pdfTextRender 1 and 0 eq pdfPatternCS not and {", " 6 copy awidthshow", " } if", " pdfTextRender 3 and dup 1 eq exch 2 eq or {", @@ -478,7 +480,7 @@ static char *prolog[] = { " currentfont /FontType get 3 eq { fCol } { sCol } ifelse", " false awcp currentpoint stroke moveto", " } if", - " pdfTextRender 4 and 0 ne {", + " pdfTextRender 4 and 0 ne pdfPatternCS or {", " 8 6 roll moveto", " false awcp", " /pdfTextClipPath [ pdfTextClipPath aload pop", @@ -3708,10 +3710,6 @@ void PSOutputDev::updateRender(GfxState *state) { int rm; rm = state->getRender(); - if (rm == 7 && haveCSPattern) { - haveCSPattern = gFalse; - restoreState(state); - } writePSFmt("{0:d} Tr\n", rm); rm &= 3; if (rm != 0 && rm != 3) { @@ -3804,10 +3802,15 @@ GBool PSOutputDev::tilingPatternFill(GfxState *state, Object *str, box.y2 = bbox[3]; gfx = new Gfx(xref, this, resDict, m_catalog, &box, NULL); writePS("/x {\n"); +#if 0 + // causes problems with page 5 of pdf of bug 2807 + // so remove it and use setcharwidth always if (paintType == 2) { writePSFmt("{0:.4g} 0 {1:.4g} {2:.4g} {3:.4g} {4:.4g} setcachedevice\n", xStep, bbox[0], bbox[1], bbox[2], bbox[3]); - } else { + } else +#endif + { if (x1 - 1 <= x0) { writePS("1 0 setcharwidth\n"); } else { @@ -4359,7 +4362,7 @@ void PSOutputDev::drawString(GfxState *state, GooString *s) { } delete s2; - if (state->getRender() & 4) { + if (state->getRender() & 4 || haveCSPattern) { haveTextClip = gTrue; } } @@ -4368,9 +4371,7 @@ void PSOutputDev::beginTextObject(GfxState *state) { if (state->getFillColorSpace()->getMode() == csPattern) { saveState(state); haveCSPattern = gTrue; - savedRender = state->getRender(); - state->setRender(7); - writePSFmt("{0:d} Tr\n", 7); + writePS("true Tp\n"); } } @@ -4379,7 +4380,6 @@ void PSOutputDev::endTextObject(GfxState *state) { if (haveTextClip) { writePS("Tclip*\n"); haveTextClip = gFalse; - state->setRender(savedRender); if (state->getFillColorSpace()->getMode() != csPattern) { double cxMin, cyMin, cxMax, cyMax; state->getClipBBox(&cxMin, &cyMin, &cxMax, &cyMax); @@ -4390,8 +4390,6 @@ void PSOutputDev::endTextObject(GfxState *state) { restoreState(state); updateFillColor(state); } - } else { - state->setRender(savedRender); } haveCSPattern = gFalse; } else if (haveTextClip) { diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h index 38c838c..9da2220 100644 --- a/poppler/PSOutputDev.h +++ b/poppler/PSOutputDev.h @@ -427,7 +427,6 @@ private: // 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