[poppler] poppler/GfxFont.cc poppler/GfxFont.h

Albert Astals Cid aacid at kemper.freedesktop.org
Wed Mar 25 13:06:28 PDT 2015


 poppler/GfxFont.cc |   36 ++++++++++++------------------------
 poppler/GfxFont.h  |    2 ++
 2 files changed, 14 insertions(+), 24 deletions(-)

New commits:
commit 4bb2c9b98299f429752b4c60820cea31ef05f7e0
Author: Jason Crain <jason at aquaticape.us>
Date:   Wed Mar 25 21:04:19 2015 +0100

    Use width from W array for WMode positioning
    
    Bug #89621

diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 3e9b7db..81f5903 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -30,7 +30,7 @@
 // Copyright (C) 2012 Yi Yang <ahyangyi at gmail.com>
 // Copyright (C) 2012 Suzuki Toshiya <mpsuzuki at hiroshima-u.ac.jp>
 // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
-// Copyright (C) 2013, 2014 Jason Crain <jason at aquaticape.us>
+// Copyright (C) 2013-2015 Jason Crain <jason at aquaticape.us>
 // Copyright (C) 2014 Olly Betts <olly at survex.com>
 //
 // To see a description of the changes please see the Changelog file that
@@ -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..febb902 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -21,6 +21,7 @@
 // Copyright (C) 2007 Koji Otani <sho at bbr.jp>
 // Copyright (C) 2011 Axel StrĂ¼bing <axel.struebing at freenet.de>
 // Copyright (C) 2011, 2012, 2014 Adrian Johnson <ajohnson at redneon.com>
+// Copyright (C) 2015 Jason Crain <jason at aquaticape.us>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -401,6 +402,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


More information about the poppler mailing list