Skip to content

Commit

Permalink
merge type3 glyph handling from xpdf 3.04
Browse files Browse the repository at this point in the history
Fixes bug #96667
  • Loading branch information
Thomas Freitag authored and tsdgeos committed Nov 2, 2016
1 parent f43cb73 commit 6c01a48
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
28 changes: 23 additions & 5 deletions poppler/SplashOutputDev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,10 @@ T3FontCache::~T3FontCache() {
struct T3GlyphStack {
Gushort code; // character code

GBool haveDx; // set after seeing a d0/d1 operator
GBool doNotCache; // set if we see a gsave/grestore before
// the d0/d1

//----- cache info
T3FontCache *cache; // font cache for the current font
T3FontCacheTag *cacheTag; // pointer to cache tag for the glyph
Expand Down Expand Up @@ -1600,11 +1604,21 @@ void SplashOutputDev::endPage() {

void SplashOutputDev::saveState(GfxState *state) {
splash->saveState();
if (t3GlyphStack && !t3GlyphStack->haveDx) {
t3GlyphStack->doNotCache = gTrue;
error(errSyntaxWarning, -1,
"Save (q) operator before d0/d1 in Type 3 glyph");
}
}

void SplashOutputDev::restoreState(GfxState *state) {
splash->restoreState();
needFontUpdate = gTrue;
if (t3GlyphStack && !t3GlyphStack->haveDx) {
t3GlyphStack->doNotCache = gTrue;
error(errSyntaxWarning, -1,
"Restore (Q) operator before d0/d1 in Type 3 glyph");
}
}

void SplashOutputDev::updateAll(GfxState *state) {
Expand Down Expand Up @@ -2668,8 +2682,8 @@ GBool SplashOutputDev::beginType3Char(GfxState *state, double x, double y,
t3GlyphStack->cache = t3Font;
t3GlyphStack->cacheTag = NULL;
t3GlyphStack->cacheData = NULL;

haveT3Dx = gFalse;
t3GlyphStack->haveDx = gFalse;
t3GlyphStack->doNotCache = gFalse;

return gFalse;
}
Expand Down Expand Up @@ -2699,7 +2713,7 @@ void SplashOutputDev::endType3Char(GfxState *state) {
}

void SplashOutputDev::type3D0(GfxState *state, double wx, double wy) {
haveT3Dx = gTrue;
t3GlyphStack->haveDx = gTrue;
}

void SplashOutputDev::type3D1(GfxState *state, double wx, double wy,
Expand All @@ -2711,10 +2725,14 @@ void SplashOutputDev::type3D1(GfxState *state, double wx, double wy,
int i, j;

// ignore multiple d0/d1 operators
if (haveT3Dx) {
if (t3GlyphStack->haveDx) {
return;
}
t3GlyphStack->haveDx = gTrue;
// don't cache if we got a gsave/grestore before the d1
if (t3GlyphStack->doNotCache) {
return;
}
haveT3Dx = gTrue;

if (unlikely(t3GlyphStack == NULL)) {
error(errSyntaxWarning, -1, "t3GlyphStack was null in SplashOutputDev::type3D1");
Expand Down
1 change: 0 additions & 1 deletion poppler/SplashOutputDev.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ class SplashOutputDev: public OutputDev {
t3FontCache[splashOutT3FontCacheSize];
int nT3Fonts; // number of valid entries in t3FontCache
T3GlyphStack *t3GlyphStack; // Type 3 glyph context stack
GBool haveT3Dx; // set after seeing a d0/d1 operator

SplashFont *font; // current font
GBool needFontUpdate; // set when the font needs to be updated
Expand Down

0 comments on commit 6c01a48

Please sign in to comment.