[poppler] poppler/Gfx.cc poppler/GfxFont.cc

Jeff Muizelaar jrmuizel at kemper.freedesktop.org
Mon Oct 22 20:09:10 PDT 2007


 poppler/Gfx.cc     |    4 ++++
 poppler/GfxFont.cc |    4 ++++
 2 files changed, 8 insertions(+)

New commits:
commit 25b273db677815c8df11e52fe9df29fe857a8a88
Author: Jeff Muizelaar <jeff at infidigm.net>
Date:   Mon Oct 22 23:01:37 2007 -0400

    Unset the font if it doesn't exist or we can not load it properly
    
    Previously, the previous font stayed current and glyphs would be drawn using
    it. This resulted in random glyphs being chosen unless the encodings happened
    to match. Now, instead, we draw nothing which matches the behaviour of
    acroread.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index b86ab10..37c279e 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2968,6 +2968,10 @@ void Gfx::opSetFont(Object args[], int numArgs) {
   GfxFont *font;
 
   if (!(font = res->lookupFont(args[0].getName()))) {
+    // unsetting the font (drawing no text) is better than using the
+    // previous one and drawing random glyphs from it
+    state->setFont(NULL, args[1].getNum());
+    fontChanged = gTrue;
     return;
   }
   if (printCommands) {
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 63ac1c0..cce097f 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -1861,6 +1861,10 @@ GfxFontDict::GfxFontDict(XRef *xref, Ref *fontDictRef, Dict *fontDict) {
       fonts[i] = GfxFont::makeFont(xref, fontDict->getKey(i),
 				   r, obj2.getDict());
       if (fonts[i] && !fonts[i]->isOk()) {
+	// XXX: it may be meaningful to distinguish between
+	// NULL and !isOk() so that when we do lookups
+	// we can tell the difference between a missing font
+	// and a font that is just !isOk()
 	delete fonts[i];
 	fonts[i] = NULL;
       }


More information about the poppler mailing list