[poppler] Branch 'xpdf303merge' - 2 commits - poppler/Lexer.cc splash/SplashFTFont.cc splash/SplashFTFont.h

Albert Astals Cid aacid at kemper.freedesktop.org
Thu Oct 27 14:34:13 PDT 2011


 poppler/Lexer.cc       |    2 -
 splash/SplashFTFont.cc |   70 ++++++++++++++++++++++++++++++++++++++++++++-----
 splash/SplashFTFont.h  |    2 -
 3 files changed, 66 insertions(+), 8 deletions(-)

New commits:
commit 8b0dfe9537082eaccd982530f1eddc2fcfc92f8e
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Oct 27 19:58:31 2011 +0200

    xpdf303: Use splashDist instead of splashSqrt and USE_FIXEDPOINT enhacements

diff --git a/splash/SplashFTFont.cc b/splash/SplashFTFont.cc
index 48df63b..9b5958c 100644
--- a/splash/SplashFTFont.cc
+++ b/splash/SplashFTFont.cc
@@ -62,27 +62,84 @@ SplashFTFont::SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA,
   enableSlightHinting(fontFileA->engine->enableSlightHinting)
 {
   FT_Face face;
-  double div;
+  int div;
   int x, y;
+#if USE_FIXEDPOINT
+  SplashCoord scale;
+#endif
 
   face = fontFileA->face;
   if (FT_New_Size(face, &sizeObj)) {
     return;
   }
   face->size = sizeObj;
-  size = splashSqrt(mat[2]*mat[2] + mat[3]*mat[3]);
-  if ((int)size < 1) {
+  size = splashRound(splashDist(0, 0, mat[2], mat[3]));
+  if (size < 1) {
     size = 1;
   }
-  if (FT_Set_Pixel_Sizes(face, 0, (int)size)) {
+  if (FT_Set_Pixel_Sizes(face, 0, size)) {
     return;
   }
   // if the textMat values are too small, FreeType's fixed point
   // arithmetic doesn't work so well
-  textScale = splashSqrt(textMat[2]*textMat[2] + textMat[3]*textMat[3]) / size;
+  textScale = splashDist(0, 0, textMat[2], textMat[3]) / size;
 
   div = face->bbox.xMax > 20000 ? 65536 : 1;
 
+#if USE_FIXEDPOINT
+  scale = (SplashCoord)1 / (SplashCoord)face->units_per_EM;
+
+  // transform the four corners of the font bounding box -- the min
+  // and max values form the bounding box of the transformed font
+  x = (int)(mat[0] * (scale * (face->bbox.xMin / div)) +
+	    mat[2] * (scale * (face->bbox.yMin / div)));
+  xMin = xMax = x;
+  y = (int)(mat[1] * (scale * (face->bbox.xMin / div)) +
+	    mat[3] * (scale * (face->bbox.yMin / div)));
+  yMin = yMax = y;
+  x = (int)(mat[0] * (scale * (face->bbox.xMin / div)) +
+	    mat[2] * (scale * (face->bbox.yMax / div)));
+  if (x < xMin) {
+    xMin = x;
+  } else if (x > xMax) {
+    xMax = x;
+  }
+  y = (int)(mat[1] * (scale * (face->bbox.xMin / div)) +
+	    mat[3] * (scale * (face->bbox.yMax / div)));
+  if (y < yMin) {
+    yMin = y;
+  } else if (y > yMax) {
+    yMax = y;
+  }
+  x = (int)(mat[0] * (scale * (face->bbox.xMax / div)) +
+	    mat[2] * (scale * (face->bbox.yMin / div)));
+  if (x < xMin) {
+    xMin = x;
+  } else if (x > xMax) {
+    xMax = x;
+  }
+  y = (int)(mat[1] * (scale * (face->bbox.xMax / div)) +
+	    mat[3] * (scale * (face->bbox.yMin / div)));
+  if (y < yMin) {
+    yMin = y;
+  } else if (y > yMax) {
+    yMax = y;
+  }
+  x = (int)(mat[0] * (scale * (face->bbox.xMax / div)) +
+	    mat[2] * (scale * (face->bbox.yMax / div)));
+  if (x < xMin) {
+    xMin = x;
+  } else if (x > xMax) {
+    xMax = x;
+  }
+  y = (int)(mat[1] * (scale * (face->bbox.xMax / div)) +
+	    mat[3] * (scale * (face->bbox.yMax / div)));
+  if (y < yMin) {
+    yMin = y;
+  } else if (y > yMax) {
+    yMax = y;
+  }
+#else // USE_FIXEDPOINT
   // transform the four corners of the font bounding box -- the min
   // and max values form the bounding box of the transformed font
   x = (int)((mat[0] * face->bbox.xMin + mat[2] * face->bbox.yMin) /
@@ -133,11 +190,12 @@ SplashFTFont::SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA,
   } else if (y > yMax) {
     yMax = y;
   }
+#endif // USE_FIXEDPOINT
   // This is a kludge: some buggy PDF generators embed fonts with
   // zero bounding boxes.
   if (xMax == xMin) {
     xMin = 0;
-    xMax = (int)size;
+    xMax = size;
   }
   if (yMax == yMin) {
     yMin = 0;
diff --git a/splash/SplashFTFont.h b/splash/SplashFTFont.h
index 157eff3..f49d7b1 100644
--- a/splash/SplashFTFont.h
+++ b/splash/SplashFTFont.h
@@ -70,7 +70,7 @@ private:
   FT_Matrix matrix;
   FT_Matrix textMatrix;
   SplashCoord textScale;
-  double size;
+  int size;
   GBool enableFreeTypeHinting;
   GBool enableSlightHinting;
 };
commit b021bce2583c8e1e3a4c129106d80e7a4e223600
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Oct 27 19:54:22 2011 +0200

    xpdf303: wops, make it compile

diff --git a/poppler/Lexer.cc b/poppler/Lexer.cc
index efdc076..f00b2b7 100644
--- a/poppler/Lexer.cc
+++ b/poppler/Lexer.cc
@@ -441,7 +441,7 @@ Object *Lexer::getObj(Object *obj, int objNum) {
       } else if (n == tokBufSize) {
 	error(errSyntaxError, getPos(), "Warning: name token is longer than what the specification says it can be");
 	*p = c;
-	s = new GString(tokBuf, n);
+	s = new GooString(tokBuf, n);
       } else {
 	s->append((char)c);
       }


More information about the poppler mailing list