diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 5d4cb82..aa728f1 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -758,7 +758,36 @@ void CairoOutputDev::type3D1(GfxState *state, double wx, double wy, t3_glyph_has_bbox = gTrue; } +void CairoOutputDev::beginTextObject(GfxState *state) { + if (state->getFillColorSpace()->getMode() == csPattern) { + haveCSPattern = gTrue; + saveState(state); + savedRender = state->getRender(); + state->setRender(7); // Set clip to text path + } +} + void CairoOutputDev::endTextObject(GfxState *state) { + if (haveCSPattern) { + state->setRender(savedRender); + haveCSPattern = gFalse; + if (state->getFillColorSpace()->getMode() != csPattern) { + if (textClipPath) { + // clip the accumulated text path + cairo_append_path (cairo, textClipPath); + cairo_clip (cairo); + if (cairo_shape) { + cairo_append_path (cairo_shape, textClipPath); + cairo_clip (cairo_shape); + } + cairo_path_destroy (textClipPath); + textClipPath = NULL; + } + restoreState(state); + updateFillColor(state); + } + } + if (textClipPath) { // clip the accumulated text path cairo_append_path (cairo, textClipPath); @@ -1057,6 +1086,10 @@ void CairoOutputDev::clearSoftMask(GfxState * /*state*/) { mask = NULL; } +void CairoOutputDev::endMaskClip(GfxState *state) { + clearSoftMask(state); +} + void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool inlineImg) { diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h index 5ec2bf0..b7579b7 100644 --- a/poppler/CairoOutputDev.h +++ b/poppler/CairoOutputDev.h @@ -157,7 +157,20 @@ public: double dx, double dy, CharCode code, Unicode *u, int uLen); virtual void endType3Char(GfxState *state); + virtual void beginTextObject(GfxState *state); virtual void endTextObject(GfxState *state); + + // If current colorspace is pattern, + // does this device support text in pattern colorspace? + virtual GBool supportTextCSPattern(GfxState *state) { + return state->getFillColorSpace()->getMode() == csPattern; } + + // If current colorspace is pattern, + // need this device special handling for masks in pattern colorspace? + virtual GBool fillMaskCSPattern(GfxState * state) { + return state->getFillColorSpace()->getMode() == csPattern; } + + virtual void endMaskClip(GfxState *state); //----- grouping operators virtual void beginMarkedContent(char *name, Dict *properties); @@ -276,6 +289,10 @@ protected: cairo_pattern_t *mask; struct MaskStack *next; } *maskStack; + + GBool haveCSPattern; // set if text has been drawn with a + // clipping render mode because of pattern colorspace + int savedRender; // use if pattern colorspace }; //------------------------------------------------------------------------