From a25ecfddbad6d6e5a534bf0374f4f522349fc158 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Mon, 10 Jun 2013 12:57:16 +0200 Subject: [PATCH] [sfnt] Improve embedded bitmap tracing. * src/base/ftobjs.c (FT_Request_Size): Move trace message regarding bitmap strike match to... (FT_Match_Size): This function. * src/sfnt/ttsbit.c (tt_sbit_decoder_load_metrics, tt_sbit_decoder_load_byte_aligned, tt_sbit_decoder_load_bit_aligned, tt_sbit_decoder_load_compound, tt_sbit_decoder_load_png, tt_sbit_decoder_load_image): Decorate with tracing messages. --- ChangeLog | 13 +++++++++++++ src/base/ftobjs.c | 5 ++--- src/sfnt/ttsbit.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 653ca4212..d9edc2ad0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2013-06-10 Werner Lemberg + + [sfnt] Improve embedded bitmap tracing. + + * src/base/ftobjs.c (FT_Request_Size): Move trace message regarding + bitmap strike match to... + (FT_Match_Size): This function. + + * src/sfnt/ttsbit.c (tt_sbit_decoder_load_metrics, + tt_sbit_decoder_load_byte_aligned, tt_sbit_decoder_load_bit_aligned, + tt_sbit_decoder_load_compound, tt_sbit_decoder_load_png, + tt_sbit_decoder_load_image): Decorate with tracing messages. + 2013-06-10 Werner Lemberg Fix Savannah bug #39160. diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 401fd6482..ac2a39c6a 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -2541,6 +2541,8 @@ if ( w == FT_PIX_ROUND( bsize->x_ppem ) || ignore_width ) { + FT_TRACE3(( "FT_Match_Size: bitmap strike %d matches\n", i )); + if ( size_index ) *size_index = (FT_ULong)i; @@ -2897,9 +2899,6 @@ if ( error ) return error; - FT_TRACE3(( "FT_Request_Size: bitmap strike %lu matched\n", - strike_index )); - return FT_Select_Size( face, (FT_Int)strike_index ); } diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c index 1c7d76b9a..cd3e5a4a0 100644 --- a/src/sfnt/ttsbit.c +++ b/src/sfnt/ttsbit.c @@ -374,6 +374,7 @@ return FT_Err_Ok; Fail: + FT_TRACE1(( "tt_sbit_decoder_load_metrics: broken table" )); return FT_THROW( Invalid_Argument ); } @@ -425,12 +426,15 @@ if ( x_pos < 0 || x_pos + width > bit_width || y_pos < 0 || y_pos + height > bit_height ) { + FT_TRACE1(( "tt_sbit_decoder_load_byte_aligned:" + " invalid bitmap dimensions\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } if ( p + ( ( line_bits + 7 ) >> 3 ) * height > limit ) { + FT_TRACE1(( "tt_sbit_decoder_load_byte_aligned: broken bitmap\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -491,6 +495,8 @@ } Exit: + if ( !error ) + FT_TRACE3(( "tt_sbit_decoder_load_byte_aligned: loaded\n" )); return error; } @@ -562,12 +568,15 @@ if ( x_pos < 0 || x_pos + width > bit_width || y_pos < 0 || y_pos + height > bit_height ) { + FT_TRACE1(( "tt_sbit_decoder_load_bit_aligned:" + " invalid bitmap dimensions\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } if ( p + ( ( line_bits * height + 7 ) >> 3 ) > limit ) { + FT_TRACE1(( "tt_sbit_decoder_load_bit_aligned: broken bitmap\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -647,6 +656,8 @@ } Exit: + if ( !error ) + FT_TRACE3(( "tt_sbit_decoder_load_bit_aligned: loaded\n" )); return error; } @@ -675,7 +686,13 @@ num_components = FT_NEXT_USHORT( p ); if ( p + 4 * num_components > limit ) + { + FT_TRACE1(( "tt_sbit_decoder_load_compound: broken table\n" )); goto Fail; + } + + FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %d components\n", + num_components )); for ( nn = 0; nn < num_components; nn++ ) { @@ -691,6 +708,8 @@ break; } + FT_TRACE3(( "tt_sbit_decoder_load_compound: done\n" )); + decoder->metrics->horiBearingX = horiBearingX; decoder->metrics->horiBearingY = horiBearingY; decoder->metrics->horiAdvance = horiAdvance; @@ -727,6 +746,7 @@ if ( limit - p < 4 ) { + FT_TRACE1(( "tt_sbit_decoder_load_png: broken bitmap\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -734,6 +754,7 @@ png_len = FT_NEXT_ULONG( p ); if ( (FT_ULong)( limit - p ) < png_len ) { + FT_TRACE1(( "tt_sbit_decoder_load_png: broken bitmap\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -748,6 +769,8 @@ png_len ); Exit: + if ( !error ) + FT_TRACE3(( "tt_sbit_decoder_load_png: loaded\n" )); return error; } @@ -1096,6 +1119,10 @@ image_end -= image_start; image_start = image_offset + image_start; + FT_TRACE3(( "tt_sbit_decoder_load_image:" + " found sbit (format %d) for glyph index %d\n", + image_format, glyph_index )); + return tt_sbit_decoder_load_bitmap( decoder, load_flags, image_format, @@ -1108,6 +1135,9 @@ return FT_THROW( Invalid_Table ); NoBitmap: + FT_TRACE4(( "tt_sbit_decoder_load_image:" + " no sbit found for glyph index %d\n", glyph_index )); + return FT_THROW( Invalid_Argument ); }