[poppler] poppler/splash: SplashFTFont.cc,1.3,1.4

Albert Astals Cid aacid at freedesktop.org
Sun Oct 16 07:30:18 PDT 2005


Update of /cvs/poppler/poppler/splash
In directory gabe:/tmp/cvs-serv26648/splash

Modified Files:
	SplashFTFont.cc 
Log Message:
Merge SplashFTFont.cc with xpdf 3.01 changes


Index: SplashFTFont.cc
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashFTFont.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- SplashFTFont.cc	16 Sep 2005 18:21:38 -0000	1.3
+++ SplashFTFont.cc	16 Oct 2005 14:30:16 -0000	1.4
@@ -12,6 +12,9 @@
 #pragma implementation
 #endif
 
+#include <ft2build.h>
+#include FT_OUTLINE_H
+#include FT_INTERNAL_OBJECTS_H // needed for FT_New_Size decl
 #include "goo/gmem.h"
 #include "SplashMath.h"
 #include "SplashGlyphBitmap.h"
@@ -20,9 +23,6 @@
 #include "SplashFTFontFile.h"
 #include "SplashFTFont.h"
 
-#include FT_OUTLINE_H
-#include FT_INTERNAL_OBJECTS_H // needed for FT_New_Size decl
-
 //------------------------------------------------------------------------
 
 static int glyphPathMoveTo(FT_Vector *pt, void *path);
@@ -112,7 +112,7 @@
   }
   if (yMax == yMin) {
     yMin = 0;
-    yMax = (int)(1.2 * size);
+    yMax = (int)((SplashCoord)1.2 * size);
   }
 
   // compute the transform matrix
@@ -150,7 +150,7 @@
   ff = (SplashFTFontFile *)fontFile;
 
   ff->face->size = sizeObj;
-  offset.x = (FT_Pos)(xFrac * splashFontFractionMul * 64);
+  offset.x = (FT_Pos)(int)((SplashCoord)xFrac * splashFontFractionMul * 64);
   offset.y = 0;
   FT_Set_Transform(ff->face, &matrix, &offset);
   slot = ff->face->glyph;
@@ -204,6 +204,11 @@
   return gTrue;
 }
 
+struct SplashFTFontPath {
+  SplashPath *path;
+  GBool needClose;
+};
+
 SplashPath *SplashFTFont::getGlyphPath(int c) {
   static FT_Outline_Funcs outlineFuncs = {
     &glyphPathMoveTo,
@@ -213,7 +218,7 @@
     0, 0
   };
   SplashFTFontFile *ff;
-  SplashPath *path;
+  SplashFTFontPath path;
   FT_GlyphSlot slot;
   FT_UInt gid;
   FT_Glyph glyph;
@@ -233,26 +238,41 @@
   if (FT_Get_Glyph(slot, &glyph)) {
     return NULL;
   }
-  path = new SplashPath();
+  path.path = new SplashPath();
+  path.needClose = gFalse;
   FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline,
-		       &outlineFuncs, path);
-  return path;
+		       &outlineFuncs, &path);
+  if (path.needClose) {
+    path.path->close();
+  }
+  FT_Done_Glyph(glyph);
+  return path.path;
 }
 
 static int glyphPathMoveTo(FT_Vector *pt, void *path) {
-  ((SplashPath *)path)->moveTo(pt->x / 64.0, -pt->y / 64.0);
+  SplashFTFontPath *p = (SplashFTFontPath *)path;
+
+  if (p->needClose) {
+    p->path->close();
+    p->needClose = gFalse;
+  }
+  p->path->moveTo(pt->x / 64.0, -pt->y / 64.0);
   return 0;
 }
 
 static int glyphPathLineTo(FT_Vector *pt, void *path) {
-  ((SplashPath *)path)->lineTo(pt->x / 64.0, -pt->y / 64.0);
+  SplashFTFontPath *p = (SplashFTFontPath *)path;
+
+  p->path->lineTo(pt->x / 64.0, -pt->y / 64.0);
+  p->needClose = gTrue;
   return 0;
 }
 
 static int glyphPathConicTo(FT_Vector *ctrl, FT_Vector *pt, void *path) {
+  SplashFTFontPath *p = (SplashFTFontPath *)path;
   SplashCoord x0, y0, x1, y1, x2, y2, x3, y3, xc, yc;
 
-  if (!((SplashPath *)path)->getCurPt(&x0, &y0)) {
+  if (!p->path->getCurPt(&x0, &y0)) {
     return 0;
   }
   xc = ctrl->x / 64.0;
@@ -276,20 +296,24 @@
   //     p1 = (1/3) * (p0 + 2pc)
   //     p2 = (1/3) * (2pc + p3)
 
-  x1 = (1.0 / 3.0) * (x0 + 2 * xc);
-  y1 = (1.0 / 3.0) * (y0 + 2 * yc);
-  x2 = (1.0 / 3.0) * (2 * xc + x3);
-  y2 = (1.0 / 3.0) * (2 * yc + y3);
+  x1 = (SplashCoord)(1.0 / 3.0) * (x0 + (SplashCoord)2 * xc);
+  y1 = (SplashCoord)(1.0 / 3.0) * (y0 + (SplashCoord)2 * yc);
+  x2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * xc + x3);
+  y2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * yc + y3);
 
-  ((SplashPath *)path)->curveTo(x1, y1, x2, y2, x3, y3);
+  p->path->curveTo(x1, y1, x2, y2, x3, y3);
+  p->needClose = gTrue;
   return 0;
 }
 
 static int glyphPathCubicTo(FT_Vector *ctrl1, FT_Vector *ctrl2,
 			    FT_Vector *pt, void *path) {
-  ((SplashPath *)path)->curveTo(ctrl1->x / 64.0, -ctrl1->y / 64.0,
-				ctrl2->x / 64.0, -ctrl2->y / 64.0,
-				pt->x / 64.0, -pt->y / 64.0);
+  SplashFTFontPath *p = (SplashFTFontPath *)path;
+
+  p->path->curveTo(ctrl1->x / 64.0, -ctrl1->y / 64.0,
+		   ctrl2->x / 64.0, -ctrl2->y / 64.0,
+		   pt->x / 64.0, -pt->y / 64.0);
+  p->needClose = gTrue;
   return 0;
 }
 



More information about the poppler mailing list