From 87054758fb1a416a045690d38dcd3d2b05ab1ac1 Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Sat, 1 Aug 2009 00:32:08 +0900 Subject: [PATCH] autofit: Fix some data types mismatching with their sources. --- ChangeLog | 27 +++++++++++++++++++++++++++ src/autofit/afglobal.c | 12 ++++++------ src/autofit/afhints.c | 4 ++-- src/autofit/aflatin.c | 5 +++-- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7798e4619..b9690111b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2009-07-31 suzuki toshiya + + 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 autofit: Count the size of the memory object by ptrdiff_t. diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c index 452e70414..01f5b1e79 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 8396a20b3..fe38fba99 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 252703ed9..bcb5601d2 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;