freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][smooth_malloc] 2 commits: [smooth] Limit accept


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][smooth_malloc] 2 commits: [smooth] Limit acceptable glyph complexity.
Date: Sun, 08 Oct 2023 03:14:52 +0000

Alexei Podtelezhnikov pushed to branch smooth_malloc at FreeType / FreeType

Commits:

  • 0571d5e0
    by Alexei Podtelezhnikov (Алексей Подтележников) at 2023-10-07T22:39:33-04:00
    [smooth] Limit acceptable glyph complexity.
    
    * src/smooth/ftgrays.c (gray_convert_glyph): Do not attempt to draw
    glyphs with taxicab-to-cbox perimeter ratio above 20.
    
  • 8059da9a
    by Alexei Podtelezhnikov (Алексей Подтележников) at 2023-10-07T23:12:33-04:00
    [smooth] Limit pool size on demand.
    
    * src/smooth/ftgrays.c (gray_convert_glyph): Honor FT_GRAY_POOL_SIZE.
    

1 changed file:

Changes:

  • src/smooth/ftgrays.c
    ... ... @@ -469,10 +469,8 @@ typedef ptrdiff_t FT_PtrDist;
    469 469
       } TPixmap;
    
    470 470
     
    
    471 471
       /* maximum number of gray cells in the buffer */
    
    472
    -#if FT_RENDER_POOL_SIZE > 2048
    
    472
    +#if defined( FT_GRAY_POOL_SIZE ) && FT_GRAY_POOL_SIZE > 2048
    
    473 473
     #define FT_MAX_GRAY_POOL  ( FT_RENDER_POOL_SIZE / sizeof ( TCell ) )
    
    474
    -#else
    
    475
    -#define FT_MAX_GRAY_POOL  ( 2048 / sizeof ( TCell ) )
    
    476 474
     #endif
    
    477 475
     
    
    478 476
       /* FT_Span buffer size for direct rendering only */
    
    ... ... @@ -2011,9 +2009,30 @@ typedef ptrdiff_t FT_PtrDist;
    2011 2009
         int  continued = 0;
    
    2012 2010
     
    
    2013 2011
     
    
    2014
    -    size = gray_taxi( RAS_VAR ) +
    
    2015
    -           height * sizeof ( PCell ) / sizeof ( TCell ) +
    
    2016
    -           9;  /* empirical extra for local extrema */
    
    2012
    +    size = gray_taxi( RAS_VAR );
    
    2013
    +
    
    2014
    +    /* taxicab perimeters in excess of 20 CBox perimeters are */
    
    2015
    +    /* not drawn unless in direct mode with possible clipping */
    
    2016
    +    if ( !ras.render_span                                     &&
    
    2017
    +         size > 20 * 2 * ( ras.max_ex - ras.min_ex + height ) )
    
    2018
    +    {
    
    2019
    +      FT_TRACE5(( "Blanking on taxi:cbox = %.2lf\n",
    
    2020
    +                  0.5 * size / ( ras.max_ex - ras.min_ex + height ) ));
    
    2021
    +      return FT_THROW( Ok );
    
    2022
    +    }
    
    2023
    +
    
    2024
    +    size += height * sizeof ( PCell ) / sizeof ( TCell ) +
    
    2025
    +            9;  /* empirical extra for local extrema */
    
    2026
    +
    
    2027
    +#ifdef FT_MAX_GRAY_POOL
    
    2028
    +    if ( size > FT_MAX_GRAY_POOL )
    
    2029
    +    {
    
    2030
    +      /* both divisions rounded up */
    
    2031
    +      n      = ( size + FT_MAX_GRAY_POOL - 1 ) / FT_MAX_GRAY_POOL;
    
    2032
    +      height = ( height + n - 1 ) / n;
    
    2033
    +      size   = FT_MAX_GRAY_POOL;
    
    2034
    +    }
    
    2035
    +#endif
    
    2017 2036
     
    
    2018 2037
         if ( FT_QNEW_ARRAY( buffer, size ) )
    
    2019 2038
           return error;
    


  • reply via email to

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