From b0ac6cdb10284e3c463874e49ce6c0ca08bc0664 Mon Sep 17 00:00:00 2001 From: Jason Crain Date: Tue, 24 Mar 2015 00:06:34 -0500 Subject: [PATCH 1/2] Use width from /W array for WMode positioning --- poppler/GfxFont.cc | 34 +++++++++++----------------------- poppler/GfxFont.h | 1 + 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc index 3e9b7db..af54add 100644 --- a/poppler/GfxFont.cc +++ b/poppler/GfxFont.cc @@ -2207,30 +2207,14 @@ int GfxCIDFont::getNextChar(char *s, int len, CharCode *code, // horizontal if (cMap->getWMode() == 0) { - w = widths.defWidth; + w = getWidth(cid); h = vx = vy = 0; - if (widths.nExceps > 0 && cid >= widths.exceps[0].first) { - a = 0; - b = widths.nExceps; - // invariant: widths.exceps[a].first <= cid < widths.exceps[b].first - while (b - a > 1) { - m = (a + b) / 2; - if (widths.exceps[m].first <= cid) { - a = m; - } else { - b = m; - } - } - if (cid <= widths.exceps[a].last) { - w = widths.exceps[a].width; - } - } // vertical } else { w = 0; h = widths.defHeight; - vx = widths.defWidth / 2; + vx = getWidth(cid) / 2; vy = widths.defVY; if (widths.nExcepsV > 0 && cid >= widths.excepsV[0].first) { a = 0; @@ -2534,13 +2518,9 @@ int *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) { return codeToGID; } -double GfxCIDFont::getWidth (char* s, int len) { - int nUsed; +double GfxCIDFont::getWidth(CID cid) { double w; int a, b, m; - CharCode c; - - CID cid = cMap->getCID(s, len, &c, &nUsed); w = widths.defWidth; if (widths.nExceps > 0 && cid >= widths.exceps[0].first) { @@ -2562,6 +2542,14 @@ double GfxCIDFont::getWidth (char* s, int len) { return w; } +double GfxCIDFont::getWidth (char* s, int len) { + int nUsed; + CharCode c; + + CID cid = cMap->getCID(s, len, &c, &nUsed); + return getWidth(cid); +} + //------------------------------------------------------------------------ // GfxFontDict //------------------------------------------------------------------------ diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h index 1f01cc7..2dde9a2 100644 --- a/poppler/GfxFont.h +++ b/poppler/GfxFont.h @@ -401,6 +401,7 @@ private: int mapCodeToGID(FoFiTrueType *ff, int cmapi, Unicode unicode, GBool wmode); + double getWidth(CID cid); // Get width of a character. GooString *collection; // collection name CMap *cMap; // char code --> CID -- 2.1.4