freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] smooth_malloc 0571d5e04 1/2: [smooth] Limit acceptable glyph


From: Werner Lemberg
Subject: [freetype2] smooth_malloc 0571d5e04 1/2: [smooth] Limit acceptable glyph complexity.
Date: Sat, 7 Oct 2023 23:14:58 -0400 (EDT)

branch: smooth_malloc
commit 0571d5e04c6a81621df46512ababa82e6e83e817
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [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.
---
 src/smooth/ftgrays.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index f56cf1c4a..12e310855 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -2011,9 +2011,20 @@ typedef ptrdiff_t  FT_PtrDist;
     int  continued = 0;
 
 
-    size = gray_taxi( RAS_VAR ) +
-           height * sizeof ( PCell ) / sizeof ( TCell ) +
-           9;  /* empirical extra for local extrema */
+    size = gray_taxi( RAS_VAR );
+
+    /* taxicab perimeters in excess of 20 CBox perimeters are */
+    /* not drawn unless in direct mode with possible clipping */
+    if ( !ras.render_span                                     &&
+         size > 20 * 2 * ( ras.max_ex - ras.min_ex + height ) )
+    {
+      FT_TRACE5(( "Blanking on taxi:cbox = %.2lf\n",
+                  0.5 * size / ( ras.max_ex - ras.min_ex + height ) ));
+      return FT_THROW( Ok );
+    }
+
+    size += height * sizeof ( PCell ) / sizeof ( TCell ) +
+            9;  /* empirical extra for local extrema */
 
     if ( FT_QNEW_ARRAY( buffer, size ) )
       return error;



reply via email to

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