From 153c038e3c60a29f2977407335c148fa75031ce9 Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Fri, 13 Oct 2023 15:22:32 +0000 Subject: [PATCH] [raster] Improve profile accounting. * src/raster/ftraster.c (End_Profile): Do not initiate next profile. (New_Profile): Fully initiate new profile. (Convert_Glyph): Clean up variables, initialize `fProfile` here. --- src/raster/ftraster.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c index 570d54711..d39d52a7b 100644 --- a/src/raster/ftraster.c +++ b/src/raster/ftraster.c @@ -618,9 +618,8 @@ New_Profile( RAS_ARGS TStates aState, Bool overshoot ) { - if ( !ras.fProfile ) + if ( !ras.cProfile || ras.cProfile->height ) { - ras.fProfile = (PProfile)ras.top; ras.cProfile = (PProfile)ras.top; ras.top += AlignProfileSize; @@ -717,20 +716,8 @@ ras.cProfile->flags |= Overshoot_Bottom; } + /* premature, the last profile in the controur must loop */ ras.cProfile->next = (PProfile)ras.top; - ras.cProfile = (PProfile)ras.top; - - ras.top += AlignProfileSize; - - if ( ras.top >= ras.maxBuff ) - { - FT_TRACE1(( "overflow in End_Profile\n" )); - ras.error = FT_THROW( Raster_Overflow ); - return FAILURE; - } - - ras.cProfile->offset = ras.top; - ras.cProfile->height = 0; ras.num_Profs++; } @@ -1971,6 +1958,7 @@ ras.fProfile = NULL; + ras.cProfile = NULL; ras.joint = FALSE; ras.fresh = FALSE; @@ -1983,7 +1971,6 @@ last = -1; for ( i = 0; i < ras.outline.n_contours; i++ ) { - PProfile lastProfile; Bool o; @@ -2009,7 +1996,6 @@ ( ras.cProfile->flags & Flow_Up ) ) ras.top--; - lastProfile = ras.cProfile; if ( ras.top != ras.cProfile->offset && ( ras.cProfile->flags & Flow_Up ) ) o = IS_TOP_OVERSHOOT( ras.lastY ); @@ -2018,8 +2004,11 @@ if ( End_Profile( RAS_VARS o ) ) return FAILURE; - /* close the `next profile in contour' linked list */ - lastProfile->next = ras.gProfile; + /* loop the last profile in the contour */ + ras.cProfile->next = ras.gProfile; + + if ( !ras.fProfile ) + ras.fProfile = ras.gProfile; } if ( Finalize_Profile_Table( RAS_VAR ) )