diff options
Diffstat (limited to 'poppler')
-rw-r--r-- | poppler/Gfx.cc | 2 | ||||
-rw-r--r-- | poppler/GfxFont.cc | 14 | ||||
-rw-r--r-- | poppler/GfxFont.h | 4 | ||||
-rw-r--r-- | poppler/GfxState.cc | 7 | ||||
-rw-r--r-- | poppler/TextOutputDev.cc | 1 |
5 files changed, 27 insertions, 1 deletions
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc index 8041004c..9ea0b625 100644 --- a/poppler/Gfx.cc +++ b/poppler/Gfx.cc @@ -2523,6 +2523,8 @@ void Gfx::opSetFont(Object args[], int numArgs) { args[1].getNum()); fflush(stdout); } + + font->incRefCnt(); state->setFont(font, args[1].getNum()); fontChanged = gTrue; } diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc index 0b16bc56..59053270 100644 --- a/poppler/GfxFont.cc +++ b/poppler/GfxFont.cc @@ -148,6 +148,7 @@ GfxFont::GfxFont(char *tagA, Ref idA, GooString *nameA) { family = NULL; stretch = StretchNotDefined; weight = WeightNotDefined; + refCnt = 1; } GfxFont::~GfxFont() { @@ -167,6 +168,15 @@ GfxFont::~GfxFont() { } } +void GfxFont::incRefCnt() { + refCnt++; +} + +void GfxFont::decRefCnt() { + if (--refCnt == 0) + delete this; +} + void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) { Object obj1, obj2, obj3, obj4; double t; @@ -457,6 +467,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GooString *nameA, Object obj1, obj2, obj3; int n, i, a, b, m; + refCnt = 1; type = typeA; ctu = NULL; @@ -1108,6 +1119,7 @@ GfxCIDFont::GfxCIDFont(XRef *xref, char *tagA, Ref idA, GooString *nameA, int c1, c2; int excepsSize, i, j, k, n; + refCnt = 1; ascent = 0.95; descent = -0.35; fontBBox[0] = fontBBox[1] = fontBBox[2] = fontBBox[3] = 0; @@ -1620,7 +1632,7 @@ GfxFontDict::~GfxFontDict() { for (i = 0; i < numFonts; ++i) { if (fonts[i]) { - delete fonts[i]; + fonts[i]->decRefCnt(); } } gfree(fonts); diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h index 15d1b9ae..80612ef6 100644 --- a/poppler/GfxFont.h +++ b/poppler/GfxFont.h @@ -115,6 +115,9 @@ public: GBool isOk() { return ok; } + void incRefCnt(); + void decRefCnt(); + // Get font tag. GooString *getTag() { return tag; } @@ -215,6 +218,7 @@ protected: double missingWidth; // "default" width double ascent; // max height above baseline double descent; // max depth below baseline + int refCnt; GBool ok; }; diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc index 62332922..9d54e1b4 100644 --- a/poppler/GfxState.cc +++ b/poppler/GfxState.cc @@ -21,6 +21,7 @@ #include "Array.h" #include "Page.h" #include "GfxState.h" +#include "GfxFont.h" #include "UGooString.h" //------------------------------------------------------------------------ @@ -3849,6 +3850,9 @@ GfxState::~GfxState() { if (saved) { delete saved; } + if (font) { + font->decRefCnt(); + } } // Used for copy(); @@ -3870,6 +3874,9 @@ GfxState::GfxState(GfxState *state) { lineDash = (double *)gmallocn(lineDashLength, sizeof(double)); memcpy(lineDash, state->lineDash, lineDashLength * sizeof(double)); } + if (font) + font->incRefCnt(); + saved = NULL; } diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc index 4c225141..22ce8b3e 100644 --- a/poppler/TextOutputDev.cc +++ b/poppler/TextOutputDev.cc @@ -3359,6 +3359,7 @@ void TextSelectionPainter::visitWord (TextWord *word, int begin, int end, state->setFillColor(glyph_color); out->updateFillColor(state); + word->font->gfxFont->incRefCnt(); state->setFont(word->font->gfxFont, word->fontSize); out->updateFont(state); |