From aaebdd6e708963c49ed1a3cbc1f54f45a3900650 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 69545 --- poppler/CairoOutputDev.cc | 14 +++++++++----- poppler/CairoOutputDev.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 1c67b5c..e4ae9d7 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -147,6 +147,7 @@ CairoOutputDev::CairoOutputDev() { inUncoloredPattern = gFalse; inType3Char = gFalse; t3_glyph_has_bbox = gFalse; + text_matrix_valid = gTrue; groupColorSpaceStack = NULL; maskStack = NULL; @@ -283,6 +284,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); @@ -657,11 +660,13 @@ void CairoOutputDev::updateFont(GfxState *state) { */ invert_matrix = matrix; if (cairo_matrix_invert(&invert_matrix)) { - error(errSyntaxWarning, -1, "font matrix not invertible\n"); + error(errSyntaxWarning, -1, "font matrix not invertible"); + text_matrix_valid = gFalse; return; } cairo_set_font_matrix (cairo, &matrix); + text_matrix_valid = gTrue; } /* Tolerance in pixels for checking if strokes are horizontal or vertical @@ -1250,10 +1255,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)) { @@ -1305,6 +1308,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 28f97fd..26e6c44 100644 --- a/poppler/CairoOutputDev.h +++ b/poppler/CairoOutputDev.h @@ -315,6 +315,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; -- 2.1.1