Commit 87054758fb1a416a045690d38dcd3d2b05ab1ac1

suzuki toshiya 2009-08-01T00:32:08

autofit: Fix some data types mismatching with their sources.

diff --git a/ChangeLog b/ChangeLog
index 7798e46..b969011 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,32 @@
 2009-07-31  suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
 
+	autofit: Fix some data types mismatching with their sources.
+
+	* src/autofit/afglobal.c: Correct the type of
+	AF_FaceGlobalsRec.glyph_count to match with
+	FT_Face->num_glyphs.
+	(af_face_globals_compute_script_coverage):
+	Insert explicit cast to compare
+	FT_Long AF_FaceGlobalsRec.glyph_count versus
+	FT_UInt gindex.  The type of `nn' is changed
+	to scan glyph index upto AF_FaceGlobalsRec.glyph_count.
+	(af_face_globals_get_metrics): The type of `script_max'
+	is changed to cover size_t value.  Insert explicit cast
+	to compare FT_Long AF_FaceGlobalsRec.glyph_count versus
+	FT_UInt gindex.
+
+	* src/autofit/afhints.c (af_axis_hints_new_segment):
+	Insert explicit cast to calculate `big_max' from
+	integer and size_t values.
+	(af_axis_hints_new_edge): Ditto.
+
+	* src/autofit/aflatin.c (af_latin_metrics_init_blues):
+	The type of `best_y' is matched to FT_Vector.y.
+	(af_latin_compute_stem_width): The type of `delta' is
+	matched to `dist' and `org_dist'.
+
+2009-07-31  suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
 	autofit: Count the size of the memory object by ptrdiff_t.
 
 	* src/autofit/afcjk.c (af_cjk_hint_edges): The
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 452e704..01f5b1e 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -65,7 +65,7 @@
   typedef struct  AF_FaceGlobalsRec_
   {
     FT_Face           face;
-    FT_UInt           glyph_count;    /* same as face->num_glyphs */
+    FT_Long           glyph_count;    /* same as face->num_glyphs */
     FT_Byte*          glyph_scripts;
 
     AF_ScriptMetrics  metrics[AF_SCRIPT_MAX];
@@ -124,7 +124,7 @@
         gindex = FT_Get_Char_Index( face, charcode );
 
         if ( gindex != 0                             &&
-             gindex < globals->glyph_count           &&
+             gindex < (FT_ULong)globals->glyph_count &&
              gscripts[gindex] == AF_SCRIPT_LIST_NONE )
         {
           gscripts[gindex] = (FT_Byte)ss;
@@ -137,7 +137,7 @@
           if ( gindex == 0 || charcode > range->last )
             break;
 
-          if ( gindex < globals->glyph_count           &&
+          if ( gindex < (FT_ULong)globals->glyph_count &&
                gscripts[gindex] == AF_SCRIPT_LIST_NONE )
           {
             gscripts[gindex] = (FT_Byte)ss;
@@ -162,7 +162,7 @@
      *  XXX: Shouldn't we disable hinting or do something similar?
      */
     {
-      FT_UInt  nn;
+      FT_Long  nn;
 
 
       for ( nn = 0; nn < globals->glyph_count; nn++ )
@@ -252,12 +252,12 @@
     FT_UInt           gidx;
     AF_ScriptClass    clazz;
     FT_UInt           script     = options & 15;
-    const FT_UInt     script_max = sizeof ( AF_SCRIPT_CLASSES_GET ) /
+    const FT_Offset   script_max = sizeof ( AF_SCRIPT_CLASSES_GET ) /
                                      sizeof ( AF_SCRIPT_CLASSES_GET[0] );
     FT_Error          error      = AF_Err_Ok;
 
 
-    if ( gindex >= globals->glyph_count )
+    if ( gindex >= (FT_ULong)globals->glyph_count )
     {
       error = AF_Err_Invalid_Argument;
       goto Exit;
diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c
index 8396a20..fe38fba 100644
--- a/src/autofit/afhints.c
+++ b/src/autofit/afhints.c
@@ -34,7 +34,7 @@
     {
       FT_Int  old_max = axis->max_segments;
       FT_Int  new_max = old_max;
-      FT_Int  big_max = FT_INT_MAX / sizeof ( *segment );
+      FT_Int  big_max = (FT_Int)( FT_INT_MAX / sizeof ( *segment ) );
 
 
       if ( old_max >= big_max )
@@ -77,7 +77,7 @@
     {
       FT_Int  old_max = axis->max_edges;
       FT_Int  new_max = old_max;
-      FT_Int  big_max = FT_INT_MAX / sizeof ( *edge );
+      FT_Int  big_max = (FT_Int)( FT_INT_MAX / sizeof ( *edge ) );
 
 
       if ( old_max >= big_max )
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 252703e..bcb5601 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -198,7 +198,8 @@
       for ( ; p < limit && *p; p++ )
       {
         FT_UInt     glyph_index;
-        FT_Int      best_point, best_y, best_first, best_last;
+        FT_Pos      best_y; /* same as points.y */
+        FT_Int      best_point, best_first, best_last;
         FT_Vector*  points;
         FT_Bool     round = 0;
 
@@ -1617,7 +1618,7 @@
             /* not hinted, appear a lot bolder or thinner than the    */
             /* vertical stems.                                        */
 
-            FT_Int  delta;
+            FT_Pos  delta;
 
 
             dist = ( dist + 22 ) & ~63;