freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][gsoc-craig-2023-final] add additional grid alig


From: Craig White (@gerzytet)
Subject: [Git][freetype/freetype][gsoc-craig-2023-final] add additional grid aligning step to tilde unflattening to fix issues
Date: Sun, 14 Apr 2024 03:05:02 +0000

Craig White pushed to branch gsoc-craig-2023-final at FreeType / FreeType

Commits:

  • afa11fc1
    by Craig White at 2024-04-13T23:04:08-04:00
    add additional grid aligning step to tilde unflattening to fix issues
    

1 changed file:

Changes:

  • src/autofit/aflatin.c
    ... ... @@ -2889,8 +2889,7 @@ The n tilde on times new roman with forced autofitting on,
    2889 2889
     16.5-18 ppem font size exhibits this behaviour.
    
    2890 2890
     */
    
    2891 2891
     void
    
    2892
    -af_latin_stretch_tildes( AF_GlyphHints hints,
    
    2893
    -                         FT_Int glyph_index )
    
    2892
    +af_latin_stretch_tildes( AF_GlyphHints hints )
    
    2894 2893
     {
    
    2895 2894
       FT_Int highest_contour = af_find_highest_contour( hints );
    
    2896 2895
       AF_Point p = hints->contours[highest_contour];
    
    ... ... @@ -3021,6 +3020,59 @@ af_latin_stretch_tildes( AF_GlyphHints hints,
    3021 3020
       while ( p != first_point );
    
    3022 3021
     }
    
    3023 3022
     
    
    3023
    +/*
    
    3024
    +  As part of af_latin_stretch_tildes, all points in the tilde
    
    3025
    +  are marked as touched, so the existing grid fitting will leave
    
    3026
    +  the tilde misaligned with the grid.
    
    3027
    +  This function moves the tilde contour down to be grid fitted.
    
    3028
    +  We assume that if moving the tilde down would cause it to touch or
    
    3029
    +  overlap another countour, the vertical adjustment step will fix it
    
    3030
    +
    
    3031
    +  Because the vertical adjustment step comes after all other grid fitting
    
    3032
    +  steps, the top edge of the contour under the tilde is usually aligned with
    
    3033
    +  a horizontal gridline. The vertical gap enforced by the vertical adjustment
    
    3034
    +  is exactly one pixel, so if the top edge of the contour below the tilde is on a
    
    3035
    +  gridline, the resulting tilde contour will also be grid aligned.
    
    3036
    +
    
    3037
    +  But in cases where the gap is already big enough so that the vertical
    
    3038
    +  adjustment does nothing, this function ensures that even without the
    
    3039
    +  intervention of the vertical adjustment step, the tilde will be
    
    3040
    +  grid aligned.
    
    3041
    +*/
    
    3042
    +void
    
    3043
    +af_latin_align_tildes( AF_GlyphHints hints ) {
    
    3044
    +  FT_Int highest_contour = af_find_highest_contour( hints );
    
    3045
    +  AF_Point p = hints->contours[highest_contour];
    
    3046
    +  AF_Point first_point = p;
    
    3047
    +
    
    3048
    +  FT_Pos min_y, max_y;
    
    3049
    +
    
    3050
    +  do
    
    3051
    +  {
    
    3052
    +    p = p->next;
    
    3053
    +    if ( p->y < min_y )
    
    3054
    +    {
    
    3055
    +      min_y = p->y;
    
    3056
    +    }
    
    3057
    +    if ( p->y > max_y )
    
    3058
    +    {
    
    3059
    +      max_y = p->y;
    
    3060
    +    }
    
    3061
    +  }
    
    3062
    +  while ( p != first_point );
    
    3063
    +
    
    3064
    +  //FT_Pos mid_y = ( min_y + max_y ) / 2;
    
    3065
    +  FT_Pos min_y_rounded = FT_PIX_ROUND( min_y );
    
    3066
    +  FT_Pos delta = min_y_rounded - min_y;
    
    3067
    +
    
    3068
    +  do
    
    3069
    +  {
    
    3070
    +    p = p->next;
    
    3071
    +    p->y += delta;
    
    3072
    +  }
    
    3073
    +  while ( p != first_point );
    
    3074
    +}
    
    3075
    +
    
    3024 3076
     /*True if the given contour overlaps horizontally with the bounding box
    
    3025 3077
       Of all other contours combined.
    
    3026 3078
       This is a helper for af_glyph_hints_apply_vertical_separation_adjustments */
    
    ... ... @@ -4141,7 +4193,8 @@ af_glyph_hints_apply_vertical_separation_adjustments( AF_GlyphHints hints,
    4141 4193
           FT_Bool is_tilde = af_lookup_tilde_correction_type( metrics->root.reverse_charmap, glyph_index );
    
    4142 4194
           if ( is_tilde ) {
    
    4143 4195
             traceheight(0, hints);
    
    4144
    -        af_latin_stretch_tildes( hints, glyph_index );
    
    4196
    +        af_latin_stretch_tildes( hints );
    
    4197
    +        af_latin_align_tildes( hints );
    
    4145 4198
             traceheight(1, hints);
    
    4146 4199
           }
    
    4147 4200
           axis  = &metrics->axis[AF_DIMENSION_VERT];
    


  • reply via email to

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