summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVort <vvort@yandex.ru>2015-01-20 08:48:39 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-01-20 13:55:04 +0000
commit7818c73445ad8e08e7ee51e2cc3a4b4d5a798ac4 (patch)
tree6dd9c136085f171dabed24e3320f9dbd80c11a37
parentd8915be647a85e6c20763febc28f015e6e11c688 (diff)
fdo#85174 PDF Import: fix character positions
Change-Id: I0aa75b6cb834341e47bbeeaa15d39387a8cb5240 Reviewed-on: https://gerrit.libreoffice.org/14029 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--external/poppler/UnpackedTarball_poppler.mk1
-rw-r--r--external/poppler/poppler-new-drawchar.patch.159
-rw-r--r--sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx8
-rw-r--r--sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx2
4 files changed, 64 insertions, 6 deletions
diff --git a/external/poppler/UnpackedTarball_poppler.mk b/external/poppler/UnpackedTarball_poppler.mk
index 3f9c9f857357..e2a6d4c77210 100644
--- a/external/poppler/UnpackedTarball_poppler.mk
+++ b/external/poppler/UnpackedTarball_poppler.mk
@@ -18,6 +18,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,poppler,\
external/poppler/poppler-nochecknew.patch.1 \
external/poppler/poppler-vs2013.patch.1 \
external/poppler/poppler-0.26.4-std-max.patch.1 \
+ external/poppler/poppler-new-drawchar.patch.1 \
))
# vim: set noet sw=4 ts=4:
diff --git a/external/poppler/poppler-new-drawchar.patch.1 b/external/poppler/poppler-new-drawchar.patch.1
new file mode 100644
index 000000000000..bc692f506977
--- /dev/null
+++ b/external/poppler/poppler-new-drawchar.patch.1
@@ -0,0 +1,59 @@
+diff -u a/poppler/Gfx.cc b/poppler/Gfx.cc
+--- a/poppler/Gfx.cc 2015-01-20 07:54:51.255889300 +0200
++++ b/poppler/Gfx.cc 2015-01-20 08:19:38.734968200 +0200
+@@ -4031,27 +4031,41 @@
+ n = font->getNextChar(p, len, &code,
+ &u, &uLen,
+ &dx, &dy, &originX, &originY);
++ dx2 = dx;
++ dy2 = dy;
+ if (wMode) {
+ dx *= state->getFontSize();
++ dx2 *= state->getFontSize();
+ dy = dy * state->getFontSize() + state->getCharSpace();
++ dy2 = dy2 * state->getFontSize();
+ if (n == 1 && *p == ' ') {
+ dy += state->getWordSpace();
++ dy2 += state->getWordSpace();
+ }
+ } else {
+ dx = dx * state->getFontSize() + state->getCharSpace();
++ dx2 = dx2 * state->getFontSize();
+ if (n == 1 && *p == ' ') {
+ dx += state->getWordSpace();
++ dx2 += state->getWordSpace();
+ }
+ dx *= state->getHorizScaling();
++ dx2 *= state->getHorizScaling();
+ dy *= state->getFontSize();
++ dy2 *= state->getFontSize();
+ }
+ state->textTransformDelta(dx, dy, &tdx, &tdy);
++ state->textTransformDelta(dx2, dy2, &ddx, &ddy);
+ originX *= state->getFontSize();
+ originY *= state->getFontSize();
+ state->textTransformDelta(originX, originY, &tOriginX, &tOriginY);
+ if (ocState)
++ {
++ out->drawChar2(state, state->getCurX() + riseX, state->getCurY() + riseY,
++ ddx, ddy, tOriginX, tOriginY, code, n, u, uLen);
+ out->drawChar(state, state->getCurX() + riseX, state->getCurY() + riseY,
+ tdx, tdy, tOriginX, tOriginY, code, n, u, uLen);
++ }
+ state->shift(tdx, tdy);
+ p += n;
+ len -= n;
+diff -u a/poppler/OutputDev.h b/poppler/OutputDev.h
+--- a/poppler/OutputDev.h 2014-04-26 18:37:22.000000000 +0300
++++ b/poppler/OutputDev.h 2015-01-20 08:20:22.321461200 +0200
+@@ -244,6 +244,10 @@
+ double /*dx*/, double /*dy*/,
+ double /*originX*/, double /*originY*/,
+ CharCode /*code*/, int /*nBytes*/, Unicode * /*u*/, int /*uLen*/) {}
++ virtual void drawChar2(GfxState * /*state*/, double /*x*/, double /*y*/,
++ double /*dx*/, double /*dy*/,
++ double /*originX*/, double /*originY*/,
++ CharCode /*code*/, int /*nBytes*/, Unicode * /*u*/, int /*uLen*/) {}
+ virtual void drawString(GfxState * /*state*/, GooString * /*s*/) {}
+ virtual GBool beginType3Char(GfxState * /*state*/, double /*x*/, double /*y*/,
+ double /*dx*/, double /*dy*/,
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index f25af8661c51..838ada552ef9 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -821,12 +821,10 @@ void PDFOutDev::eoClip(GfxState *state)
@param dx
- horizontal skip for character (already scaled with font size) +
- inter-char space: cursor is shifted by this amount for next char
+ horizontal skip for character
@param dy
- vertical skip for character (zero for horizontal writing mode):
- cursor is shifted by this amount for next char
+ vertical skip for character
@param originX
local offset of character (zero for horizontal writing mode). not
@@ -836,7 +834,7 @@ void PDFOutDev::eoClip(GfxState *state)
local offset of character (zero for horizontal writing mode). not
taken into account for output pos updates. Used for vertical writing.
*/
-void PDFOutDev::drawChar(GfxState *state, double x, double y,
+void PDFOutDev::drawChar2(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
CharCode, int /*nBytes*/, Unicode *u, int uLen)
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
index daba4454a4d8..a577e5ec9b42 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
@@ -220,7 +220,7 @@ namespace pdfi
virtual void eoClip(GfxState *state) SAL_OVERRIDE;
//----- text drawing
- virtual void drawChar(GfxState *state, double x, double y,
+ virtual void drawChar2(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
CharCode code, int nBytes, Unicode *u, int uLen) SAL_OVERRIDE;