freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] Prevent hinting if there are too many s


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] Prevent hinting if there are too many segments.
Date: Sat, 19 Jun 2021 04:42:19 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

2 changed files:

Changes:

  • ChangeLog
    1
    +2021-06-19  Werner Lemberg  <david@freetype.org>
    
    2
    +
    
    3
    +	[autofit] Prevent hinting if there are too many segments.
    
    4
    +
    
    5
    +	This speeds up handling of broken glyphs.
    
    6
    +
    
    7
    +	Reported as
    
    8
    +
    
    9
    +	  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35309
    
    10
    +
    
    11
    +	* src/autofit/aflatin.c (af_latin_hints_compute_segments): Implement
    
    12
    +	it.
    
    13
    +
    
    1 14
     2021-06-18  Alexei Podtelezhnikov  <apodtele@gmail.com>
    
    2 15
     
    
    3 16
     	* src/sdf/ftsdfrend.c (ft_(b)sdf_render): Do not FT_ERROR routinely.
    

  • src/autofit/aflatin.c
    ... ... @@ -1847,6 +1847,31 @@
    1847 1847
                  ( FT_ABS( point->out_dir ) == major_dir ||
    
    1848 1848
                    point == point->prev                  ) )
    
    1849 1849
             {
    
    1850
    +          /*
    
    1851
    +           * For efficiency, we restrict the number of segments to 1000,
    
    1852
    +           * which is a heuristic value: it is very unlikely that a glyph
    
    1853
    +           * with so many segments can be hinted in a sensible way.
    
    1854
    +           * Reasons:
    
    1855
    +           *
    
    1856
    +           * - The glyph has really 1000 segments; this implies that it has
    
    1857
    +           *   at least 2000 outline points.  Assuming 'normal' fonts that
    
    1858
    +           *   have superfluous points optimized away, viewing such a glyph
    
    1859
    +           *   only makes sense at large magnifications where hinting
    
    1860
    +           *   isn't applied anyway.
    
    1861
    +           *
    
    1862
    +           * - We have a broken glyph.  Hinting doesn't make sense in this
    
    1863
    +           *   case either.
    
    1864
    +           */
    
    1865
    +          if ( axis->num_segments > 1000 )
    
    1866
    +          {
    
    1867
    +            FT_TRACE0(( "af_latin_hints_compute_segments:"
    
    1868
    +                        " more than 1000 segments in this glyph;\n" ));
    
    1869
    +            FT_TRACE0(( "                                "
    
    1870
    +                        " hinting is suppressed\n" ));
    
    1871
    +            axis->num_segments = 0;
    
    1872
    +            return FT_Err_Ok;
    
    1873
    +          }
    
    1874
    +
    
    1850 1875
               /* this is the start of a new segment! */
    
    1851 1876
               segment_dir = (AF_Direction)point->out_dir;
    
    1852 1877
     
    


  • reply via email to

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