On Sun, Jun 08, 2008 at 06:05:49PM +0930, Adrian Johnson wrote:
This pdf from the cairo test suite demonstrates the problem:
http://annarchy.freedesktop.org/~ajohnson/user-font-pdf-argb32-out.pdf
That pdf works correctly with the splash renderer so i don't see why
a patch on Gfx.cc is needed, i'd say a patch for the cairo renderer
is needed.
Attaching a new patch for the cairo renderer to fix the bug.
I'm now seeing a crash with some PDFs in evince, and reverting this
patch fixes them. The error I'm seeing is
evince: cairo-pattern.c:679: cairo_pattern_destroy: Assertion
`((*&(&pattern->ref_count)->ref_count) > 0)' failed.
My guess is that reference counts are not being updated on
fill_pattern/stroke_pattern when they are temporarily changed; if the
Type3 font happens to explicitly set the color, then the reference
counts can be corrupted.
Additionally, I believe it may be possible to have a Type3 font nested
inside another Type3 font, but using a single member variable to save
the old stroke color is not reentrant.
Fortunately, calls to beginType3Char/endType3Char are already wrapped in
calls to saveState/restoreState, so we don't need to save and restore
the stroke color in the Cairo backend--that will happen automatically.
This allows the code to be simplified.
We should still set the stroke pattern to the current fill pattern. Do
that, but with proper reference counting.
Patch is attached.
--Michael Vrable
From fe30a44f6526c2f409dbf50066f7f74a613cd920 Mon Sep 17 00:00:00 2001
From: Michael Vrable <[EMAIL PROTECTED]>
Date: Wed, 18 Jun 2008 11:24:05 -0700
Subject: [PATCH] Fix a crash in the cairo backend with Type 3 glyphs
Commit 86b7e8a3bee7 ("Ensure cairo renders Type 3 glyphs with only the fill
color") introduced a bug into the Cairo backend, causing evince to crash
with the message
evince: cairo-pattern.c:679: cairo_pattern_destroy: Assertion
`((*&(&pattern->ref_count)->ref_count) > 0)' failed.
Fix this by updating reference counts to the fill and stroke patterns when
modifying them in beginType3Char.
Simplify the code as well by not saving the old stroke pattern before
overriding it; this is already done since beginType3Char/endType3Char is
wrapped by calls to saveState/restoreState in Gfx::doShowText.
---
poppler/CairoOutputDev.cc | 4 ++--
poppler/CairoOutputDev.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 05fe1a8..7ae19a2 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -616,13 +616,13 @@ GBool CairoOutputDev::beginType3Char(GfxState *state, double x, double y,
cairo_set_matrix(cairo_shape, &orig_matrix);
cairo_transform(cairo_shape, &matrix);
}
- old_stroke_pattern = stroke_pattern;
+ cairo_pattern_destroy(stroke_pattern);
+ cairo_pattern_reference(fill_pattern);
stroke_pattern = fill_pattern;
return gFalse;
}
void CairoOutputDev::endType3Char(GfxState *state) {
- stroke_pattern = old_stroke_pattern;
cairo_restore (cairo);
if (cairo_shape) {
cairo_restore (cairo_shape);
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index f6f9e13..5d2b658 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -199,7 +199,7 @@ protected:
void doPath(cairo_t *cairo, GfxState *state, GfxPath *path);
GfxRGB fill_color, stroke_color;
- cairo_pattern_t *fill_pattern, *stroke_pattern, *old_stroke_pattern;
+ cairo_pattern_t *fill_pattern, *stroke_pattern;
double fill_opacity;
double stroke_opacity;
CairoFont *currentFont;
--
1.5.5.3
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler