freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master ee72e2850 2/2: [autofit] Use unsigned accounting for


From: Werner Lemberg
Subject: [freetype2] master ee72e2850 2/2: [autofit] Use unsigned accounting for hints.
Date: Fri, 29 Jul 2022 23:04:27 -0400 (EDT)

branch: master
commit ee72e285033a943e104f5709cab1ba0c65e54056
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [autofit] Use unsigned accounting for hints.
    
    * src/autofit/afhints.h (AF_AxisHintsRec): Use unsigned types.
    
    * src/autofit/afhints.c (af_axis_hints_new_{segment,edge},
    af_glyph_hints_get_num_segments, af_glyph_hints_get_segment_offset):
    Updated accordingly.
    * src/autofit/aflatin.c (af_cjk_hints_compute_edges): Ditto.
    * src/autofit/afcjk.c (af_cjk_hints_compute_edges): Ditto.
---
 src/autofit/afcjk.c   |  2 +-
 src/autofit/afhints.c | 18 +++++++++---------
 src/autofit/afhints.h |  8 ++++----
 src/autofit/aflatin.c |  4 ++--
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c
index 1853a17f5..950f65925 100644
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -1044,7 +1044,7 @@
     {
       AF_Edge  found = NULL;
       FT_Pos   best  = 0xFFFFU;
-      FT_Int   ee;
+      FT_UInt  ee;
 
 
       /* look for an edge corresponding to the segment */
diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c
index ae7d10528..17a3983e0 100644
--- a/src/autofit/afhints.c
+++ b/src/autofit/afhints.c
@@ -151,9 +151,9 @@
     }
     else if ( axis->num_segments >= axis->max_segments )
     {
-      FT_Int  old_max = axis->max_segments;
-      FT_Int  new_max = old_max;
-      FT_Int  big_max = (FT_Int)( FT_INT_MAX / sizeof ( *segment ) );
+      FT_UInt  old_max = axis->max_segments;
+      FT_UInt  new_max = old_max;
+      FT_UInt  big_max = FT_INT_MAX / sizeof ( *segment );
 
 
       if ( old_max >= big_max )
@@ -216,9 +216,9 @@
     }
     else if ( axis->num_edges >= axis->max_edges )
     {
-      FT_Int  old_max = axis->max_edges;
-      FT_Int  new_max = old_max;
-      FT_Int  big_max = (FT_Int)( FT_INT_MAX / sizeof ( *edge ) );
+      FT_UInt  old_max = axis->max_edges;
+      FT_UInt  new_max = old_max;
+      FT_UInt  big_max = FT_INT_MAX / sizeof ( *edge );
 
 
       if ( old_max >= big_max )
@@ -597,7 +597,7 @@
   FT_Error
   af_glyph_hints_get_num_segments( AF_GlyphHints  hints,
                                    FT_Int         dimension,
-                                   FT_Int*        num_segments )
+                                   FT_UInt*       num_segments )
   {
     AF_Dimension  dim;
     AF_AxisHints  axis;
@@ -623,7 +623,7 @@
   FT_Error
   af_glyph_hints_get_segment_offset( AF_GlyphHints  hints,
                                      FT_Int         dimension,
-                                     FT_Int         idx,
+                                     FT_UInt        idx,
                                      FT_Pos        *offset,
                                      FT_Bool       *is_blue,
                                      FT_Pos        *blue_offset )
@@ -640,7 +640,7 @@
 
     axis = &hints->axis[dim];
 
-    if ( idx < 0 || idx >= axis->num_segments )
+    if ( idx >= axis->num_segments )
       return FT_THROW( Invalid_Argument );
 
     seg      = &axis->segments[idx];
diff --git a/src/autofit/afhints.h b/src/autofit/afhints.h
index 9dd48be74..50c465c26 100644
--- a/src/autofit/afhints.h
+++ b/src/autofit/afhints.h
@@ -308,12 +308,12 @@ FT_BEGIN_HEADER
 
   typedef struct  AF_AxisHintsRec_
   {
-    FT_Int        num_segments; /* number of used segments      */
-    FT_Int        max_segments; /* number of allocated segments */
+    FT_UInt       num_segments; /* number of used segments      */
+    FT_UInt       max_segments; /* number of allocated segments */
     AF_Segment    segments;     /* segments array               */
 
-    FT_Int        num_edges;    /* number of used edges      */
-    FT_Int        max_edges;    /* number of allocated edges */
+    FT_UInt       num_edges;    /* number of used edges      */
+    FT_UInt       max_edges;    /* number of allocated edges */
     AF_Edge       edges;        /* edges array               */
 
     AF_Direction  major_dir;    /* either vertical or horizontal */
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index bed0ccee0..568ecec3d 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -2203,7 +2203,7 @@
     for ( seg = segments; seg < segment_limit; seg++ )
     {
       AF_Edge  found = NULL;
-      FT_Int   ee;
+      FT_UInt  ee;
 
 
       /* ignore too short segments, too wide ones, and, in this loop, */
@@ -2277,7 +2277,7 @@
     for ( seg = segments; seg < segment_limit; seg++ )
     {
       AF_Edge  found = NULL;
-      FT_Int   ee;
+      FT_UInt  ee;
 
 
       if ( seg->dir != AF_DIR_NONE )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]