diff options
Diffstat (limited to 'freetype/src/smooth')
-rw-r--r-- | freetype/src/smooth/ftgrays.c | 29 | ||||
-rw-r--r-- | freetype/src/smooth/ftsmooth.c | 57 | ||||
-rw-r--r-- | freetype/src/smooth/ftspic.c | 4 |
3 files changed, 70 insertions, 20 deletions
diff --git a/freetype/src/smooth/ftgrays.c b/freetype/src/smooth/ftgrays.c index 849734b5d..579485a1e 100644 --- a/freetype/src/smooth/ftgrays.c +++ b/freetype/src/smooth/ftgrays.c @@ -1091,11 +1091,11 @@ typedef ptrdiff_t FT_PtrDist; if ( s > s_limit ) goto Split; - /* If P1 or P2 is outside P0-P3, split the curve. */ - if ( dy * dy1 + dx * dx1 < 0 || - dy * dy2 + dx * dx2 < 0 || - dy * (arc[3].y - arc[1].y) + dx * (arc[3].x - arc[1].x) < 0 || - dy * (arc[3].y - arc[2].y) + dx * (arc[3].x - arc[2].x) < 0 ) + /* Split super curvy segments where the off points are so far + from the chord that the angles P0-P1-P3 or P0-P2-P3 become + acute as detected by appropriate dot products. */ + if ( dx1 * ( dx1 - dx ) + dy1 * ( dy1 - dy ) > 0 || + dx2 * ( dx2 - dx ) + dy2 * ( dy2 - dy ) > 0 ) goto Split; /* No reason to split. */ @@ -1400,7 +1400,26 @@ typedef ptrdiff_t FT_PtrDist; ras.render_span( ras.span_y, ras.num_gray_spans, ras.gray_spans, ras.render_span_data ); +#ifdef FT_DEBUG_LEVEL_TRACE + + if ( ras.num_gray_spans > 0 ) + { + FT_Span* span; + int n; + + + FT_TRACE7(( "y = %3d ", ras.span_y )); + span = ras.gray_spans; + for ( n = 0; n < ras.num_gray_spans; n++, span++ ) + FT_TRACE7(( "[%d..%d]:%02x ", + span->x, span->x + span->len - 1, span->coverage )); + FT_TRACE7(( "\n" )); + } + FT_TRACE7(( "gray_sweep: end\n" )); + +#endif /* FT_DEBUG_LEVEL_TRACE */ + } diff --git a/freetype/src/smooth/ftsmooth.c b/freetype/src/smooth/ftsmooth.c index 233dd6524..7150fe9a5 100644 --- a/freetype/src/smooth/ftsmooth.c +++ b/freetype/src/smooth/ftsmooth.c @@ -116,6 +116,10 @@ FT_Raster_Params params; + FT_Bool have_translated_origin = FALSE; + FT_Bool have_outline_shifted = FALSE; + FT_Bool have_buffer = FALSE; + /* check glyph image format */ if ( slot->format != render->glyph_format ) @@ -126,13 +130,19 @@ /* check mode */ if ( mode != required_mode ) - return Smooth_Err_Cannot_Render_Glyph; + { + error = Smooth_Err_Cannot_Render_Glyph; + goto Exit; + } outline = &slot->outline; /* translate the outline to the new origin if needed */ if ( origin ) + { FT_Outline_Translate( outline, origin->x, origin->y ); + have_translated_origin = TRUE; + } /* compute the control box, and grid fit it */ FT_Outline_Get_CBox( outline, &cbox ); @@ -147,17 +157,19 @@ FT_ERROR(( "ft_smooth_render_generic: glyph too large:" " xMin = %d, xMax = %d\n", cbox.xMin >> 6, cbox.xMax >> 6 )); - return Smooth_Err_Raster_Overflow; + error = Smooth_Err_Raster_Overflow; + goto Exit; } else - width = ( cbox.xMax - cbox.xMin ) >> 6; + width = ( cbox.xMax - cbox.xMin ) >> 6; if ( cbox.yMin < 0 && cbox.yMax > FT_INT_MAX + cbox.yMin ) { FT_ERROR(( "ft_smooth_render_generic: glyph too large:" " yMin = %d, yMax = %d\n", cbox.yMin >> 6, cbox.yMax >> 6 )); - return Smooth_Err_Raster_Overflow; + error = Smooth_Err_Raster_Overflow; + goto Exit; } else height = ( cbox.yMax - cbox.yMin ) >> 6; @@ -220,13 +232,14 @@ #if FT_UINT_MAX > 0xFFFFU - /* Required check is ( pitch * height < FT_ULONG_MAX ), */ - /* but we care realistic cases only. Always pitch <= width. */ + /* Required check is (pitch * height < FT_ULONG_MAX), */ + /* but we care realistic cases only. Always pitch <= width. */ if ( width > 0x7FFF || height > 0x7FFF ) { FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n", width, height )); - return Smooth_Err_Raster_Overflow; + error = Smooth_Err_Raster_Overflow; + goto Exit; } #endif @@ -239,9 +252,12 @@ /* translate outline to render it into the bitmap */ FT_Outline_Translate( outline, -x_shift, -y_shift ); + have_outline_shifted = TRUE; if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) ) goto Exit; + else + have_buffer = TRUE; slot->internal->flags |= FT_GLYPH_OWN_BITMAP; @@ -287,6 +303,9 @@ vec->y /= 3; } + if ( error ) + goto Exit; + if ( slot->library->lcd_filter_func ) slot->library->lcd_filter_func( bitmap, mode, slot->library ); @@ -294,6 +313,8 @@ /* render outline into bitmap */ error = render->raster_render( render->raster, ¶ms ); + if ( error ) + goto Exit; /* expand it horizontally */ if ( hmul ) @@ -345,25 +366,35 @@ #endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - FT_Outline_Translate( outline, x_shift, y_shift ); - /* * XXX: on 16bit system, we return an error for huge bitmap * to prevent an overflow. */ if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX ) - return Smooth_Err_Invalid_Pixel_Size; - - if ( error ) + { + error = Smooth_Err_Invalid_Pixel_Size; goto Exit; + } slot->format = FT_GLYPH_FORMAT_BITMAP; slot->bitmap_left = (FT_Int)x_left; slot->bitmap_top = (FT_Int)y_top; + /* everything is fine; don't deallocate buffer */ + have_buffer = FALSE; + + error = Smooth_Err_Ok; + Exit: - if ( outline && origin ) + if ( have_outline_shifted ) + FT_Outline_Translate( outline, x_shift, y_shift ); + if ( have_translated_origin ) FT_Outline_Translate( outline, -origin->x, -origin->y ); + if ( have_buffer ) + { + FT_FREE( bitmap->buffer ); + slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; + } return error; } diff --git a/freetype/src/smooth/ftspic.c b/freetype/src/smooth/ftspic.c index 49485328f..820fb8aca 100644 --- a/freetype/src/smooth/ftspic.c +++ b/freetype/src/smooth/ftspic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for smooth module. */ /* */ -/* Copyright 2009, 2010 by */ +/* Copyright 2009, 2010, 2012 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -53,7 +53,7 @@ { FT_PIC_Container* pic_container = &library->pic_container; FT_Error error = Smooth_Err_Ok; - SmoothPIC* container; + SmoothPIC* container = NULL; FT_Memory memory = library->memory; |