From df54862ec61c81a39b7ccfadc292b5bf859f45fa Mon Sep 17 00:00:00 2001 From: Vort Date: Wed, 21 Jan 2015 08:39:08 +0200 Subject: fdo#85174 PDF Import: fix character positions without modifying poppler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4ec6409e8fa13161c5cd37fcae2055b4bc5ecfd4 Reviewed-on: https://gerrit.libreoffice.org/14066 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- .../pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 28 +++++++++++++--------- .../pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx | 7 ------ 2 files changed, 17 insertions(+), 18 deletions(-) (limited to 'sdext') diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index e7853394506c..15454a4501b5 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -821,10 +821,12 @@ void PDFOutDev::eoClip(GfxState *state) @param dx - horizontal skip for character + horizontal skip for character (already scaled with font size) + + inter-char space: cursor is shifted by this amount for next char @param dy - vertical skip for character + vertical skip for character (zero for horizontal writing mode): + cursor is shifted by this amount for next char @param originX local offset of character (zero for horizontal writing mode). not @@ -834,23 +836,27 @@ 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. */ -#ifdef SYSTEM_POPPLER_HEADERS void PDFOutDev::drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode, int /*nBytes*/, Unicode *u, int uLen) -#else -void PDFOutDev::drawChar2(GfxState *state, double x, double y, - double dx, double dy, - double originX, double originY, - CharCode, int /*nBytes*/, Unicode *u, int uLen) -#endif { assert(state); if( u == NULL ) return; + double csdx = 0.0; + double csdy = 0.0; + if (state->getFont()->getWMode()) + csdy = state->getCharSpace(); + else + csdx = state->getCharSpace() * state->getHorizScaling(); + + double cstdx = 0.0; + double cstdy = 0.0; + state->textTransformDelta(csdx, csdy, &cstdx, &cstdy); + const double fontSize = state->getFontSize(); const double aPositionX(x-originX); @@ -860,8 +866,8 @@ void PDFOutDev::drawChar2(GfxState *state, double x, double y, printf( "drawChar %f %f %f %f %f %f %f %f %f ", normalize(aPositionX), normalize(aPositionY), - normalize(aPositionX + dx), - normalize(aPositionY + dy), + normalize(aPositionX + dx - cstdx), + normalize(aPositionY + dy - cstdy), normalize(pTextMat[0]), normalize(pTextMat[2]), normalize(pTextMat[1]), diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx index b8414c7fb69d..daba4454a4d8 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx @@ -220,17 +220,10 @@ namespace pdfi virtual void eoClip(GfxState *state) SAL_OVERRIDE; //----- text drawing -#ifdef SYSTEM_POPPLER_HEADERS virtual void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, Unicode *u, int uLen) SAL_OVERRIDE; -#else - 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; -#endif virtual void drawString(GfxState *state, GooString *s) SAL_OVERRIDE; virtual void endTextObject(GfxState *state) SAL_OVERRIDE; -- cgit