[poppler] [PATCH] fix CairoOutputDevice text clipping
Jeff Muizelaar
jeff at infidigm.net
Sun Jan 8 18:42:13 PST 2006
This patch fixes the following fixme in CairoOutputDevice.
// FIXME: This is quite right yet, we need to accumulate all
// glyphs within one text object before we clip. Right now this
// just add this one string.
It fixes it following a strategy similar to the one the Splash backend
does. textClipPath is used to store the appended path from each call to
endString(). The accumulated path is clipped in endTextObject.
--
poppler/CairoOutputDev.cc | 22 ++++++++++++++++++----
poppler/CairoOutputDev.h | 1 +
2 files changed, 19 insertions(+), 4 deletions(-)
ac2f3a50c44d8e401a6f3ed0b1c1bcd97b0920e3
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index a006385..c6525fe 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -57,6 +57,7 @@ CairoOutputDev::CairoOutputDev() {
stroke_pattern = NULL;
stroke_opacity = 1.0;
fill_opacity = 1.0;
+ textClipPath = NULL;
}
CairoOutputDev::~CairoOutputDev() {
@@ -411,12 +412,17 @@ void CairoOutputDev::endString(GfxState
// clip
if (render & 4) {
- // FIXME: This is quite right yet, we need to accumulate all
- // glyphs within one text object before we clip. Right now this
- // just add this one string.
LOG (printf ("clip string\n"));
+ // set up the clipping path
+ if (textClipPath) {
+ cairo_append_path (cairo, textClipPath);
+ cairo_path_destroy (textClipPath);
+ }
cairo_glyph_path (cairo, glyphs, glyphCount);
- cairo_clip (cairo);
+
+ // move the path into textClipPath
+ textClipPath = cairo_copy_path (cairo);
+ cairo_new_path (cairo);
}
gfree (glyphs);
@@ -440,6 +446,14 @@ void CairoOutputDev::type3D1(GfxState *s
}
void CairoOutputDev::endTextObject(GfxState *state) {
+ if (textClipPath) {
+ // clip the accumulated text path
+ cairo_append_path (cairo, textClipPath);
+ cairo_clip (cairo);
+ cairo_path_destroy (textClipPath);
+ textClipPath = NULL;
+ }
+
}
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index ab79046..78f77eb 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -150,6 +150,7 @@ protected:
cairo_surface_t *surface;
cairo_glyph_t *glyphs;
int glyphCount;
+ cairo_path_t *textClipPath;
};
#endif
More information about the poppler
mailing list