diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index 2ca42a4..44ca05f 100644 --- a/poppler/SplashOutputDev.cc +++ b/poppler/SplashOutputDev.cc @@ -1195,6 +1195,7 @@ struct SplashTransparencyGroup { SplashBitmap *shape; GBool knockout; SplashCoord knockoutOpacity; + GBool fontAA; //----- saved state SplashBitmap *origBitmap; @@ -3819,6 +3820,7 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, // save state transpGroup->origBitmap = bitmap; transpGroup->origSplash = splash; + transpGroup->fontAA = fontEngine->getAA(); //~ this handles the blendingColorSpace arg for soft masks, but //~ not yet for transparency groups @@ -3850,6 +3852,9 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, bitmapTopDown, bitmap->getSeparationList()); splash = new Splash(bitmap, vectorAntialias, transpGroup->origSplash->getScreen()); + if (transpGroup->next != NULL && transpGroup->next->knockout) { + fontEngine->setAA(gFalse); + } splash->setThinLineMode(transpGroup->origSplash->getThinLineMode()); splash->setMinLineWidth(globalParams->getMinLineWidth()); //~ Acrobat apparently copies at least the fill and stroke colors, and @@ -3868,8 +3873,12 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, } else { SplashBitmap *shape = (knockout) ? transpGroup->shape : (transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->shape : transpGroup->origBitmap; + int shapeTx = (knockout) ? tx : + (transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->tx + tx : tx; + int shapeTy = (knockout) ? ty : + (transpGroup->next != NULL && transpGroup->next->shape != NULL) ? transpGroup->next->ty + ty : ty; splash->blitTransparent(transpGroup->origBitmap, tx, ty, 0, 0, w, h); - splash->setInNonIsolatedGroup(shape, tx, ty); + splash->setInNonIsolatedGroup(shape, shapeTx, shapeTy); } transpGroup->tBitmap = bitmap; state->shiftCTMAndClip(-tx, -ty); @@ -3906,8 +3915,9 @@ void SplashOutputDev::paintTransparencyGroup(GfxState *state, double *bbox) { : transpGroupStack->knockoutOpacity; splash->setOverprintMask(0xffffffff, gFalse); splash->composite(tBitmap, 0, 0, tx, ty, - tBitmap->getWidth(), tBitmap->getHeight(), - gFalse, !isolated, transpGroupStack->next != NULL && transpGroupStack->next->knockout, knockoutOpacity); + tBitmap->getWidth(), tBitmap->getHeight(), + gFalse, !isolated, transpGroupStack->next != NULL && transpGroupStack->next->knockout, knockoutOpacity); + fontEngine->setAA(transpGroupStack->fontAA); if (transpGroupStack->next != NULL && transpGroupStack->next->shape != NULL) { transpGroupStack->next->knockout = gTrue; } diff --git a/splash/Splash.cc b/splash/Splash.cc index 6bb0dfe..f9c4c37 100644 --- a/splash/Splash.cc +++ b/splash/Splash.cc @@ -446,39 +446,68 @@ void Splash::pipeRun(SplashPipe *pipe) { //----- read destination pixel + Guchar *destColorPtr; + if (pipe->shape && state->blendFunc && pipe->knockout && alpha0Bitmap != NULL) { + destColorPtr = alpha0Bitmap->data + (alpha0Y+pipe->y)*alpha0Bitmap->rowSize; + switch (bitmap->mode) { + case splashModeMono1: + destColorPtr += (alpha0X+pipe->x) / 8; + break; + case splashModeMono8: + destColorPtr += (alpha0X+pipe->x); + break; + case splashModeRGB8: + case splashModeBGR8: + destColorPtr += (alpha0X+pipe->x) * 3; + break; + case splashModeXBGR8: +#if SPLASH_CMYK + case splashModeCMYK8: +#endif + destColorPtr += (alpha0X+pipe->x) * 4; + break; +#if SPLASH_CMYK + case splashModeDeviceN8: + destColorPtr += (alpha0X+pipe->x) * (SPOT_NCOMPS + 4); + break; +#endif + } + } else { + destColorPtr = pipe->destColorPtr; + } switch (bitmap->mode) { case splashModeMono1: - cDest[0] = (*pipe->destColorPtr & pipe->destColorMask) ? 0xff : 0x00; + cDest[0] = (*destColorPtr & pipe->destColorMask) ? 0xff : 0x00; break; case splashModeMono8: - cDest[0] = *pipe->destColorPtr; + cDest[0] = *destColorPtr; break; case splashModeRGB8: - cDest[0] = pipe->destColorPtr[0]; - cDest[1] = pipe->destColorPtr[1]; - cDest[2] = pipe->destColorPtr[2]; + cDest[0] = destColorPtr[0]; + cDest[1] = destColorPtr[1]; + cDest[2] = destColorPtr[2]; break; case splashModeXBGR8: - cDest[0] = pipe->destColorPtr[2]; - cDest[1] = pipe->destColorPtr[1]; - cDest[2] = pipe->destColorPtr[0]; + cDest[0] = destColorPtr[2]; + cDest[1] = destColorPtr[1]; + cDest[2] = destColorPtr[0]; cDest[3] = 255; break; case splashModeBGR8: - cDest[0] = pipe->destColorPtr[2]; - cDest[1] = pipe->destColorPtr[1]; - cDest[2] = pipe->destColorPtr[0]; + cDest[0] = destColorPtr[2]; + cDest[1] = destColorPtr[1]; + cDest[2] = destColorPtr[0]; break; #if SPLASH_CMYK case splashModeCMYK8: - cDest[0] = pipe->destColorPtr[0]; - cDest[1] = pipe->destColorPtr[1]; - cDest[2] = pipe->destColorPtr[2]; - cDest[3] = pipe->destColorPtr[3]; + cDest[0] = destColorPtr[0]; + cDest[1] = destColorPtr[1]; + cDest[2] = destColorPtr[2]; + cDest[3] = destColorPtr[3]; break; case splashModeDeviceN8: for (cp = 0; cp < SPOT_NCOMPS + 4; cp++) - cDest[cp] = pipe->destColorPtr[cp]; + cDest[cp] = destColorPtr[cp]; break; #endif } diff --git a/splash/SplashFTFontEngine.h b/splash/SplashFTFontEngine.h index aa1ad5f..6206482 100644 --- a/splash/SplashFTFontEngine.h +++ b/splash/SplashFTFontEngine.h @@ -58,6 +58,8 @@ public: int *codeToGID, int codeToGIDLen); SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src, int *codeToGID, int codeToGIDLen, int faceIndex = 0); + GBool getAA() { return aa; } + void setAA(GBool aaA) { aa = aaA; } private: diff --git a/splash/SplashFontEngine.cc b/splash/SplashFontEngine.cc index 2e74f5a..0ac1cd0 100644 --- a/splash/SplashFontEngine.cc +++ b/splash/SplashFontEngine.cc @@ -288,6 +288,18 @@ SplashFontFile *SplashFontEngine::loadTrueTypeFont(SplashFontFileID *idA, return fontFile; } +#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H +GBool SplashFontEngine::getAA() { + return (ftEngine == NULL) ? gFalse : ftEngine->getAA(); +} + +void SplashFontEngine::setAA(GBool aa) { + if (ftEngine != NULL) { + ftEngine->setAA(aa); + } +} +#endif + SplashFont *SplashFontEngine::getFont(SplashFontFile *fontFile, SplashCoord *textMat, SplashCoord *ctm) { diff --git a/splash/SplashFontEngine.h b/splash/SplashFontEngine.h index 54926b4..6c3a5c0 100644 --- a/splash/SplashFontEngine.h +++ b/splash/SplashFontEngine.h @@ -89,6 +89,10 @@ public: // Note that the Splash y axis points downward. SplashFont *getFont(SplashFontFile *fontFile, SplashCoord *textMat, SplashCoord *ctm); +#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H + GBool getAA(); + void setAA(GBool aa); +#endif private: