From 1ee02cd0419021c3d4950af2619da39c6e9c47f0 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 21 Dec 2009 15:22:51 +0000 Subject: Updated to freetype-2.3.11 --- freetype/src/pcf/pcf.h | 4 +-- freetype/src/pcf/pcfdrivr.c | 82 ++++++++++++++++++++++++++------------------- freetype/src/pcf/pcfdrivr.h | 4 +++ freetype/src/pcf/pcfread.c | 49 ++++++++++++++------------- freetype/src/pcf/pcfutil.c | 8 ++--- freetype/src/pcf/pcfutil.h | 6 ++-- 6 files changed, 87 insertions(+), 66 deletions(-) (limited to 'freetype/src/pcf') diff --git a/freetype/src/pcf/pcf.h b/freetype/src/pcf/pcf.h index 9d2d8e0e4..1cd56c13a 100644 --- a/freetype/src/pcf/pcf.h +++ b/freetype/src/pcf/pcf.h @@ -72,8 +72,8 @@ FT_BEGIN_HEADER union { FT_String* atom; - FT_Long integer; - FT_ULong cardinal; + FT_Long l; + FT_ULong ul; } value; diff --git a/freetype/src/pcf/pcfdrivr.c b/freetype/src/pcf/pcfdrivr.c index e2d4d3d87..b34e542ae 100644 --- a/freetype/src/pcf/pcfdrivr.c +++ b/freetype/src/pcf/pcfdrivr.c @@ -111,7 +111,7 @@ THE SOFTWARE. while ( min < max ) { - FT_UInt32 code; + FT_ULong code; mid = ( min + max ) >> 1; @@ -140,7 +140,7 @@ THE SOFTWARE. PCF_CMap cmap = (PCF_CMap)pcfcmap; PCF_Encoding encodings = cmap->encodings; FT_UInt min, max, mid; - FT_UInt32 charcode = *acharcode + 1; + FT_ULong charcode = *acharcode + 1; FT_UInt result = 0; @@ -149,7 +149,7 @@ THE SOFTWARE. while ( min < max ) { - FT_UInt32 code; + FT_ULong code; mid = ( min + max ) >> 1; @@ -175,7 +175,14 @@ THE SOFTWARE. } Exit: - *acharcode = charcode; + if ( charcode > 0xFFFFFFFFUL ) + { + FT_TRACE1(( "pcf_cmap_char_next: charcode 0x%x > 32bit API" )); + *acharcode = 0; + /* XXX: result should be changed to indicate an overflow error */ + } + else + *acharcode = (FT_UInt32)charcode; return result; } @@ -266,19 +273,27 @@ THE SOFTWARE. error = pcf_load_font( stream, face ); if ( error ) { - FT_Error error2; + PCF_Face_Done( pcfface ); +#if defined( FT_CONFIG_OPTION_USE_ZLIB ) || \ + defined( FT_CONFIG_OPTION_USE_LZW ) - PCF_Face_Done( pcfface ); +#ifdef FT_CONFIG_OPTION_USE_ZLIB + { + FT_Error error2; - /* this didn't work, try gzip support! */ - error2 = FT_Stream_OpenGzip( &face->gzip_stream, stream ); - if ( FT_ERROR_BASE( error2 ) == FT_Err_Unimplemented_Feature ) - goto Fail; - error = error2; - if ( error ) + /* this didn't work, try gzip support! */ + error2 = FT_Stream_OpenGzip( &face->gzip_stream, stream ); + if ( FT_ERROR_BASE( error2 ) == FT_Err_Unimplemented_Feature ) + goto Fail; + + error = error2; + } +#endif /* FT_CONFIG_OPTION_USE_ZLIB */ + #ifdef FT_CONFIG_OPTION_USE_LZW + if ( error ) { FT_Error error3; @@ -289,32 +304,26 @@ THE SOFTWARE. goto Fail; error = error3; - if ( error ) - goto Fail; + } +#endif /* FT_CONFIG_OPTION_USE_LZW */ - face->gzip_source = stream; - pcfface->stream = &face->gzip_stream; + if ( error ) + goto Fail; - stream = pcfface->stream; + face->gzip_source = stream; + pcfface->stream = &face->gzip_stream; - error = pcf_load_font( stream, face ); - if ( error ) - goto Fail; - } -#else + stream = pcfface->stream; + + error = pcf_load_font( stream, face ); + if ( error ) goto Fail; -#endif - else - { - face->gzip_source = stream; - pcfface->stream = &face->gzip_stream; - stream = pcfface->stream; +#else /* !(FT_CONFIG_OPTION_USE_ZLIB || FT_CONFIG_OPTION_USE_LZW) */ - error = pcf_load_font( stream, face ); - if ( error ) - goto Fail; - } + goto Fail; + +#endif } /* set up charmap */ @@ -446,7 +455,7 @@ THE SOFTWARE. FT_Error error = PCF_Err_Ok; FT_Bitmap* bitmap = &slot->bitmap; PCF_Metric metric; - int bytes; + FT_Offset bytes; FT_UNUSED( load_flags ); @@ -576,12 +585,17 @@ THE SOFTWARE. } else { + if ( prop->value.l > 0x7FFFFFFFL || prop->value.l < ( -1 - 0x7FFFFFFFL ) ) + { + FT_TRACE1(( "pcf_get_bdf_property: " )); + FT_TRACE1(( "too large integer 0x%x is truncated\n" )); + } /* Apparently, the PCF driver loads all properties as signed integers! * This really doesn't seem to be a problem, because this is * sufficient for any meaningful values. */ aproperty->type = BDF_PROPERTY_TYPE_INTEGER; - aproperty->u.integer = prop->value.integer; + aproperty->u.integer = (FT_Int32)prop->value.l; } return 0; } diff --git a/freetype/src/pcf/pcfdrivr.h b/freetype/src/pcf/pcfdrivr.h index 7ddf697e1..a81d7309e 100644 --- a/freetype/src/pcf/pcfdrivr.h +++ b/freetype/src/pcf/pcfdrivr.h @@ -33,6 +33,10 @@ THE SOFTWARE. FT_BEGIN_HEADER +#ifdef FT_CONFIG_OPTION_PIC +#error "this module does not support PIC yet" +#endif + FT_EXPORT_VAR( const FT_Driver_ClassRec ) pcf_driver_class; FT_END_HEADER diff --git a/freetype/src/pcf/pcfread.c b/freetype/src/pcf/pcfread.c index 8e04c57b3..08becf99c 100644 --- a/freetype/src/pcf/pcfread.c +++ b/freetype/src/pcf/pcfread.c @@ -32,7 +32,6 @@ THE SOFTWARE. #include FT_INTERNAL_OBJECTS_H #include "pcf.h" -#include "pcfdrivr.h" #include "pcfread.h" #include "pcferror.h" @@ -290,13 +289,13 @@ THE SOFTWARE. static FT_Error pcf_seek_to_table_type( FT_Stream stream, PCF_Table tables, - FT_Int ntables, + FT_ULong ntables, /* same as PCF_Toc->count */ FT_ULong type, FT_ULong *aformat, FT_ULong *asize ) { FT_Error error = PCF_Err_Invalid_File_Format; - FT_Int i; + FT_ULong i; for ( i = 0; i < ntables; i++ ) @@ -328,10 +327,10 @@ THE SOFTWARE. static FT_Bool pcf_has_table_type( PCF_Table tables, - FT_Int ntables, + FT_ULong ntables, /* same as PCF_Toc->count */ FT_ULong type ) { - FT_Int i; + FT_ULong i; for ( i = 0; i < ntables; i++ ) @@ -400,7 +399,7 @@ THE SOFTWARE. { PCF_ParseProperty props = 0; PCF_Property properties; - FT_UInt nprops, i; + FT_ULong nprops, i; FT_ULong format, size; FT_Error error; FT_Memory memory = FT_FACE(face)->memory; @@ -434,7 +433,10 @@ THE SOFTWARE. if ( error ) goto Bail; - FT_TRACE4(( " nprop = %d\n", nprops )); + FT_TRACE4(( " nprop = %d (truncate %d props)\n", + (int)nprops, nprops - (int)nprops )); + + nprops = (int)nprops; /* rough estimate */ if ( nprops > size / PCF_PROPERTY_SIZE ) @@ -443,7 +445,7 @@ THE SOFTWARE. goto Bail; } - face->nprops = nprops; + face->nprops = (int)nprops; if ( FT_NEW_ARRAY( props, nprops ) ) goto Bail; @@ -543,9 +545,9 @@ THE SOFTWARE. } else { - properties[i].value.integer = props[i].value; + properties[i].value.l = props[i].value; - FT_TRACE4(( " %d\n", properties[i].value.integer )); + FT_TRACE4(( " %d\n", properties[i].value.l )); } } @@ -662,7 +664,7 @@ THE SOFTWARE. FT_Long* offsets; FT_Long bitmapSizes[GLYPHPADOPTIONS]; FT_ULong format, size; - int nbitmaps, i, sizebitmaps = 0; + FT_ULong nbitmaps, i, sizebitmaps = 0; error = pcf_seek_to_table_type( stream, @@ -693,7 +695,8 @@ THE SOFTWARE. FT_TRACE4(( " number of bitmaps: %d\n", nbitmaps )); - if ( nbitmaps != face->nmetrics ) + /* XXX: PCF_Face->nmetrics is singed FT_Long, see pcf.h */ + if ( face->nmetrics < 0 || nbitmaps != ( FT_ULong )face->nmetrics ) return PCF_Err_Invalid_File_Format; if ( FT_NEW_ARRAY( offsets, nbitmaps ) ) @@ -739,8 +742,8 @@ THE SOFTWARE. if ( ( offsets[i] < 0 ) || ( (FT_ULong)offsets[i] > size ) ) { - FT_ERROR(( "pcf_get_bitmaps:")); - FT_ERROR(( " invalid offset to bitmap data of glyph %d\n", i )); + FT_TRACE0(( "pcf_get_bitmaps:" + " invalid offset to bitmap data of glyph %d\n", i )); } else face->metrics[i].bits = stream->pos + offsets[i]; @@ -993,9 +996,9 @@ THE SOFTWARE. PCF_Property prop; - int nn, len; - char* strings[4] = { NULL, NULL, NULL, NULL }; - int lengths[4]; + size_t nn, len; + char* strings[4] = { NULL, NULL, NULL, NULL }; + size_t lengths[4]; face->style_flags = 0; @@ -1077,7 +1080,7 @@ THE SOFTWARE. /* add_style_name and setwidth_name */ if ( nn == 0 || nn == 3 ) { - int mm; + size_t mm; for ( mm = 0; mm < len; mm++ ) @@ -1202,7 +1205,7 @@ THE SOFTWARE. prop = pcf_find_property( face, "AVERAGE_WIDTH" ); if ( prop ) - bsize->width = (FT_Short)( ( prop->value.integer + 5 ) / 10 ); + bsize->width = (FT_Short)( ( prop->value.l + 5 ) / 10 ); else bsize->width = (FT_Short)( bsize->height * 2/3 ); @@ -1210,19 +1213,19 @@ THE SOFTWARE. if ( prop ) /* convert from 722.7 decipoints to 72 points per inch */ bsize->size = - (FT_Pos)( ( prop->value.integer * 64 * 7200 + 36135L ) / 72270L ); + (FT_Pos)( ( prop->value.l * 64 * 7200 + 36135L ) / 72270L ); prop = pcf_find_property( face, "PIXEL_SIZE" ); if ( prop ) - bsize->y_ppem = (FT_Short)prop->value.integer << 6; + bsize->y_ppem = (FT_Short)prop->value.l << 6; prop = pcf_find_property( face, "RESOLUTION_X" ); if ( prop ) - resolution_x = (FT_Short)prop->value.integer; + resolution_x = (FT_Short)prop->value.l; prop = pcf_find_property( face, "RESOLUTION_Y" ); if ( prop ) - resolution_y = (FT_Short)prop->value.integer; + resolution_y = (FT_Short)prop->value.l; if ( bsize->y_ppem == 0 ) { diff --git a/freetype/src/pcf/pcfutil.c b/freetype/src/pcf/pcfutil.c index 67ddbe889..b91274f93 100644 --- a/freetype/src/pcf/pcfutil.c +++ b/freetype/src/pcf/pcfutil.c @@ -42,9 +42,9 @@ in this Software without prior written authorization from The Open Group. FT_LOCAL_DEF( void ) BitOrderInvert( unsigned char* buf, - int nbytes ) + size_t nbytes ) { - for ( ; --nbytes >= 0; buf++ ) + for ( ; nbytes > 0; nbytes--, buf++ ) { unsigned int val = *buf; @@ -64,7 +64,7 @@ in this Software without prior written authorization from The Open Group. FT_LOCAL_DEF( void ) TwoByteSwap( unsigned char* buf, - int nbytes ) + size_t nbytes ) { unsigned char c; @@ -83,7 +83,7 @@ in this Software without prior written authorization from The Open Group. FT_LOCAL_DEF( void ) FourByteSwap( unsigned char* buf, - int nbytes ) + size_t nbytes ) { unsigned char c; diff --git a/freetype/src/pcf/pcfutil.h b/freetype/src/pcf/pcfutil.h index 1557be3e8..ce10fb541 100644 --- a/freetype/src/pcf/pcfutil.h +++ b/freetype/src/pcf/pcfutil.h @@ -37,15 +37,15 @@ FT_BEGIN_HEADER FT_LOCAL( void ) BitOrderInvert( unsigned char* buf, - int nbytes ); + size_t nbytes ); FT_LOCAL( void ) TwoByteSwap( unsigned char* buf, - int nbytes ); + size_t nbytes ); FT_LOCAL( void ) FourByteSwap( unsigned char* buf, - int nbytes ); + size_t nbytes ); FT_END_HEADER -- cgit v1.2.3