[PATCH] Allow multiple instances of CairoOutputDev to be created
Adrian Johnson
ajohnson at redneon.com
Fri Oct 31 05:14:41 PDT 2008
for the same document that shares the same CairoFontEngine.
---
poppler/CairoOutputDev.cc | 16 +++++++++++-----
poppler/CairoOutputDev.h | 4 +++-
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 03cc059..25335b7 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -114,6 +114,7 @@ CairoOutputDev::CairoOutputDev() {
}
fontEngine = NULL;
+ fontEngine_owner = gFalse;
glyphs = NULL;
fill_pattern = NULL;
stroke_pattern = NULL;
@@ -134,7 +135,7 @@ CairoOutputDev::CairoOutputDev() {
}
CairoOutputDev::~CairoOutputDev() {
- if (fontEngine) {
+ if (fontEngine_owner && fontEngine) {
delete fontEngine;
}
@@ -171,12 +172,17 @@ void CairoOutputDev::setCairo(cairo_t *cairo)
}
}
-void CairoOutputDev::startDoc(XRef *xrefA) {
+void CairoOutputDev::startDoc(XRef *xrefA, CairoFontEngine *parentFontEngine) {
xref = xrefA;
- if (fontEngine) {
- delete fontEngine;
+ if (parentFontEngine) {
+ fontEngine = parentFontEngine;
+ } else {
+ if (fontEngine) {
+ delete fontEngine;
+ }
+ fontEngine = new CairoFontEngine(ft_lib);
+ fontEngine_owner = gTrue;
}
- fontEngine = new CairoFontEngine(ft_lib);
}
void CairoOutputDev::startPage(int pageNum, GfxState *state) {
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 9a18613..27b39ed 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -207,7 +207,7 @@ public:
//----- special access
// Called to indicate that a new PDF document has been loaded.
- void startDoc(XRef *xrefA);
+ void startDoc(XRef *xrefA, CairoFontEngine *fontEngine = NULL);
GBool isReverseVideo() { return gFalse; }
@@ -229,6 +229,8 @@ protected:
static GBool ft_lib_initialized;
CairoFontEngine *fontEngine;
+ GBool fontEngine_owner;
+
cairo_t *cairo;
cairo_matrix_t orig_matrix;
GBool needFontUpdate; // set when the font needs to be updated
--
1.5.6.3
--------------090504070501070603020308
Content-Type: text/x-patch;
name="0004-Make-the-catalog-available-to-CairoFontEngine.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename*0="0004-Make-the-catalog-available-to-CairoFontEngine.patch"
More information about the poppler
mailing list