From 67a1f817108a84ad83883e5d7a5fc0d522160f9a Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Thu, 26 Jan 2012 00:37:17 +1030 Subject: [PATCH] cairo: don't render text when text matrix is not invertable Emulates acroread behavior. Bug 43676 --- poppler/CairoOutputDev.cc | 12 ++++++++---- poppler/CairoOutputDev.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 7ef36df..758f1ca 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -147,6 +147,7 @@ CairoOutputDev::CairoOutputDev() { use_show_text_glyphs = gFalse; inType3Char = gFalse; t3_glyph_has_bbox = gFalse; + text_matrix_valid = gTrue; groupColorSpaceStack = NULL; maskStack = NULL; @@ -277,6 +278,8 @@ void CairoOutputDev::restoreState(GfxState *state) { if (cairo_shape) cairo_restore (cairo_shape); + text_matrix_valid = gTrue; + /* These aren't restored by cairo_restore() since we keep them in * the output device. */ updateFillColor(state); @@ -635,10 +638,12 @@ void CairoOutputDev::updateFont(GfxState *state) { invert_matrix = matrix; if (cairo_matrix_invert(&invert_matrix)) { warning("font matrix not invertible\n"); + text_matrix_valid = gFalse; return; } cairo_set_font_matrix (cairo, &matrix); + text_matrix_valid = gTrue; } void CairoOutputDev::alignStrokeCoords(double *x, double *y) @@ -1171,10 +1176,8 @@ void CairoOutputDev::endString(GfxState *state) // ignore empty strings and invisible text -- this is used by // Acrobat Capture render = state->getRender(); - if (render == 3 || glyphCount == 0) { - gfree(glyphs); - glyphs = NULL; - return; + if (render == 3 || glyphCount == 0 || !text_matrix_valid) { + goto finish; } if (!(render & 1) && !haveCSPattern) { @@ -1226,6 +1229,7 @@ void CairoOutputDev::endString(GfxState *state) } } +finish: gfree (glyphs); glyphs = NULL; if (use_show_text_glyphs) { diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h index b2e6fb2..768efc7 100644 --- a/poppler/CairoOutputDev.h +++ b/poppler/CairoOutputDev.h @@ -319,6 +319,7 @@ protected: GBool needFontUpdate; // set when the font needs to be updated GBool printing; GBool use_show_text_glyphs; + GBool text_matrix_valid; cairo_surface_t *surface; cairo_glyph_t *glyphs; int glyphCount; -- 1.7.5.4