freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [autofit] Updated to reduce casting.


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [autofit] Updated to reduce casting.
Date: Mon, 01 Aug 2022 14:00:27 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • 4f195185
    by Alexei Podtelezhnikov at 2022-08-01T09:52:43-04:00
    [autofit] Updated to reduce casting.
    
    * src/autofit/afglobal.h (AF_FaceGlobalsRec): Change `glyph_count` type.
    * src/autofit/afglobal.c (af_face_globals_compute_style_coverage,
    af_face_globals_get_metrics, af_face_globals_is_digit,
    af_face_globals_new): Changed local types and updated accordingly.
    * src/autofit/aflatin.c (af_latin_metrics_init_blues): Ditto.
    

3 changed files:

Changes:

  • src/autofit/afglobal.c
    ... ... @@ -129,13 +129,13 @@
    129 129
         FT_Face     face        = globals->face;
    
    130 130
         FT_CharMap  old_charmap = face->charmap;
    
    131 131
         FT_UShort*  gstyles     = globals->glyph_styles;
    
    132
    -    FT_UInt     ss;
    
    132
    +    FT_UShort   ss;
    
    133
    +    FT_UShort   dflt        = 0xFFFFU; /* a non-valid value */
    
    133 134
         FT_UInt     i;
    
    134
    -    FT_UInt     dflt        = ~0U; /* a non-valid value */
    
    135 135
     
    
    136 136
     
    
    137 137
         /* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */
    
    138
    -    for ( i = 0; i < (FT_UInt)globals->glyph_count; i++ )
    
    138
    +    for ( i = 0; i < globals->glyph_count; i++ )
    
    139 139
           gstyles[i] = AF_STYLE_UNASSIGNED;
    
    140 140
     
    
    141 141
         error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
    
    ... ... @@ -183,9 +183,9 @@
    183 183
               gindex = FT_Get_Char_Index( face, charcode );
    
    184 184
     
    
    185 185
               if ( gindex != 0                                                &&
    
    186
    -               gindex < (FT_ULong)globals->glyph_count                    &&
    
    186
    +               gindex < globals->glyph_count                              &&
    
    187 187
                    ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
    
    188
    -            gstyles[gindex] = (FT_UShort)ss;
    
    188
    +            gstyles[gindex] = ss;
    
    189 189
     
    
    190 190
               for (;;)
    
    191 191
               {
    
    ... ... @@ -194,9 +194,9 @@
    194 194
                 if ( gindex == 0 || charcode > range->last )
    
    195 195
                   break;
    
    196 196
     
    
    197
    -            if ( gindex < (FT_ULong)globals->glyph_count                    &&
    
    197
    +            if ( gindex < globals->glyph_count                              &&
    
    198 198
                      ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
    
    199
    -              gstyles[gindex] = (FT_UShort)ss;
    
    199
    +              gstyles[gindex] = ss;
    
    200 200
               }
    
    201 201
             }
    
    202 202
     
    
    ... ... @@ -211,9 +211,9 @@
    211 211
     
    
    212 212
               gindex = FT_Get_Char_Index( face, charcode );
    
    213 213
     
    
    214
    -          if ( gindex != 0                                          &&
    
    215
    -               gindex < (FT_ULong)globals->glyph_count              &&
    
    216
    -               ( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
    
    214
    +          if ( gindex != 0                               &&
    
    215
    +               gindex < globals->glyph_count             &&
    
    216
    +               ( gstyles[gindex] & AF_STYLE_MASK ) == ss )
    
    217 217
                 gstyles[gindex] |= AF_NONBASE;
    
    218 218
     
    
    219 219
               for (;;)
    
    ... ... @@ -223,8 +223,8 @@
    223 223
                 if ( gindex == 0 || charcode > range->last )
    
    224 224
                   break;
    
    225 225
     
    
    226
    -            if ( gindex < (FT_ULong)globals->glyph_count              &&
    
    227
    -                 ( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
    
    226
    +            if ( gindex < globals->glyph_count             &&
    
    227
    +                 ( gstyles[gindex] & AF_STYLE_MASK ) == ss )
    
    228 228
                   gstyles[gindex] |= AF_NONBASE;
    
    229 229
               }
    
    230 230
             }
    
    ... ... @@ -255,7 +255,7 @@
    255 255
           FT_UInt  gindex = FT_Get_Char_Index( face, i );
    
    256 256
     
    
    257 257
     
    
    258
    -      if ( gindex != 0 && gindex < (FT_ULong)globals->glyph_count )
    
    258
    +      if ( gindex != 0 && gindex < globals->glyph_count )
    
    259 259
             gstyles[gindex] |= AF_DIGIT;
    
    260 260
         }
    
    261 261
     
    
    ... ... @@ -266,7 +266,7 @@
    266 266
          */
    
    267 267
         if ( globals->module->fallback_style != AF_STYLE_UNASSIGNED )
    
    268 268
         {
    
    269
    -      FT_Long  nn;
    
    269
    +      FT_UInt  nn;
    
    270 270
     
    
    271 271
     
    
    272 272
           for ( nn = 0; nn < globals->glyph_count; nn++ )
    
    ... ... @@ -290,7 +290,7 @@
    290 290
         {
    
    291 291
           AF_StyleClass  style_class = af_style_classes[ss];
    
    292 292
           FT_UInt        count       = 0;
    
    293
    -      FT_Long        idx;
    
    293
    +      FT_UInt        idx;
    
    294 294
     
    
    295 295
     
    
    296 296
           FT_TRACE4(( "%s:\n", af_style_names[style_class->style] ));
    
    ... ... @@ -345,7 +345,7 @@
    345 345
         FT_ZERO( &globals->metrics );
    
    346 346
     
    
    347 347
         globals->face                      = face;
    
    348
    -    globals->glyph_count               = face->num_glyphs;
    
    348
    +    globals->glyph_count               = (FT_UInt)face->num_glyphs;
    
    349 349
         /* right after the globals structure come the glyph styles */
    
    350 350
         globals->glyph_styles              = (FT_UShort*)( globals + 1 );
    
    351 351
         globals->module                    = module;
    
    ... ... @@ -429,7 +429,7 @@
    429 429
         FT_Error  error = FT_Err_Ok;
    
    430 430
     
    
    431 431
     
    
    432
    -    if ( gindex >= (FT_ULong)globals->glyph_count )
    
    432
    +    if ( gindex >= globals->glyph_count )
    
    433 433
         {
    
    434 434
           error = FT_THROW( Invalid_Argument );
    
    435 435
           goto Exit;
    
    ... ... @@ -501,7 +501,7 @@
    501 501
       af_face_globals_is_digit( AF_FaceGlobals  globals,
    
    502 502
                                 FT_UInt         gindex )
    
    503 503
       {
    
    504
    -    if ( gindex < (FT_ULong)globals->glyph_count )
    
    504
    +    if ( gindex < globals->glyph_count )
    
    505 505
           return FT_BOOL( globals->glyph_styles[gindex] & AF_DIGIT );
    
    506 506
     
    
    507 507
         return FT_BOOL( 0 );
    

  • src/autofit/afglobal.h
    ... ... @@ -105,7 +105,7 @@ FT_BEGIN_HEADER
    105 105
       typedef struct  AF_FaceGlobalsRec_
    
    106 106
       {
    
    107 107
         FT_Face          face;
    
    108
    -    FT_Long          glyph_count;    /* same as face->num_glyphs */
    
    108
    +    FT_UInt          glyph_count;    /* unsigned face->num_glyphs */
    
    109 109
         FT_UShort*       glyph_styles;
    
    110 110
     
    
    111 111
     #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    

  • src/autofit/aflatin.c
    ... ... @@ -1043,7 +1043,7 @@
    1043 1043
           AF_FaceGlobals  globals = metrics->root.globals;
    
    1044 1044
           FT_UShort*      gstyles = globals->glyph_styles;
    
    1045 1045
     
    
    1046
    -      FT_Long  i;
    
    1046
    +      FT_UInt  i;
    
    1047 1047
     
    
    1048 1048
     
    
    1049 1049
           FT_TRACE5(( "no blue zones found:"
    


  • reply via email to

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