diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc index 221caef..9d87b54 100644 --- a/poppler/Gfx.cc +++ b/poppler/Gfx.cc @@ -3332,7 +3332,7 @@ void Gfx::opBeginText(Object args[], int numArgs) { out->updateTextMat(state); out->updateTextPos(state); fontChanged = gTrue; - if (out->supportTextCSPattern(state)) { + if (!(state->getRender() & 4) && out->supportTextCSPattern(state)) { textHaveCSPattern = gTrue; } } @@ -3387,10 +3387,23 @@ void Gfx::opSetTextLeading(Object args[], int numArgs) { } void Gfx::opSetTextRender(Object args[], int numArgs) { + int rm = state->getRender(); state->setRender(args[0].getInt()); - if (args[0].getInt() == 7) { - textHaveCSPattern = gFalse; - } + if ((args[0].getInt() & 4) && textHaveCSPattern && drawText) { + GBool needFill = out->deviceHasTextClip(state); + out->endTextObject(state); + if (needFill) { + doPatternFill(gTrue); + } + out->restoreState(state); + out->beginTextObject(state); + out->updateTextMat(state); + out->updateTextPos(state); + textHaveCSPattern = gFalse; + } else if ((rm & 4) && !(args[0].getInt() & 4) && out->supportTextCSPattern(state) && drawText) { + out->beginTextObject(state); + textHaveCSPattern = gTrue; + } out->updateRender(state); } diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index 21d7be6..df8fb6f 100644 --- a/poppler/SplashOutputDev.cc +++ b/poppler/SplashOutputDev.cc @@ -1224,15 +1224,6 @@ void SplashOutputDev::updateFont(GfxState * /*state*/) { needFontUpdate = gTrue; } -void SplashOutputDev::updateRender(GfxState *state) { - int rm; - rm = state->getRender(); - if (rm == 7 && haveCSPattern) { - haveCSPattern = gFalse; - restoreState(state); - } -} - void SplashOutputDev::doUpdateFont(GfxState *state) { GfxFont *gfxFont; GfxFontType fontType; @@ -1620,7 +1611,7 @@ void SplashOutputDev::drawChar(GfxState *state, double x, double y, // fill if (!(render & 1)) { - if (!state->getFillColorSpace()->isNonMarking()) { + if (!haveCSPattern && !state->getFillColorSpace()->isNonMarking()) { splash->fillChar((SplashCoord)x, (SplashCoord)y, code, font); } } @@ -1637,7 +1628,7 @@ void SplashOutputDev::drawChar(GfxState *state, double x, double y, } // clip - if (render & 4) { + if (haveCSPattern || (render & 4)) { if ((path = font->getGlyphPath(code))) { path->offset((SplashCoord)x, (SplashCoord)y); if (textClipPath) { @@ -1926,17 +1917,14 @@ void SplashOutputDev::drawType3Glyph(T3FontCache *t3Font, } void SplashOutputDev::beginTextObject(GfxState *state) { - if (state->getFillColorSpace()->getMode() == csPattern) { + if (!(state->getRender() & 4) && state->getFillColorSpace()->getMode() == csPattern) { haveCSPattern = gTrue; saveState(state); - savedRender = state->getRender(); - state->setRender(7); } } void SplashOutputDev::endTextObject(GfxState *state) { if (haveCSPattern) { - state->setRender(savedRender); haveCSPattern = gFalse; if (state->getFillColorSpace()->getMode() != csPattern) { if (textClipPath) { diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h index 37b771a..adbd196 100644 --- a/poppler/SplashOutputDev.h +++ b/poppler/SplashOutputDev.h @@ -116,7 +116,6 @@ public: //----- update text state virtual void updateFont(GfxState *state); - virtual void updateRender(GfxState *state); //----- path painting virtual void stroke(GfxState *state); @@ -246,8 +245,7 @@ private: Guchar *alphaLine); GBool haveCSPattern; // set if text has been drawn with a - // clipping render mode because of pattern colorspace - int savedRender; // use if pattern colorspace + // clipping render mode because of pattern colorspace GBool keepAlphaChannel; // don't fill with paper color, keep alpha channel SplashColorMode colorMode;