diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc index 50870cc..b7028f2 100644 --- a/poppler/Gfx.cc +++ b/poppler/Gfx.cc @@ -2169,9 +2169,12 @@ void Gfx::doShadingPatternFill(GfxShadingPattern *sPat, #if 1 //~tmp: turn off anti-aliasing temporarily GBool vaa = out->getVectorAntialias(); - if (vaa) { + if (vaa && !textHaveCSPattern ) { out->setVectorAntialias(gFalse); } + if (vaa && textHaveCSPattern ) { + out->setFillAntialias(gTrue); + } #endif // do shading type-specific operations @@ -3332,7 +3335,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,9 +3390,22 @@ 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) { + 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/OutputDev.h b/poppler/OutputDev.h index cdc74cf..433b533 100644 --- a/poppler/OutputDev.h +++ b/poppler/OutputDev.h @@ -301,6 +301,7 @@ public: #if 1 //~tmp: turn off anti-aliasing temporarily virtual GBool getVectorAntialias() { return gFalse; } virtual void setVectorAntialias(GBool /*vaa*/) {} + virtual void setFillAntialias(GBool /*vaa*/) {} #endif private: diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index 666ee18..6194dbd 100644 --- a/poppler/SplashOutputDev.cc +++ b/poppler/SplashOutputDev.cc @@ -1225,15 +1225,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; @@ -1621,7 +1612,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); } } @@ -1638,7 +1629,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) { @@ -1927,17 +1918,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) { @@ -3192,6 +3180,10 @@ GBool SplashOutputDev::getVectorAntialias() { void SplashOutputDev::setVectorAntialias(GBool vaa) { splash->setVectorAntialias(vaa); } + +void SplashOutputDev::setFillAntialias(GBool vaa) { + splash->setFillAntialias(vaa); +} #endif void SplashOutputDev::setFreeTypeHinting(GBool enable) diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h index 37b771a..ae8410f 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); @@ -221,6 +220,7 @@ public: #if 1 //~tmp: turn off anti-aliasing temporarily virtual GBool getVectorAntialias(); virtual void setVectorAntialias(GBool vaa); + virtual void setFillAntialias(GBool vaa); #endif void setFreeTypeHinting(GBool enable); @@ -246,8 +246,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; diff --git a/splash/Splash.cc b/splash/Splash.cc index 5e27d42..0c4dba6 100644 --- a/splash/Splash.cc +++ b/splash/Splash.cc @@ -821,6 +821,7 @@ Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA, bitmap = bitmapA; vectorAntialias = vectorAntialiasA; + fillAntialias = gFalse; state = new SplashState(bitmap->width, bitmap->height, vectorAntialias, screenParams); if (vectorAntialias) { @@ -844,6 +845,7 @@ Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA, bitmap = bitmapA; vectorAntialias = vectorAntialiasA; + fillAntialias = gFalse; state = new SplashState(bitmap->width, bitmap->height, vectorAntialias, screenA); if (vectorAntialias) { @@ -1595,13 +1597,16 @@ SplashError Splash::fillWithPattern(SplashPath *path, GBool eo, // draw the spans if (vectorAntialias) { - for (y = yMinI; y <= yMaxI; ++y) { + int yMax = (fillAntialias && yMaxI > yMinI) ? yMaxI - 1 : yMaxI; + for (y = yMinI; y <= yMax; ++y) { scanner->renderAALine(aaBuf, &x0, &x1, y); if (clipRes != splashClipAllInside) { state->clip->clipAALine(aaBuf, &x0, &x1, y); } drawAALine(&pipe, x0, x1, y); } + if (fillAntialias && yMaxI > yMinI) + drawAALine(&pipe, x0, x1, yMaxI); } else { for (y = yMinI; y <= yMaxI; ++y) { while (scanner->getNextSpan(y, &x0, &x1)) { diff --git a/splash/Splash.h b/splash/Splash.h index c9d57cc..bac48e0 100644 --- a/splash/Splash.h +++ b/splash/Splash.h @@ -246,7 +246,8 @@ public: #if 1 //~tmp: turn off anti-aliasing temporarily GBool getVectorAntialias() { return vectorAntialias; } - void setVectorAntialias(GBool vaa) { vectorAntialias = vaa; } + void setVectorAntialias(GBool vaa) { vectorAntialias = vaa; fillAntialias = gFalse; } + void setFillAntialias(GBool vaa) { fillAntialias = vaa; } #endif private: @@ -300,6 +301,7 @@ private: int modXMin, modYMin, modXMax, modYMax; SplashClipResult opClipRes; GBool vectorAntialias; + GBool fillAntialias; GBool debugMode; };