swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swftools-common] [Fix attached] Spaces disappear for some pdfs


From: Jonas Petersson
Subject: Re: [Swftools-common] [Fix attached] Spaces disappear for some pdfs
Date: Sat, 7 Mar 2009 09:07:14 +0100

Hi all (in particular Matthias),

Below is a simple fix that works for all PDFs I've had problems with.
Basically, it traps the combination of two bad cases:
1) Space is represented by null.
2) getWordSpace returns zero.
When this happens and the width of the current character (dx) is zero,
I approximate a space with getFontSize/3.

Presumably this doesn't happen much for most users or it would have
been more noise about it here, but is sure does in my case. I don't
know whether this is a "correct" fix, but it certainly looks a lot
more like how acrobat renders so I vote that this is applied. I've
utterly failed to get any response from the xpdf maintainer so my hope
is that it will be accepted to swftools in the interim.

                                            Best / Jonas

diff --git a/./lib/pdf/xpdf/Gfx.cc-org b/./lib/pdf/xpdf/Gfx.cc
index 04ddd70..f946c3c 100644
--- a/./lib/pdf/xpdf/Gfx.cc-org
+++ b/./lib/pdf/xpdf/Gfx.cc
@@ -3244,8 +3244,11 @@ void Gfx::doShowText(GString *s) {
        }
       } else {
        dx = dx * state->getFontSize() + state->getCharSpace();
-       if (n == 1 && *p == ' ') {
-         dx += state->getWordSpace();
+       if (n == 1 && (*p == ' ' || *p == 0)) {
+               double w=state->getWordSpace();
+               if (w==0 && dx==0)
+                       w=state->getFontSize()/3; // patch - but only
when dx is zero
+               dx += w;
        }
        dx *= state->getHorizScaling();
        dy *= state->getFontSize();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]