From ad5ffc75cdf78f6cf6160e4334d45be15dd48221 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Tue, 2 Jul 2019 04:44:43 +0000 Subject: freetype 2.10.1 git-svn-id: svn://tug.org/texlive/trunk@51529 c570f23f-e606-0410-a88d-b1316a301751 --- .../libs/freetype2/freetype-src/src/cff/cffdrivr.c | 4 +- .../libs/freetype2/freetype-src/src/cff/cffobjs.c | 2 +- .../libs/freetype2/freetype-src/src/cff/cffparse.c | 155 ++++++++++++++------- .../libs/freetype2/freetype-src/src/cff/cffparse.h | 13 ++ 4 files changed, 124 insertions(+), 50 deletions(-) (limited to 'Build/source/libs/freetype2/freetype-src/src/cff') diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c index bbd5c403297..23249898115 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c @@ -381,8 +381,8 @@ static FT_UInt - cff_get_name_index( CFF_Face face, - FT_String* glyph_name ) + cff_get_name_index( CFF_Face face, + const FT_String* glyph_name ) { CFF_Font cff; CFF_Charset charset; diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c index 1a1030c0650..f76245f30b0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c @@ -962,7 +962,7 @@ cffface->style_name = style_name; else /* assume "Regular" style if we don't know better */ - cffface->style_name = cff_strcpy( memory, (char *)"Regular" ); + cffface->style_name = cff_strcpy( memory, "Regular" ); /******************************************************************** * diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c index fa806f1a905..008752c3aea 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c @@ -77,6 +77,23 @@ } +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + static void + finalize_t2_strings( FT_Memory memory, + void* data, + void* user ) + { + CFF_T2_String t2 = (CFF_T2_String)data; + + + FT_UNUSED( user ); + + memory->free( memory, t2->start ); + memory->free( memory, data ); + } +#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ + + FT_LOCAL_DEF( void ) cff_parser_done( CFF_Parser parser ) { @@ -84,13 +101,65 @@ FT_FREE( parser->stack ); + +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + FT_List_Finalize( &parser->t2_strings, + finalize_t2_strings, + memory, + NULL ); +#endif + } + + + /* Assuming `first >= last'. */ + + static FT_Error + cff_parser_within_limits( CFF_Parser parser, + FT_Byte* first, + FT_Byte* last ) + { +#ifndef CFF_CONFIG_OPTION_OLD_ENGINE + + /* Fast path for regular FreeType builds with the "new" engine; */ + /* `first >= parser->start' can be assumed. */ + + FT_UNUSED( first ); + + return last < parser->limit ? FT_Err_Ok : FT_THROW( Invalid_Argument ); + +#else /* CFF_CONFIG_OPTION_OLD_ENGINE */ + + FT_ListNode node; + + + if ( first >= parser->start && + last < parser->limit ) + return FT_Err_Ok; + + node = parser->t2_strings.head; + + while ( node ) + { + CFF_T2_String t2 = (CFF_T2_String)node->data; + + + if ( first >= t2->start && + last < t2->limit ) + return FT_Err_Ok; + + node = node->next; + } + + return FT_THROW( Invalid_Argument ); + +#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ } /* read an integer */ static FT_Long - cff_parse_integer( FT_Byte* start, - FT_Byte* limit ) + cff_parse_integer( CFF_Parser parser, + FT_Byte* start ) { FT_Byte* p = start; FT_Int v = *p++; @@ -99,14 +168,14 @@ if ( v == 28 ) { - if ( p + 2 > limit ) + if ( cff_parser_within_limits( parser, p, p + 1 ) ) goto Bad; val = (FT_Short)( ( (FT_UShort)p[0] << 8 ) | p[1] ); } else if ( v == 29 ) { - if ( p + 4 > limit ) + if ( cff_parser_within_limits( parser, p, p + 3 ) ) goto Bad; val = (FT_Long)( ( (FT_ULong)p[0] << 24 ) | @@ -120,14 +189,14 @@ } else if ( v < 251 ) { - if ( p + 1 > limit ) + if ( cff_parser_within_limits( parser, p, p ) ) goto Bad; val = ( v - 247 ) * 256 + p[0] + 108; } else { - if ( p + 1 > limit ) + if ( cff_parser_within_limits( parser, p, p ) ) goto Bad; val = -( v - 251 ) * 256 - p[0] - 108; @@ -176,10 +245,10 @@ /* read a real */ static FT_Fixed - cff_parse_real( FT_Byte* start, - FT_Byte* limit, - FT_Long power_ten, - FT_Long* scaling ) + cff_parse_real( CFF_Parser parser, + FT_Byte* start, + FT_Long power_ten, + FT_Long* scaling ) { FT_Byte* p = start; FT_Int nib; @@ -214,7 +283,7 @@ p++; /* Make sure we don't read past the end. */ - if ( p >= limit ) + if ( cff_parser_within_limits( parser, p, p ) ) goto Bad; } @@ -251,7 +320,7 @@ p++; /* Make sure we don't read past the end. */ - if ( p >= limit ) + if ( cff_parser_within_limits( parser, p, p ) ) goto Bad; } @@ -290,7 +359,7 @@ p++; /* Make sure we don't read past the end. */ - if ( p >= limit ) + if ( cff_parser_within_limits( parser, p, p ) ) goto Bad; } @@ -457,7 +526,7 @@ if ( **d == 30 ) { /* binary-coded decimal is truncated to integer */ - return cff_parse_real( *d, parser->limit, 0, NULL ) >> 16; + return cff_parse_real( parser, *d, 0, NULL ) >> 16; } else if ( **d == 255 ) @@ -483,7 +552,7 @@ } else - return cff_parse_integer( *d, parser->limit ); + return cff_parse_integer( parser, *d ); } @@ -494,10 +563,10 @@ FT_Long scaling ) { if ( **d == 30 ) - return cff_parse_real( *d, parser->limit, scaling, NULL ); + return cff_parse_real( parser, *d, scaling, NULL ); else { - FT_Long val = cff_parse_integer( *d, parser->limit ); + FT_Long val = cff_parse_integer( parser, *d ); if ( scaling ) @@ -562,14 +631,14 @@ FT_ASSERT( scaling ); if ( **d == 30 ) - return cff_parse_real( *d, parser->limit, 0, scaling ); + return cff_parse_real( parser, *d, 0, scaling ); else { FT_Long number; FT_Int integer_length; - number = cff_parse_integer( d[0], d[1] ); + number = cff_parse_integer( parser, d[0] ); if ( number > 0x7FFFL ) { @@ -1122,18 +1191,6 @@ #endif /* FT_DEBUG_LEVEL_TRACE */ -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - static void - destruct_t2s_item( FT_Memory memory, - void* data, - void* user ) - { - FT_UNUSED( user ); - memory->free( memory, data ); - } -#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ - - FT_LOCAL_DEF( FT_Error ) cff_parser_run( CFF_Parser parser, FT_Byte* start, @@ -1147,11 +1204,6 @@ FT_Library library = parser->library; FT_Memory memory = library->memory; - - FT_ListRec t2s; - - - FT_ZERO( &t2s ); #endif parser->top = parser->stack; @@ -1212,9 +1264,11 @@ FT_Byte* charstring_base; FT_ULong charstring_len; - FT_Fixed* stack; - FT_ListNode node; - FT_Byte* q; + FT_Fixed* stack; + FT_ListNode node; + CFF_T2_String t2; + size_t t2_size; + FT_Byte* q; charstring_base = ++p; @@ -1261,16 +1315,26 @@ if ( !node ) goto Out_Of_Memory_Error; + FT_List_Add( &parser->t2_strings, node ); + + t2 = (CFF_T2_String)memory->alloc( memory, + sizeof ( CFF_T2_StringRec ) ); + if ( !t2 ) + goto Out_Of_Memory_Error; + + node->data = t2; + /* `5' is the conservative upper bound of required bytes per stack */ /* element. */ - q = (FT_Byte*)memory->alloc( memory, - 5 * ( decoder.top - decoder.stack ) ); + + t2_size = 5 * ( decoder.top - decoder.stack ); + + q = (FT_Byte*)memory->alloc( memory, t2_size ); if ( !q ) goto Out_Of_Memory_Error; - node->data = q; - - FT_List_Add( &t2s, node ); + t2->start = q; + t2->limit = q + t2_size; stack = decoder.stack; @@ -1531,9 +1595,6 @@ } /* while ( p < limit ) */ Exit: -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - FT_List_Finalize( &t2s, destruct_t2s_item, memory, NULL ); -#endif return error; #ifdef CFF_CONFIG_OPTION_OLD_ENGINE diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h index bac32f94491..4e74709a2d6 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h @@ -60,6 +60,10 @@ FT_BEGIN_HEADER FT_Byte** top; FT_UInt stackSize; /* allocated size */ +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + FT_ListRec t2_strings; +#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ + FT_UInt object_code; void* object; @@ -130,6 +134,15 @@ FT_BEGIN_HEADER FT_END_HEADER +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + typedef struct CFF_T2_String_ + { + FT_Byte* start; + FT_Byte* limit; + + } CFF_T2_StringRec, *CFF_T2_String; +#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ + #endif /* CFFPARSE_H_ */ -- cgit v1.2.3