From 47ed6413ce8f2586b8d542dc46055e075a47022e Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 6 Aug 2010 10:14:25 +0000 Subject: Updated to freetype 2.4.1 --- freetype/src/pfr/pfrdrivr.c | 4 ++-- freetype/src/pfr/pfrgload.c | 42 +++++++++++++++++++++++++++++------------- freetype/src/pfr/pfrload.c | 16 ++++++++-------- freetype/src/pfr/pfrobjs.c | 20 +++++++++++++++----- freetype/src/pfr/pfrsbit.c | 6 +++--- 5 files changed, 57 insertions(+), 31 deletions(-) (limited to 'freetype/src/pfr') diff --git a/freetype/src/pfr/pfrdrivr.c b/freetype/src/pfr/pfrdrivr.c index 15cca9854..0053050a2 100644 --- a/freetype/src/pfr/pfrdrivr.c +++ b/freetype/src/pfr/pfrdrivr.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR driver interface (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2006, 2008 by */ +/* Copyright 2002, 2003, 2004, 2006, 2008, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -84,7 +84,7 @@ if ( gindex < phys->num_chars ) { *anadvance = phys->chars[gindex].advance; - error = 0; + error = PFR_Err_Ok; } } diff --git a/freetype/src/pfr/pfrgload.c b/freetype/src/pfr/pfrgload.c index 6fe6e4225..6f65b01f5 100644 --- a/freetype/src/pfr/pfrgload.c +++ b/freetype/src/pfr/pfrgload.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR glyph loader (body). */ /* */ -/* Copyright 2002, 2003, 2005, 2007 by */ +/* Copyright 2002, 2003, 2005, 2007, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -248,7 +248,7 @@ FT_Byte* p, FT_Byte* limit ) { - FT_Error error = 0; + FT_Error error = PFR_Err_Ok; FT_Memory memory = glyph->loader->memory; FT_UInt flags, x_count, y_count, i, count, mask; FT_Int x; @@ -268,8 +268,8 @@ { PFR_CHECK( 1 ); count = PFR_NEXT_BYTE( p ); - x_count = ( count & 15 ); - y_count = ( count >> 4 ); + x_count = count & 15; + y_count = count >> 4; } else { @@ -388,7 +388,7 @@ case 2: /* horizontal line to */ FT_TRACE6(( "- horizontal line to cx.%d", format_low )); - if ( format_low > x_count ) + if ( format_low >= x_count ) goto Failure; pos[0].x = glyph->x_control[format_low]; pos[0].y = pos[3].y; @@ -398,7 +398,7 @@ case 3: /* vertical line to */ FT_TRACE6(( "- vertical line to cy.%d", format_low )); - if ( format_low > y_count ) + if ( format_low >= y_count ) goto Failure; pos[0].x = pos[3].x; pos[0].y = glyph->y_control[format_low]; @@ -440,7 +440,7 @@ case 0: /* 8-bit index */ PFR_CHECK( 1 ); idx = PFR_NEXT_BYTE( p ); - if ( idx > x_count ) + if ( idx >= x_count ) goto Failure; cur->x = glyph->x_control[idx]; FT_TRACE7(( " cx#%d", idx )); @@ -470,7 +470,7 @@ case 0: /* 8-bit index */ PFR_CHECK( 1 ); idx = PFR_NEXT_BYTE( p ); - if ( idx > y_count ) + if ( idx >= y_count ) goto Failure; cur->y = glyph->y_control[idx]; FT_TRACE7(( " cy#%d", idx )); @@ -558,7 +558,7 @@ FT_Byte* p, FT_Byte* limit ) { - FT_Error error = 0; + FT_Error error = PFR_Err_Ok; FT_GlyphLoader loader = glyph->loader; FT_Memory memory = loader->memory; PFR_SubGlyph subglyph; @@ -598,6 +598,16 @@ FT_UInt new_max = ( org_count + count + 3 ) & (FT_UInt)-4; + /* we arbitrarily limit the number of subglyphs */ + /* to avoid endless recursion */ + if ( new_max > 64 ) + { + error = PFR_Err_Invalid_Table; + FT_ERROR(( "pfr_glyph_load_compound:" + " too many compound glyphs components\n" )); + goto Exit; + } + if ( FT_RENEW_ARRAY( glyph->subs, glyph->max_subs, new_max ) ) goto Exit; @@ -743,6 +753,9 @@ count = glyph->num_subs - old_count; + FT_TRACE4(( "compound glyph with %d elements (offset %lu):\n", + count, offset )); + /* now, load each individual glyph */ for ( n = 0; n < count; n++ ) { @@ -750,6 +763,8 @@ PFR_SubGlyph subglyph; + FT_TRACE4(( "subglyph %d:\n", n )); + subglyph = glyph->subs + old_count + n; old_points = base->n_points; @@ -757,7 +772,7 @@ subglyph->gps_offset, subglyph->gps_size ); if ( error ) - goto Exit; + break; /* note that `glyph->subs' might have been re-allocated */ subglyph = glyph->subs + old_count + n; @@ -791,9 +806,13 @@ /* proceed to next sub-glyph */ } + + FT_TRACE4(( "end compound glyph with %d elements\n", count )); } else { + FT_TRACE4(( "simple glyph (offset %lu)\n", offset )); + /* load a simple glyph */ error = pfr_glyph_load_simple( glyph, p, limit ); @@ -805,9 +824,6 @@ } - - - FT_LOCAL_DEF( FT_Error ) pfr_glyph_load( PFR_Glyph glyph, FT_Stream stream, diff --git a/freetype/src/pfr/pfrload.c b/freetype/src/pfr/pfrload.c index bc5c035f3..e919fa5b9 100644 --- a/freetype/src/pfr/pfrload.c +++ b/freetype/src/pfr/pfrload.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR loader (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2005, 2007, 2009 by */ +/* Copyright 2002, 2003, 2004, 2005, 2007, 2009, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -49,7 +49,7 @@ PFR_ExtraItem item_list, FT_Pointer item_data ) { - FT_Error error = 0; + FT_Error error = PFR_Err_Ok; FT_Byte* p = *pp; FT_UInt num_items, item_type, item_size; @@ -353,7 +353,7 @@ PFR_Strike strike; FT_UInt flags0; FT_UInt n, count, size1; - FT_Error error = 0; + FT_Error error = PFR_Err_Ok; PFR_CHECK( 5 ); @@ -449,7 +449,7 @@ FT_Byte* limit, PFR_PhyFont phy_font ) { - FT_Error error = 0; + FT_Error error = PFR_Err_Ok; FT_Memory memory = phy_font->memory; FT_PtrDist len = limit - p; @@ -477,7 +477,7 @@ { FT_UInt count, num_vert, num_horz; FT_Int* snaps; - FT_Error error = 0; + FT_Error error = PFR_Err_Ok; FT_Memory memory = phy_font->memory; @@ -520,8 +520,8 @@ FT_Byte* limit, PFR_PhyFont phy_font ) { - PFR_KernItem item; - FT_Error error = 0; + PFR_KernItem item = NULL; + FT_Error error = PFR_Err_Ok; FT_Memory memory = phy_font->memory; @@ -631,7 +631,7 @@ FT_Memory memory, FT_String* *astring ) { - FT_Error error = 0; + FT_Error error = PFR_Err_Ok; FT_String* result = NULL; FT_UInt n, ok; diff --git a/freetype/src/pfr/pfrobjs.c b/freetype/src/pfr/pfrobjs.c index 56d617d88..3e5e86e21 100644 --- a/freetype/src/pfr/pfrobjs.c +++ b/freetype/src/pfr/pfrobjs.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR object methods (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */ +/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -23,6 +23,7 @@ #include "pfrsbit.h" #include FT_OUTLINE_H #include FT_INTERNAL_DEBUG_H +#include FT_TRUETYPE_IDS_H #include "pfrerror.h" @@ -147,7 +148,16 @@ break; if ( nn == phy_font->num_chars ) - pfrface->face_flags = 0; /* not scalable */ + { + if ( phy_font->num_strikes > 0 ) + pfrface->face_flags = 0; /* not scalable */ + else + { + FT_ERROR(( "pfr_face_init: font doesn't contain glyphs\n" )); + error = PFR_Err_Invalid_File_Format; + goto Exit; + } + } } if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 ) @@ -243,11 +253,11 @@ charmap.face = pfrface; - charmap.platform_id = 3; - charmap.encoding_id = 1; + charmap.platform_id = TT_PLATFORM_MICROSOFT; + charmap.encoding_id = TT_MS_ID_UNICODE_CS; charmap.encoding = FT_ENCODING_UNICODE; - FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL ); + error = FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL ); #if 0 /* Select default charmap */ diff --git a/freetype/src/pfr/pfrsbit.c b/freetype/src/pfr/pfrsbit.c index d2f17dc9c..52bc2c8c3 100644 --- a/freetype/src/pfr/pfrsbit.c +++ b/freetype/src/pfr/pfrsbit.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR bitmap loader (body). */ /* */ -/* Copyright 2002, 2003, 2006, 2009 by */ +/* Copyright 2002, 2003, 2006, 2009, 2010 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -353,7 +353,7 @@ FT_Long *aadvance, FT_UInt *aformat ) { - FT_Error error = 0; + FT_Error error = PFR_Err_Ok; FT_Byte flags; FT_Char b; FT_Byte* p = *pdata; @@ -484,7 +484,7 @@ FT_Bool decreasing, FT_Bitmap* target ) { - FT_Error error = 0; + FT_Error error = PFR_Err_Ok; PFR_BitWriterRec writer; -- cgit v1.2.3