summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVort <vvort@yandex.ru>2014-03-02 13:01:05 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-03-03 09:20:24 -0600
commit7963d2b0f6fe006c215607eda1c51acf1d7273b5 (patch)
tree3e84ecaaab44210b3d7267c57eb981585425fea2
parent0feaf45541ab82a3e1d8e644380734cb85152446 (diff)
fdo#40513 PDF Import: Hack: Replace incorrect values of font's ascent property
Change-Id: Ib7bd6e15fff5213b5d935c6f03f2c65ea3f6ca50 Reviewed-on: https://gerrit.libreoffice.org/8416 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx19
1 files changed, 18 insertions, 1 deletions
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 391f755f07ed..c5b145f0a00a 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -792,12 +792,29 @@ void PDFOutDev::drawChar(GfxState *state, double x, double y,
if( u == NULL )
return;
+ GfxFont* font = state->getFont();
+ double ascent = font->getAscent();
+ GooString* fontName = font->getName();
+
+ // Hackfix until incorrect ascent values are fixed in poppler (fdo#75667)
+ if ((fontName->cmpN("Arial", 5) == 0) &&
+ (ascent > 0.717) && (ascent < 0.719))
+ {
+ ascent = 0.905;
+ }
+ else if ((fontName->cmpN("Times New Roman", 15) == 0) &&
+ (ascent > 0.682) && (ascent < 0.684))
+ {
+ ascent = 0.891;
+ }
+
// normalize coordinates: correct from baseline-relative to upper
// left corner of glyphs
double x2(0.0), y2(0.0);
state->textTransformDelta( 0.0,
- state->getFont()->getAscent(),
+ ascent,
&x2, &y2 );
+
const double fFontSize(state->getFontSize());
x += x2*fFontSize;
y += y2*fFontSize;