From 819d73f6581174353b4853393ee346639ed2cd27 Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Mon, 9 Oct 2023 22:39:27 -0400 Subject: [PATCH] [smooth] Limit acceptable glyph complexity. * src/smooth/ftgrays.c (gray_convert_glyph): Do not attempt to draw glyphs with taxicab: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 404acae50..201b730b3 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;