Kaydet (Commit) df54862e authored tarafından Vort's avatar Vort Kaydeden (comit) Caolán McNamara

fdo#85174 PDF Import: fix character positions without modifying poppler

Change-Id: I4ec6409e8fa13161c5cd37fcae2055b4bc5ecfd4
Reviewed-on: https://gerrit.libreoffice.org/14066Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 6acd5c45
......@@ -2628,10 +2628,6 @@ endif # ENABLE_VALGRIND
ifneq ($(SYSTEM_POPPLER),)
define gb_LinkTarget__use_poppler
$(call gb_LinkTarget_add_defs,$(1),\
-DSYSTEM_POPPLER_HEADERS \
)
$(call gb_LinkTarget_set_include,$(1),\
$(POPPLER_CFLAGS) \
$$(INCLUDE) \
......
......@@ -18,7 +18,6 @@ $(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 -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*/,
......@@ -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]),
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment