From ec62c527eb34ee4481a0153ceb42dfd35d7e1d26 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Tue, 9 Jun 2015 16:35:08 -0700 Subject: Update to freetype 2.6.0 Bug 18751561 Change-Id: I871cc2925dc5908ec48073e11ecffad1924bbf50 --- src/psaux/afmparse.c | 45 +++++++++++++++++++++++++++++---------------- src/psaux/afmparse.h | 5 +++-- src/psaux/psaux.c | 2 +- src/psaux/psauxerr.h | 2 +- src/psaux/psauxmod.c | 2 +- src/psaux/psauxmod.h | 2 +- src/psaux/psconv.c | 15 ++++++++------- src/psaux/psconv.h | 2 +- src/psaux/psobjs.c | 46 ++++++++++++++++++++++++---------------------- src/psaux/psobjs.h | 12 ++++++------ src/psaux/t1cmap.c | 32 +++++++++++++++++++++++--------- src/psaux/t1cmap.h | 2 +- src/psaux/t1decode.c | 42 +++++++++++++++++++++++------------------- src/psaux/t1decode.h | 2 +- 14 files changed, 123 insertions(+), 88 deletions(-) (limited to 'src/psaux') diff --git a/src/psaux/afmparse.c b/src/psaux/afmparse.c index 6a40e11..3ad44ec 100644 --- a/src/psaux/afmparse.c +++ b/src/psaux/afmparse.c @@ -4,7 +4,7 @@ /* */ /* AFM parser (body). */ /* */ -/* Copyright 2006-2010, 2012, 2013 by */ +/* Copyright 2006-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -75,8 +75,8 @@ #define AFM_STREAM_KEY_BEGIN( stream ) \ (char*)( (stream)->cursor - 1 ) -#define AFM_STREAM_KEY_LEN( stream, key ) \ - ( (char*)(stream)->cursor - key - 1 ) +#define AFM_STREAM_KEY_LEN( stream, key ) \ + (FT_Offset)( (char*)(stream)->cursor - key - 1 ) #define AFM_STATUS_EOC( stream ) \ ( (stream)->status >= AFM_STREAM_STATUS_EOC ) @@ -369,11 +369,11 @@ FT_LOCAL_DEF( FT_Int ) afm_parser_read_vals( AFM_Parser parser, AFM_Value vals, - FT_UInt n ) + FT_Int n ) { AFM_Stream stream = parser->stream; char* str; - FT_UInt i; + FT_Int i; if ( n > AFM_MAX_ARGUMENTS ) @@ -446,7 +446,7 @@ FT_Offset* len ) { AFM_Stream stream = parser->stream; - char* key = 0; /* make stupid compiler happy */ + char* key = NULL; /* make stupid compiler happy */ if ( line ) @@ -562,7 +562,7 @@ } - FT_LOCAL_DEF( FT_Error ) + static FT_Error afm_parser_read_int( AFM_Parser parser, FT_Int* aint ) { @@ -590,11 +590,17 @@ char* key; FT_Offset len; int n = -1; + FT_Int tmp; - if ( afm_parser_read_int( parser, &fi->NumTrackKern ) ) + if ( afm_parser_read_int( parser, &tmp ) ) goto Fail; + if ( tmp < 0 ) + goto Fail; + + fi->NumTrackKern = (FT_UInt)tmp; + if ( fi->NumTrackKern ) { FT_Memory memory = parser->memory; @@ -615,7 +621,7 @@ case AFM_TOKEN_TRACKKERN: n++; - if ( n >= fi->NumTrackKern ) + if ( n >= (int)fi->NumTrackKern ) goto Fail; tk = fi->TrackKerns + n; @@ -639,7 +645,7 @@ case AFM_TOKEN_ENDTRACKKERN: case AFM_TOKEN_ENDKERNDATA: case AFM_TOKEN_ENDFONTMETRICS: - fi->NumTrackKern = n + 1; + fi->NumTrackKern = (FT_UInt)( n + 1 ); return FT_Err_Ok; case AFM_TOKEN_UNKNOWN: @@ -688,11 +694,17 @@ char* key; FT_Offset len; int n = -1; + FT_Int tmp; + + if ( afm_parser_read_int( parser, &tmp ) ) + goto Fail; - if ( afm_parser_read_int( parser, &fi->NumKernPair ) ) + if ( tmp < 0 ) goto Fail; + fi->NumKernPair = (FT_UInt)tmp; + if ( fi->NumKernPair ) { FT_Memory memory = parser->memory; @@ -720,7 +732,7 @@ n++; - if ( n >= fi->NumKernPair ) + if ( n >= (int)fi->NumKernPair ) goto Fail; kp = fi->KernPairs + n; @@ -733,8 +745,9 @@ if ( r < 3 ) goto Fail; - kp->index1 = shared_vals[0].u.i; - kp->index2 = shared_vals[1].u.i; + /* index values can't be negative */ + kp->index1 = shared_vals[0].u.u; + kp->index2 = shared_vals[1].u.u; if ( token == AFM_TOKEN_KPY ) { kp->x = 0; @@ -752,7 +765,7 @@ case AFM_TOKEN_ENDKERNPAIRS: case AFM_TOKEN_ENDKERNDATA: case AFM_TOKEN_ENDFONTMETRICS: - fi->NumKernPair = n + 1; + fi->NumKernPair = (FT_UInt)( n + 1 ); ft_qsort( fi->KernPairs, fi->NumKernPair, sizeof ( AFM_KernPairRec ), afm_compare_kern_pairs ); @@ -815,7 +828,7 @@ static FT_Error afm_parser_skip_section( AFM_Parser parser, - FT_UInt n, + FT_Int n, AFM_Token end_section ) { char* key; diff --git a/src/psaux/afmparse.h b/src/psaux/afmparse.h index 35d9604..f922c4e 100644 --- a/src/psaux/afmparse.h +++ b/src/psaux/afmparse.h @@ -4,7 +4,7 @@ /* */ /* AFM parser (specification). */ /* */ -/* Copyright 2006 by */ +/* Copyright 2006-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -61,6 +61,7 @@ FT_BEGIN_HEADER char* s; FT_Fixed f; FT_Int i; + FT_UInt u; FT_Bool b; } u; @@ -72,7 +73,7 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Int ) afm_parser_read_vals( AFM_Parser parser, AFM_Value vals, - FT_UInt n ); + FT_Int n ); /* read the next key from the next line or column */ FT_LOCAL( char* ) diff --git a/src/psaux/psaux.c b/src/psaux/psaux.c index a4b9c5c..7f1d9aa 100644 --- a/src/psaux/psaux.c +++ b/src/psaux/psaux.c @@ -4,7 +4,7 @@ /* */ /* FreeType auxiliary PostScript driver component (body only). */ /* */ -/* Copyright 1996-2001, 2002, 2006 by */ +/* Copyright 1996-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/src/psaux/psauxerr.h b/src/psaux/psauxerr.h index d52375f..97712f0 100644 --- a/src/psaux/psauxerr.h +++ b/src/psaux/psauxerr.h @@ -4,7 +4,7 @@ /* */ /* PS auxiliary module error codes (specification only). */ /* */ -/* Copyright 2001, 2012 by */ +/* Copyright 2001-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/src/psaux/psauxmod.c b/src/psaux/psauxmod.c index 4b1249d..06fcab0 100644 --- a/src/psaux/psauxmod.c +++ b/src/psaux/psauxmod.c @@ -4,7 +4,7 @@ /* */ /* FreeType auxiliary PostScript module implementation (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2006 by */ +/* Copyright 2000-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/src/psaux/psauxmod.h b/src/psaux/psauxmod.h index 1217236..ae6a8f9 100644 --- a/src/psaux/psauxmod.h +++ b/src/psaux/psauxmod.h @@ -4,7 +4,7 @@ /* */ /* FreeType auxiliary PostScript module implementation (specification). */ /* */ -/* Copyright 2000-2001 by */ +/* Copyright 2000-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/src/psaux/psconv.c b/src/psaux/psconv.c index d0d8861..aca7412 100644 --- a/src/psaux/psconv.c +++ b/src/psaux/psconv.c @@ -4,7 +4,7 @@ /* */ /* Some convenience conversions (body). */ /* */ -/* Copyright 2006, 2008, 2009, 2012-2013 by */ +/* Copyright 2006-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -124,7 +124,7 @@ if ( IS_PS_SPACE( *p ) || *p OP 0x80 ) break; - c = ft_char_table[*p & 0x7f]; + c = ft_char_table[*p & 0x7F]; if ( c < 0 || c >= base ) break; @@ -245,12 +245,13 @@ if ( IS_PS_SPACE( *p ) || *p OP 0x80 ) break; - c = ft_char_table[*p & 0x7f]; + c = ft_char_table[*p & 0x7F]; if ( c < 0 || c >= 10 ) break; - if ( decimal < 0xCCCCCCCL ) + /* only add digit if we don't overflow */ + if ( divider < 0xCCCCCCCL && decimal < 0xCCCCCCCL ) { decimal = decimal * 10 + c; @@ -488,8 +489,8 @@ if ( c OP 0x80 ) break; - c = ft_char_table[c & 0x7F]; - if ( (unsigned)c >= 16 ) + c = (FT_UInt)ft_char_table[c & 0x7F]; + if ( c >= 16 ) break; pad = ( pad << 4 ) | c; @@ -520,7 +521,7 @@ if ( *p OP 0x80 ) break; - c = ft_char_table[*p & 0x7f]; + c = ft_char_table[*p & 0x7F]; if ( (unsigned)c >= 16 ) break; diff --git a/src/psaux/psconv.h b/src/psaux/psconv.h index d91c762..10f1ff7 100644 --- a/src/psaux/psconv.h +++ b/src/psaux/psconv.h @@ -4,7 +4,7 @@ /* */ /* Some convenience conversions (specification). */ /* */ -/* Copyright 2006, 2012 by */ +/* Copyright 2006-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c index b4b7d45..c7cbc67 100644 --- a/src/psaux/psobjs.c +++ b/src/psaux/psobjs.c @@ -4,7 +4,7 @@ /* */ /* Auxiliary functions for PostScript fonts (body). */ /* */ -/* Copyright 1996-2014 by */ +/* Copyright 1996-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -81,7 +81,7 @@ table->max_elems = count; table->init = 0xDEADBEEFUL; table->num_elems = 0; - table->block = 0; + table->block = NULL; table->capacity = 0; table->cursor = 0; @@ -165,10 +165,10 @@ /* reallocation fails. */ /* */ FT_LOCAL_DEF( FT_Error ) - ps_table_add( PS_Table table, - FT_Int idx, - void* object, - FT_PtrDist length ) + ps_table_add( PS_Table table, + FT_Int idx, + void* object, + FT_UInt length ) { if ( idx < 0 || idx >= table->max_elems ) { @@ -176,12 +176,6 @@ return FT_THROW( Invalid_Argument ); } - if ( length < 0 ) - { - FT_ERROR(( "ps_table_add: invalid length\n" )); - return FT_THROW( Invalid_Argument ); - } - /* grow the base block if needed */ if ( table->cursor + length > table->capacity ) { @@ -625,8 +619,8 @@ token->type = T1_TOKEN_TYPE_NONE; - token->start = 0; - token->limit = 0; + token->start = NULL; + token->limit = NULL; /* first of all, skip leading whitespace */ ps_parser_skip_spaces( parser ); @@ -707,7 +701,7 @@ if ( !token->limit ) { - token->start = 0; + token->start = NULL; token->type = T1_TOKEN_TYPE_NONE; } @@ -932,7 +926,7 @@ FT_Memory memory ) { FT_Byte* cur = *cursor; - FT_PtrDist len = 0; + FT_UInt len = 0; FT_Int count; FT_String* result; FT_Error error; @@ -972,7 +966,7 @@ } } - len = cur - *cursor; + len = (FT_UInt)( cur - *cursor ); if ( cur >= limit || FT_ALLOC( result, len + 1 ) ) return 0; @@ -1230,7 +1224,7 @@ for ( i = 0; i < 4; i++ ) { - result = ps_tofixedarray( &cur, limit, max_objects, + result = ps_tofixedarray( &cur, limit, (FT_Int)max_objects, temp + i * max_objects, 0 ); if ( result < 0 || (FT_UInt)result < max_objects ) { @@ -1321,7 +1315,7 @@ goto Exit; } if ( (FT_UInt)num_elements > field->array_max ) - num_elements = field->array_max; + num_elements = (FT_Int)field->array_max; old_cursor = parser->cursor; old_limit = parser->limit; @@ -1338,7 +1332,15 @@ { parser->cursor = token->start; parser->limit = token->limit; - ps_parser_load_field( parser, &fieldrec, objects, max_objects, 0 ); + + error = ps_parser_load_field( parser, + &fieldrec, + objects, + max_objects, + 0 ); + if ( error ) + break; + fieldrec.offset += fieldrec.size; } @@ -1371,7 +1373,7 @@ ps_parser_to_bytes( PS_Parser parser, FT_Byte* bytes, FT_Offset max_bytes, - FT_Long* pnum_bytes, + FT_ULong* pnum_bytes, FT_Bool delimiters ) { FT_Error error = FT_Err_Ok; @@ -1545,7 +1547,7 @@ FT_GlyphLoader_Rewind( loader ); builder->hints_globals = size->internal; - builder->hints_funcs = 0; + builder->hints_funcs = NULL; if ( hinting ) builder->hints_funcs = glyph->internal->glyph_hints; diff --git a/src/psaux/psobjs.h b/src/psaux/psobjs.h index e380c60..bf879c1 100644 --- a/src/psaux/psobjs.h +++ b/src/psaux/psobjs.h @@ -4,7 +4,7 @@ /* */ /* Auxiliary functions for PostScript fonts (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003 by */ +/* Copyright 1996-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -52,10 +52,10 @@ FT_BEGIN_HEADER FT_Memory memory ); FT_LOCAL( FT_Error ) - ps_table_add( PS_Table table, - FT_Int idx, - void* object, - FT_PtrDist length ); + ps_table_add( PS_Table table, + FT_Int idx, + void* object, + FT_UInt length ); FT_LOCAL( void ) ps_table_done( PS_Table table ); @@ -112,7 +112,7 @@ FT_BEGIN_HEADER ps_parser_to_bytes( PS_Parser parser, FT_Byte* bytes, FT_Offset max_bytes, - FT_Long* pnum_bytes, + FT_ULong* pnum_bytes, FT_Bool delimiters ); diff --git a/src/psaux/t1cmap.c b/src/psaux/t1cmap.c index 9e5bd34..2e2d433 100644 --- a/src/psaux/t1cmap.c +++ b/src/psaux/t1cmap.c @@ -4,7 +4,7 @@ /* */ /* Type 1 character map support (body). */ /* */ -/* Copyright 2002, 2003, 2006, 2007, 2012 by */ +/* Copyright 2002-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -39,7 +39,7 @@ FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; - cmap->num_glyphs = face->type1.num_glyphs; + cmap->num_glyphs = (FT_UInt)face->type1.num_glyphs; cmap->glyph_names = (const char* const*)face->type1.glyph_names; cmap->sid_to_string = psnames->adobe_std_strings; cmap->code_to_sid = is_expert ? psnames->adobe_expert_encoding @@ -120,8 +120,12 @@ FT_CALLBACK_DEF( FT_Error ) - t1_cmap_standard_init( T1_CMapStd cmap ) + t1_cmap_standard_init( T1_CMapStd cmap, + FT_Pointer pointer ) { + FT_UNUSED( pointer ); + + t1_cmap_std_init( cmap, 0 ); return 0; } @@ -142,8 +146,12 @@ FT_CALLBACK_DEF( FT_Error ) - t1_cmap_expert_init( T1_CMapStd cmap ) + t1_cmap_expert_init( T1_CMapStd cmap, + FT_Pointer pointer ) { + FT_UNUSED( pointer ); + + t1_cmap_std_init( cmap, 1 ); return 0; } @@ -172,14 +180,17 @@ FT_CALLBACK_DEF( FT_Error ) - t1_cmap_custom_init( T1_CMapCustom cmap ) + t1_cmap_custom_init( T1_CMapCustom cmap, + FT_Pointer pointer ) { T1_Face face = (T1_Face)FT_CMAP_FACE( cmap ); T1_Encoding encoding = &face->type1.encoding; + FT_UNUSED( pointer ); + - cmap->first = encoding->code_first; - cmap->count = (FT_UInt)( encoding->code_last - cmap->first ); + cmap->first = (FT_UInt)encoding->code_first; + cmap->count = (FT_UInt)encoding->code_last - cmap->first; cmap->indices = encoding->char_index; FT_ASSERT( cmap->indices != NULL ); @@ -272,16 +283,19 @@ FT_CALLBACK_DEF( FT_Error ) - t1_cmap_unicode_init( PS_Unicodes unicodes ) + t1_cmap_unicode_init( PS_Unicodes unicodes, + FT_Pointer pointer ) { T1_Face face = (T1_Face)FT_CMAP_FACE( unicodes ); FT_Memory memory = FT_FACE_MEMORY( face ); FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; + FT_UNUSED( pointer ); + return psnames->unicodes_init( memory, unicodes, - face->type1.num_glyphs, + (FT_UInt)face->type1.num_glyphs, (PS_GetGlyphNameFunc)&psaux_get_glyph_name, (PS_FreeGlyphNameFunc)NULL, (FT_Pointer)face ); diff --git a/src/psaux/t1cmap.h b/src/psaux/t1cmap.h index 7ae65d2..b8ba06c 100644 --- a/src/psaux/t1cmap.h +++ b/src/psaux/t1cmap.h @@ -4,7 +4,7 @@ /* */ /* Type 1 character map support (specification). */ /* */ -/* Copyright 2002, 2003, 2006 by */ +/* Copyright 2002-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c index 6ce370b..2e19928 100644 --- a/src/psaux/t1decode.c +++ b/src/psaux/t1decode.c @@ -4,7 +4,7 @@ /* */ /* PostScript Type 1 decoding routines (body). */ /* */ -/* Copyright 2000-2013 by */ +/* Copyright 2000-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -150,7 +150,7 @@ if ( name && name[0] == glyph_name[0] && ft_strcmp( name, glyph_name ) == 0 ) - return n; + return (FT_Int)n; } return -1; @@ -298,7 +298,7 @@ /* the seac operator must not be nested */ decoder->seac = TRUE; - error = t1_decoder_parse_glyph( decoder, bchar_index ); + error = t1_decoder_parse_glyph( decoder, (FT_UInt)bchar_index ); decoder->seac = FALSE; if ( error ) goto Exit; @@ -320,7 +320,7 @@ /* the seac operator must not be nested */ decoder->seac = TRUE; - error = t1_decoder_parse_glyph( decoder, achar_index ); + error = t1_decoder_parse_glyph( decoder, (FT_UInt)achar_index ); decoder->seac = FALSE; if ( error ) goto Exit; @@ -381,10 +381,10 @@ /* compute random seed from stack address of parameter */ - seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed ^ - (FT_PtrDist)(char*)&decoder ^ - (FT_PtrDist)(char*)&charstring_base ) & - FT_ULONG_MAX ) ; + seed = (FT_Fixed)( ( (FT_Offset)(char*)&seed ^ + (FT_Offset)(char*)&decoder ^ + (FT_Offset)(char*)&charstring_base ) & + FT_ULONG_MAX ); seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL; if ( seed == 0 ) seed = 0x7384; @@ -796,7 +796,8 @@ known_othersubr_result_cnt = 1; if ( hinter ) - hinter->reset( hinter->hints, builder->current->n_points ); + hinter->reset( hinter->hints, + (FT_UInt)builder->current->n_points ); break; case 12: @@ -861,7 +862,7 @@ *values++ = tmp; } - known_othersubr_result_cnt = num_points; + known_othersubr_result_cnt = (FT_Int)num_points; break; } @@ -879,8 +880,8 @@ idx = Fix2Int( top[0] ); - if ( idx < 0 || - idx + blend->num_designs > decoder->len_buildchar ) + if ( idx < 0 || + (FT_UInt)idx + blend->num_designs > decoder->len_buildchar ) goto Unexpected_OtherSubr; ft_memcpy( &decoder->buildchar[idx], @@ -1094,14 +1095,17 @@ /* close hints recording session */ if ( hinter ) { - if ( hinter->close( hinter->hints, builder->current->n_points ) ) + if ( hinter->close( hinter->hints, + (FT_UInt)builder->current->n_points ) ) goto Syntax_Error; /* apply hints to the loaded glyph outline now */ - hinter->apply( hinter->hints, - builder->current, - (PSH_Globals)builder->hints_globals, - decoder->hint_mode ); + error = hinter->apply( hinter->hints, + builder->current, + (PSH_Globals)builder->hints_globals, + decoder->hint_mode ); + if ( error ) + goto Fail; } /* add current outline to the glyph slot */ @@ -1344,7 +1348,7 @@ FT_TRACE4(( " callsubr" )); idx = Fix2Int( top[0] ); - if ( idx < 0 || idx >= (FT_Int)decoder->num_subrs ) + if ( idx < 0 || idx >= decoder->num_subrs ) { FT_ERROR(( "t1_decoder_parse_charstrings:" " invalid subrs index\n" )); @@ -1577,7 +1581,7 @@ /* retrieve PSNames interface from list of current modules */ { - FT_Service_PsCMaps psnames = 0; + FT_Service_PsCMaps psnames; FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); diff --git a/src/psaux/t1decode.h b/src/psaux/t1decode.h index 00728db..e83078f 100644 --- a/src/psaux/t1decode.h +++ b/src/psaux/t1decode.h @@ -4,7 +4,7 @@ /* */ /* PostScript Type 1 decoding routines (specification). */ /* */ -/* Copyright 2000-2001, 2002, 2003 by */ +/* Copyright 2000-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ -- cgit v1.2.3