freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][adjust] Rework autofitter to center tildes if t


From: Craig White (@gerzytet)
Subject: [Git][freetype/freetype][adjust] Rework autofitter to center tildes if they are small.
Date: Sun, 20 Oct 2024 09:38:53 +0000

Craig White pushed to branch adjust at FreeType / FreeType

Commits:

  • fa64df53
    by Craig White at 2024-10-20T05:24:16-04:00
    Rework autofitter to center tildes if they are small.
    

1 changed file:

Changes:

  • src/autofit/aflatin.c
    ... ... @@ -2984,18 +2984,20 @@
    2984 2984
               min_measurement = measurement;
    
    2985 2985
           }
    
    2986 2986
         } while ( p != first_point );
    
    2987
    +    height        = max_y - min_y;
    
    2987 2988
     
    
    2988
    -    /* touch all points */
    
    2989
    -    p = first_point;
    
    2990
    -    do
    
    2991
    -    {
    
    2992
    -      p = p->next;
    
    2993
    -      if ( !( p->flags & AF_FLAG_CONTROL ) )
    
    2994
    -        p->flags |= AF_FLAG_TOUCH_Y;
    
    2989
    +    if ( height < 256 ) {
    
    2990
    +      /* touch all points */
    
    2991
    +      p = first_point;
    
    2992
    +      do
    
    2993
    +      {
    
    2994
    +        p = p->next;
    
    2995
    +        if ( !( p->flags & AF_FLAG_CONTROL ) )
    
    2996
    +          p->flags |= AF_FLAG_TOUCH_Y;
    
    2995 2997
     
    
    2996
    -    } while ( p != first_point );
    
    2998
    +      } while ( p != first_point );
    
    2999
    +    }
    
    2997 3000
     
    
    2998
    -    height        = max_y - min_y;
    
    2999 3001
         target_height = min_measurement + 64;
    
    3000 3002
     
    
    3001 3003
         if ( height >= target_height )
    
    ... ... @@ -3043,7 +3045,6 @@
    3043 3045
         AF_Point  first_point = p;
    
    3044 3046
     
    
    3045 3047
         FT_Pos  min_y, max_y;
    
    3046
    -    FT_Pos  min_y_rounded;
    
    3047 3048
         FT_Pos  delta;
    
    3048 3049
     
    
    3049 3050
     
    
    ... ... @@ -3057,10 +3058,17 @@
    3057 3058
     
    
    3058 3059
         } while ( p != first_point );
    
    3059 3060
     
    
    3060
    -    // mid_y = ( min_y + max_y ) / 2;
    
    3061
    -    min_y_rounded = FT_PIX_ROUND( min_y );
    
    3062
    -    delta         = min_y_rounded - min_y;
    
    3061
    +    // If the tilde is less than 2 pixels tall, snap the center of it to
    
    3062
    +    // the grid instead of the bottom to improve readability
    
    3063
    +    //
    
    3064
    +    FT_Pos min_y_rounded = FT_PIX_ROUND( min_y );
    
    3065
    +    delta                = min_y_rounded - min_y;
    
    3066
    +    FT_Pos height        = max_y - min_y;
    
    3067
    +    if ( height < 64*3 ) {
    
    3068
    +      delta += ( FT_PIX_ROUND( height ) - height ) / 2;
    
    3069
    +    }
    
    3063 3070
     
    
    3071
    +    p = first_point;
    
    3064 3072
         do
    
    3065 3073
         {
    
    3066 3074
           p     = p->next;
    
    ... ... @@ -3193,6 +3201,17 @@
    3193 3201
             return;
    
    3194 3202
           }
    
    3195 3203
     
    
    3204
    +      AF_Point point = hints->contours[highest_contour];
    
    3205
    +      AF_Point first_point = point;
    
    3206
    +      FT_Pos   highest_max_y = point->y;
    
    3207
    +      do
    
    3208
    +      {
    
    3209
    +        if ( point->y > highest_max_y )
    
    3210
    +        {
    
    3211
    +          highest_max_y = point->y;
    
    3212
    +        }
    
    3213
    +      } while ( point != first_point );
    
    3214
    +
    
    3196 3215
           /* If there are any contours that have a maximum y coordinate       */
    
    3197 3216
           /* greater than or equal to the minimum y coordinate of the         */
    
    3198 3217
           /* previously found highest contour, bump the high contour up until */
    
    ... ... @@ -3225,7 +3244,20 @@
    3225 3244
             } while ( point != first_point );
    
    3226 3245
     
    
    3227 3246
             if ( max_y >= highest_min_y - 64 )
    
    3247
    +        {
    
    3228 3248
               adjustment_amount = 64 - ( highest_min_y - max_y );
    
    3249
    +        }
    
    3250
    +      }
    
    3251
    +
    
    3252
    +      FT_TRACE4(( "    Calculated adjustment amount 1: %d\n",
    
    3253
    +                  adjustment_amount ));
    
    3254
    +
    
    3255
    +
    
    3256
    +      if ( adjustment_amount > 0 && ( highest_max_y - highest_min_y ) < 128 )
    
    3257
    +      {
    
    3258
    +        adjustment_amount += ( 128 - ( highest_max_y - highest_min_y ) ) / 2;
    
    3259
    +        FT_TRACE4(( "    Additional push: %d\n",
    
    3260
    +                  ( 128 - ( highest_max_y - highest_min_y ) ) / 2 ));
    
    3229 3261
           }
    
    3230 3262
     
    
    3231 3263
           FT_TRACE4(( "    Calculated adjustment amount: %d\n",
    
    ... ... @@ -4186,6 +4218,7 @@
    4186 4218
         } while ( p != first_point );
    
    4187 4219
     
    
    4188 4220
         FT_TRACE4(( "height %d: %ld\n", num, max_y - min_y ));
    
    4221
    +    FT_TRACE4(( "min y %d: %ld\n", num, min_y ));
    
    4189 4222
       }
    
    4190 4223
     #else
    
    4191 4224
       static void
    
    ... ... @@ -4240,6 +4273,7 @@
    4240 4273
           {
    
    4241 4274
             af_latin_trace_height(0, hints );
    
    4242 4275
             af_latin_stretch_tildes( hints );
    
    4276
    +        af_latin_trace_height(33, hints );
    
    4243 4277
             af_latin_align_tildes( hints );
    
    4244 4278
             af_latin_trace_height(1, hints );
    
    4245 4279
           }
    
    ... ... @@ -4279,7 +4313,7 @@
    4279 4313
               (AF_Dimension)dim,
    
    4280 4314
               glyph_index,
    
    4281 4315
               metrics->root.reverse_charmap );
    
    4282
    -        af_latin_trace_height(6, hints );
    
    4316
    +        af_latin_trace_height(99, hints );
    
    4283 4317
           }
    
    4284 4318
         }
    
    4285 4319
     
    


  • reply via email to

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