diff options
author | marha <marha@users.sourceforge.net> | 2015-06-15 20:22:43 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2015-06-15 20:22:43 +0200 |
commit | 0b3be550b20ad9f991f77bf979b2c306a7d4ef11 (patch) | |
tree | 523f6db090457118723eca33dabc7758eeb2dcde /freetype/src/cff | |
parent | 5fe210ff514aa4b3149ea7561862776d7b8849e7 (diff) | |
download | vcxsrv-0b3be550b20ad9f991f77bf979b2c306a7d4ef11.tar.gz vcxsrv-0b3be550b20ad9f991f77bf979b2c306a7d4ef11.tar.bz2 vcxsrv-0b3be550b20ad9f991f77bf979b2c306a7d4ef11.zip |
Update to freetype 2.6
Diffstat (limited to 'freetype/src/cff')
28 files changed, 305 insertions, 137 deletions
diff --git a/freetype/src/cff/Jamfile b/freetype/src/cff/Jamfile index 6705d3cfd..8ffb79cd9 100644 --- a/freetype/src/cff/Jamfile +++ b/freetype/src/cff/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/cff Jamfile # -# Copyright 2001, 2002 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, modified, diff --git a/freetype/src/cff/cf2arrst.c b/freetype/src/cff/cf2arrst.c index c8d6f1309..528b1fa86 100644 --- a/freetype/src/cff/cf2arrst.c +++ b/freetype/src/cff/cf2arrst.c @@ -101,7 +101,7 @@ FT_Error error = FT_Err_Ok; /* for FT_REALLOC */ FT_Memory memory = arrstack->memory; /* for FT_REALLOC */ - FT_Long newSize = (FT_Long)( numElements * arrstack->sizeItem ); + size_t newSize = numElements * arrstack->sizeItem; if ( numElements > LONG_MAX / arrstack->sizeItem ) diff --git a/freetype/src/cff/cf2fixed.h b/freetype/src/cff/cf2fixed.h index ed1452a7d..d6d9faf8e 100644 --- a/freetype/src/cff/cf2fixed.h +++ b/freetype/src/cff/cf2fixed.h @@ -57,22 +57,22 @@ FT_BEGIN_HEADER /* in C 89, left and right shift of negative numbers is */ /* implementation specific behaviour in the general case */ -#define cf2_intToFixed( i ) \ +#define cf2_intToFixed( i ) \ ( (CF2_Fixed)( (FT_UInt32)(i) << 16 ) ) -#define cf2_fixedToInt( x ) \ +#define cf2_fixedToInt( x ) \ ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) ) -#define cf2_fixedRound( x ) \ - ( (CF2_Fixed)( ( (x) + 0x8000 ) & 0xFFFF0000L ) ) -#define cf2_floatToFixed( f ) \ +#define cf2_fixedRound( x ) \ + ( (CF2_Fixed)( ( (FT_UInt32)(x) + 0x8000U ) & 0xFFFF0000UL ) ) +#define cf2_floatToFixed( f ) \ ( (CF2_Fixed)( (f) * 65536.0 + 0.5 ) ) -#define cf2_fixedAbs( x ) \ +#define cf2_fixedAbs( x ) \ ( (x) < 0 ? -(x) : (x) ) -#define cf2_fixedFloor( x ) \ - ( (CF2_Fixed)( (x) & 0xFFFF0000L ) ) -#define cf2_fixedFraction( x ) \ +#define cf2_fixedFloor( x ) \ + ( (CF2_Fixed)( (FT_UInt32)(x) & 0xFFFF0000UL ) ) +#define cf2_fixedFraction( x ) \ ( (x) - cf2_fixedFloor( x ) ) -#define cf2_fracToFixed( x ) \ - ( (x) < 0 ? -( ( -(x) + 0x2000 ) >> 14 ) \ +#define cf2_fracToFixed( x ) \ + ( (x) < 0 ? -( ( -(x) + 0x2000 ) >> 14 ) \ : ( ( (x) + 0x2000 ) >> 14 ) ) diff --git a/freetype/src/cff/cf2font.h b/freetype/src/cff/cf2font.h index d8860ce8e..86cf02f49 100644 --- a/freetype/src/cff/cf2font.h +++ b/freetype/src/cff/cf2font.h @@ -48,7 +48,12 @@ FT_BEGIN_HEADER #define CF2_OPERAND_STACK_SIZE 48 -#define CF2_MAX_SUBR 10 /* maximum subroutine nesting */ +#define CF2_MAX_SUBR 16 /* maximum subroutine nesting; */ + /* only 10 are allowed but there exist */ + /* fonts like `HiraKakuProN-W3.ttf' */ + /* (Hiragino Kaku Gothic ProN W3; */ + /* 8.2d6e1; 2014-12-19) that exceed */ + /* this limit */ /* typedef is in `cf2glue.h' */ diff --git a/freetype/src/cff/cf2ft.c b/freetype/src/cff/cf2ft.c index ebba4694c..d2544a234 100644 --- a/freetype/src/cff/cf2ft.c +++ b/freetype/src/cff/cf2ft.c @@ -551,7 +551,7 @@ FT_ZERO( buf ); - idx += decoder->globals_bias; + idx += (CF2_UInt)decoder->globals_bias; if ( idx >= decoder->num_globals ) return TRUE; /* error */ @@ -569,7 +569,7 @@ /* used for seac component */ FT_LOCAL_DEF( FT_Error ) cf2_getSeacComponent( CFF_Decoder* decoder, - CF2_UInt code, + CF2_Int code, CF2_Buffer buf ) { CF2_Int gid; @@ -582,12 +582,21 @@ FT_ZERO( buf ); - gid = cff_lookup_glyph_by_stdcharcode( decoder->cff, code ); - if ( gid < 0 ) - return FT_THROW( Invalid_Glyph_Format ); +#ifdef FT_CONFIG_OPTION_INCREMENTAL + /* Incremental fonts don't necessarily have valid charsets. */ + /* They use the character code, not the glyph index, in this case. */ + if ( decoder->builder.face->root.internal->incremental_interface ) + gid = code; + else +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ + { + gid = cff_lookup_glyph_by_stdcharcode( decoder->cff, code ); + if ( gid < 0 ) + return FT_THROW( Invalid_Glyph_Format ); + } error = cff_get_glyph_data( decoder->builder.face, - gid, + (CF2_UInt)gid, &charstring, &len ); /* TODO: for now, just pass the FreeType error through */ @@ -626,7 +635,7 @@ FT_ZERO( buf ); - idx += decoder->locals_bias; + idx += (CF2_UInt)decoder->locals_bias; if ( idx >= decoder->num_locals ) return TRUE; /* error */ diff --git a/freetype/src/cff/cf2ft.h b/freetype/src/cff/cf2ft.h index 731da3ca8..3073df382 100644 --- a/freetype/src/cff/cf2ft.h +++ b/freetype/src/cff/cf2ft.h @@ -103,7 +103,7 @@ FT_BEGIN_HEADER CF2_Buffer buf ); FT_LOCAL( FT_Error ) cf2_getSeacComponent( CFF_Decoder* decoder, - CF2_UInt code, + CF2_Int code, CF2_Buffer buf ); FT_LOCAL( void ) cf2_freeSeacComponent( CFF_Decoder* decoder, diff --git a/freetype/src/cff/cf2hints.c b/freetype/src/cff/cf2hints.c index 040d193f3..0e2700021 100644 --- a/freetype/src/cff/cf2hints.c +++ b/freetype/src/cff/cf2hints.c @@ -697,10 +697,10 @@ /* make room to insert */ { - CF2_Int iSrc = hintmap->count - 1; - CF2_Int iDst = isPair ? hintmap->count + 1 : hintmap->count; + CF2_UInt iSrc = hintmap->count - 1; + CF2_UInt iDst = isPair ? hintmap->count + 1 : hintmap->count; - CF2_Int count = hintmap->count - indexInsert; + CF2_UInt count = hintmap->count - indexInsert; if ( iDst >= CF2_MAX_HINT_EDGES ) diff --git a/freetype/src/cff/cf2intrp.c b/freetype/src/cff/cf2intrp.c index a26960669..537e0609d 100644 --- a/freetype/src/cff/cf2intrp.c +++ b/freetype/src/cff/cf2intrp.c @@ -43,6 +43,7 @@ #include "cf2font.h" #include "cf2stack.h" #include "cf2hints.h" +#include "cf2intrp.h" #include "cf2error.h" @@ -760,16 +761,19 @@ /* push our current CFF charstring region on subrStack */ charstring = (CF2_Buffer) - cf2_arrstack_getPointer( &subrStack, - charstringIndex + 1 ); + cf2_arrstack_getPointer( + &subrStack, + (size_t)charstringIndex + 1 ); /* set up the new CFF region and pointer */ - subrIndex = cf2_stack_popInt( opStack ); + subrIndex = (CF2_UInt)cf2_stack_popInt( opStack ); switch ( op1 ) { case cf2_cmdCALLGSUBR: - FT_TRACE4(( "(%d)\n", subrIndex + decoder->globals_bias )); + FT_TRACE4(( " (idx %d, entering level %d)\n", + subrIndex + (CF2_UInt)decoder->globals_bias, + charstringIndex + 1 )); if ( cf2_initGlobalRegionBuffer( decoder, subrIndex, @@ -782,7 +786,9 @@ default: /* cf2_cmdCALLSUBR */ - FT_TRACE4(( "(%d)\n", subrIndex + decoder->locals_bias )); + FT_TRACE4(( " (idx %d, entering level %d)\n", + subrIndex + (CF2_UInt)decoder->locals_bias, + charstringIndex + 1 )); if ( cf2_initLocalRegionBuffer( decoder, subrIndex, @@ -798,7 +804,7 @@ continue; /* do not clear the stack */ case cf2_cmdRETURN: - FT_TRACE4(( " return\n" )); + FT_TRACE4(( " return (leaving level %d)\n", charstringIndex )); if ( charstringIndex < 1 ) { @@ -809,8 +815,9 @@ /* restore position in previous charstring */ charstring = (CF2_Buffer) - cf2_arrstack_getPointer( &subrStack, - --charstringIndex ); + cf2_arrstack_getPointer( + &subrStack, + (CF2_UInt)--charstringIndex ); continue; /* do not clear the stack */ case cf2_cmdESC: @@ -1088,8 +1095,8 @@ /* must be either 4 or 5 -- */ /* this is a (deprecated) implied `seac' operator */ - CF2_UInt achar; - CF2_UInt bchar; + CF2_Int achar; + CF2_Int bchar; CF2_BufferRec component; CF2_Fixed dummyWidth; /* ignore component width */ FT_Error error2; @@ -1291,10 +1298,16 @@ case cf2_cmdVVCURVETO: { - CF2_UInt count = cf2_stack_count( opStack ); + CF2_UInt count, count1 = cf2_stack_count( opStack ); CF2_UInt index = 0; + /* if `cf2_stack_count' isn't of the form 4n or 4n+1, */ + /* we enforce it by clearing the second bit */ + /* (and sorting the stack indexing to suit) */ + count = count1 & ~2; + index += count1 - count; + FT_TRACE4(( " vvcurveto\n" )); while ( index < count ) @@ -1330,10 +1343,16 @@ case cf2_cmdHHCURVETO: { - CF2_UInt count = cf2_stack_count( opStack ); + CF2_UInt count, count1 = cf2_stack_count( opStack ); CF2_UInt index = 0; + /* if `cf2_stack_count' isn't of the form 4n or 4n+1, */ + /* we enforce it by clearing the second bit */ + /* (and sorting the stack indexing to suit) */ + count = count1 & ~2; + index += count1 - count; + FT_TRACE4(( " hhcurveto\n" )); while ( index < count ) @@ -1370,12 +1389,19 @@ case cf2_cmdVHCURVETO: case cf2_cmdHVCURVETO: { - CF2_UInt count = cf2_stack_count( opStack ); + CF2_UInt count, count1 = cf2_stack_count( opStack ); CF2_UInt index = 0; FT_Bool alternate = op1 == cf2_cmdHVCURVETO; + /* if `cf2_stack_count' isn't of the form 8n, 8n+1, */ + /* 8n+4, or 8n+5, we enforce it by clearing the */ + /* second bit */ + /* (and sorting the stack indexing to suit) */ + count = count1 & ~2; + index += count1 - count; + FT_TRACE4(( alternate ? " hvcurveto\n" : " vhcurveto\n" )); while ( index < count ) diff --git a/freetype/src/cff/cff.c b/freetype/src/cff/cff.c index c3840b583..bb2cfb525 100644 --- a/freetype/src/cff/cff.c +++ b/freetype/src/cff/cff.c @@ -4,7 +4,7 @@ /* */ /* FreeType OpenType driver component (body only). */ /* */ -/* Copyright 1996-2001, 2002, 2013 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/freetype/src/cff/cffcmap.c b/freetype/src/cff/cffcmap.c index 52248b2b9..e7538e984 100644 --- a/freetype/src/cff/cffcmap.c +++ b/freetype/src/cff/cffcmap.c @@ -4,7 +4,7 @@ /* */ /* CFF character mapping table (cmap) support (body). */ /* */ -/* Copyright 2002-2007, 2010, 2013 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/freetype/src/cff/cffcmap.h b/freetype/src/cff/cffcmap.h index 3f7f67bbe..6eaed636e 100644 --- a/freetype/src/cff/cffcmap.h +++ b/freetype/src/cff/cffcmap.h @@ -4,7 +4,7 @@ /* */ /* CFF character mapping table (cmap) 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/freetype/src/cff/cffdrivr.c b/freetype/src/cff/cffdrivr.c index 3e8898e34..a718b7a00 100644 --- a/freetype/src/cff/cffdrivr.c +++ b/freetype/src/cff/cffdrivr.c @@ -4,7 +4,7 @@ /* */ /* OpenType font driver implementation (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, */ @@ -35,7 +35,7 @@ #include "cfferrs.h" #include "cffpic.h" -#include FT_SERVICE_XFREE86_NAME_H +#include FT_SERVICE_FONT_FORMAT_H #include FT_SERVICE_GLYPH_DICT_H #include FT_SERVICE_PROPERTIES_H #include FT_CFF_DRIVER_H @@ -64,11 +64,6 @@ /*************************************************************************/ -#undef PAIR_TAG -#define PAIR_TAG( left, right ) ( ( (FT_ULong)left << 16 ) | \ - (FT_ULong)right ) - - /*************************************************************************/ /* */ /* <Function> */ @@ -121,9 +116,6 @@ } -#undef PAIR_TAG - - /*************************************************************************/ /* */ /* <Function> */ @@ -203,6 +195,68 @@ FT_GlyphSlot slot = face->glyph; + if ( FT_IS_SFNT( face ) ) + { + /* OpenType 1.7 mandates that the data from `hmtx' table be used; */ + /* it is no longer necessary that those values are identical to */ + /* the values in the `CFF' table */ + + TT_Face ttface = (TT_Face)face; + FT_Short dummy; + + + if ( flags & FT_LOAD_VERTICAL_LAYOUT ) + { + /* check whether we have data from the `vmtx' table at all; */ + /* otherwise we extract the info from the CFF glyphstrings */ + /* (instead of synthesizing a global value using the `OS/2' */ + /* table) */ + if ( !ttface->vertical_info ) + goto Missing_Table; + + for ( nn = 0; nn < count; nn++ ) + { + FT_UShort ah; + + + ( (SFNT_Service)ttface->sfnt )->get_metrics( ttface, + 1, + start + nn, + &dummy, + &ah ); + + FT_TRACE5(( " idx %d: advance height %d font units\n", + start + nn, ah )); + advances[nn] = ah; + } + } + else + { + /* check whether we have data from the `hmtx' table at all */ + if ( !ttface->horizontal.number_Of_HMetrics ) + goto Missing_Table; + + for ( nn = 0; nn < count; nn++ ) + { + FT_UShort aw; + + + ( (SFNT_Service)ttface->sfnt )->get_metrics( ttface, + 0, + start + nn, + &dummy, + &aw ); + + FT_TRACE5(( " idx %d: advance width %d font units\n", + start + nn, aw )); + advances[nn] = aw; + } + } + + return error; + } + + Missing_Table: flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY; for ( nn = 0; nn < count; nn++ ) @@ -352,7 +406,7 @@ font_info->italic_angle = dict->italic_angle; font_info->is_fixed_pitch = dict->is_fixed_pitch; font_info->underline_position = (FT_Short)dict->underline_position; - font_info->underline_thickness = (FT_Short)dict->underline_thickness; + font_info->underline_thickness = (FT_UShort)dict->underline_thickness; cff->font_info = font_info; } @@ -383,9 +437,27 @@ static const char* cff_get_ps_name( CFF_Face face ) { - CFF_Font cff = (CFF_Font)face->extra.data; + CFF_Font cff = (CFF_Font)face->extra.data; + SFNT_Service sfnt = (SFNT_Service)face->sfnt; + /* following the OpenType specification 1.7, we return the name stored */ + /* in the `name' table for a CFF wrapped into an SFNT container */ + + if ( sfnt ) + { + FT_Library library = FT_FACE_LIBRARY( face ); + FT_Module sfnt_module = FT_Get_Module( library, "sfnt" ); + FT_Service_PsFontName service = + (FT_Service_PsFontName)ft_module_get_service( + sfnt_module, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME ); + + + if ( service && service->get_ps_font_name ) + return service->get_ps_font_name( FT_FACE( face ) ); + } + return (const char*)cff->font_name; } @@ -723,7 +795,7 @@ #ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES FT_DEFINE_SERVICEDESCREC7( cff_services, - FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF, + FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, @@ -734,7 +806,7 @@ #else FT_DEFINE_SERVICEDESCREC6( cff_services, - FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF, + FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, diff --git a/freetype/src/cff/cffdrivr.h b/freetype/src/cff/cffdrivr.h index 50e813870..9527f5e14 100644 --- a/freetype/src/cff/cffdrivr.h +++ b/freetype/src/cff/cffdrivr.h @@ -4,7 +4,7 @@ /* */ /* High-level OpenType driver interface (specification). */ /* */ -/* Copyright 1996-2001, 2002 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/freetype/src/cff/cfferrs.h b/freetype/src/cff/cfferrs.h index 801d73ec6..543bdb07c 100644 --- a/freetype/src/cff/cfferrs.h +++ b/freetype/src/cff/cfferrs.h @@ -4,7 +4,7 @@ /* */ /* CFF 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/freetype/src/cff/cffgload.c b/freetype/src/cff/cffgload.c index 758a3d3bb..43054f8c3 100644 --- a/freetype/src/cff/cffgload.c +++ b/freetype/src/cff/cffgload.c @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (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, */ @@ -273,8 +273,8 @@ builder->current = &loader->current.outline; FT_GlyphLoader_Rewind( loader ); - builder->hints_globals = 0; - builder->hints_funcs = 0; + builder->hints_globals = NULL; + builder->hints_funcs = NULL; if ( hinting && size ) { @@ -646,7 +646,7 @@ for ( n = 0; n < cff->num_glyphs; n++ ) { if ( cff->charset.sids[n] == glyph_sid ) - return n; + return (FT_Int)n; } return -1; @@ -672,7 +672,7 @@ *pointer = (FT_Byte*)data.pointer; - *length = data.length; + *length = (FT_ULong)data.length; return error; } @@ -707,7 +707,7 @@ data.pointer = *pointer; - data.length = length; + data.length = (FT_Int)length; face->root.internal->incremental_interface->funcs->free_glyph_data( face->root.internal->incremental_interface->object, &data ); @@ -819,7 +819,7 @@ FT_GlyphLoader_Prepare( builder->loader ); /* First load `bchar' in builder */ - error = cff_get_glyph_data( face, bchar_index, + error = cff_get_glyph_data( face, (FT_UInt)bchar_index, &charstring, &charstring_len ); if ( !error ) { @@ -849,7 +849,7 @@ builder->pos_y = ady; /* Now load `achar' on top of the base outline. */ - error = cff_get_glyph_data( face, achar_index, + error = cff_get_glyph_data( face, (FT_UInt)achar_index, &charstring, &charstring_len ); if ( !error ) { @@ -922,10 +922,10 @@ decoder->read_width = 1; /* 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; @@ -1373,12 +1373,12 @@ { if ( op == cff_op_hintmask ) hinter->hintmask( hinter->hints, - builder->current->n_points, - decoder->num_hints, + (FT_UInt)builder->current->n_points, + (FT_UInt)decoder->num_hints, ip ); else hinter->counter( hinter->hints, - decoder->num_hints, + (FT_UInt)decoder->num_hints, ip ); } @@ -1995,7 +1995,7 @@ if ( hinter ) { if ( hinter->close( hinter->hints, - builder->current->n_points ) ) + (FT_UInt)builder->current->n_points ) ) goto Syntax_Error; /* apply hints to the loaded glyph outline now */ @@ -2389,7 +2389,9 @@ decoder->locals_bias ); - FT_TRACE4(( " callsubr(%d)\n", idx )); + FT_TRACE4(( " callsubr (idx %d, entering level %d)\n", + idx, + zone - decoder->zones + 1 )); if ( idx >= decoder->num_locals ) { @@ -2431,7 +2433,9 @@ decoder->globals_bias ); - FT_TRACE4(( " callgsubr(%d)\n", idx )); + FT_TRACE4(( " callgsubr (idx %d, entering level %d)\n", + idx, + zone - decoder->zones + 1 )); if ( idx >= decoder->num_globals ) { @@ -2468,7 +2472,8 @@ break; case cff_op_return: - FT_TRACE4(( " return\n" )); + FT_TRACE4(( " return (leaving level %d)\n", + decoder->zone - decoder->zones )); if ( decoder->zone <= decoder->zones ) { @@ -2669,7 +2674,7 @@ error = sfnt->load_sbit_image( face, size->strike_index, glyph_index, - (FT_Int)load_flags, + (FT_UInt)load_flags, stream, &glyph->root.bitmap, &metrics ); @@ -2720,7 +2725,7 @@ face->vertical_info && face->vertical.number_Of_VMetrics > 0 ); - /* get the vertical metrics from the vtmx table if we have one */ + /* get the vertical metrics from the vmtx table if we have one */ if ( has_vertical_info ) { (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 1, @@ -2757,16 +2762,16 @@ /* this scaling is only relevant if the PS hinter isn't active */ if ( cff->num_subfonts ) { - FT_ULong top_upm, sub_upm; - FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, - glyph_index ); + FT_Long top_upm, sub_upm; + FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, + glyph_index ); if ( fd_index >= cff->num_subfonts ) fd_index = (FT_Byte)( cff->num_subfonts - 1 ); - top_upm = cff->top_font.font_dict.units_per_em; - sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em; + top_upm = (FT_Long)cff->top_font.font_dict.units_per_em; + sub_upm = (FT_Long)cff->subfonts[fd_index]->font_dict.units_per_em; font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix; @@ -2867,7 +2872,7 @@ /* fonts. */ if ( face->root.internal->incremental_interface ) { - glyph->root.control_data = 0; + glyph->root.control_data = NULL; glyph->root.control_len = 0; } else @@ -2884,7 +2889,7 @@ { glyph->root.control_data = csindex->bytes + csindex->offsets[glyph_index] - 1; - glyph->root.control_len = charstring_len; + glyph->root.control_len = (FT_Long)charstring_len; } } @@ -2948,25 +2953,43 @@ FT_Bool has_vertical_info; - /* copy the _unscaled_ advance width */ - metrics->horiAdvance = decoder.glyph_width; - glyph->root.linearHoriAdvance = decoder.glyph_width; + if ( face->horizontal.number_Of_HMetrics ) + { + FT_Short horiBearingX = 0; + FT_UShort horiAdvance = 0; + + + ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, + glyph_index, + &horiBearingX, + &horiAdvance ); + metrics->horiAdvance = horiAdvance; + metrics->horiBearingX = horiBearingX; + glyph->root.linearHoriAdvance = horiAdvance; + } + else + { + /* copy the _unscaled_ advance width */ + metrics->horiAdvance = decoder.glyph_width; + glyph->root.linearHoriAdvance = decoder.glyph_width; + } + glyph->root.internal->glyph_transformed = 0; has_vertical_info = FT_BOOL( face->vertical_info && face->vertical.number_Of_VMetrics > 0 ); - /* get the vertical metrics from the vtmx table if we have one */ + /* get the vertical metrics from the vmtx table if we have one */ if ( has_vertical_info ) { FT_Short vertBearingY = 0; FT_UShort vertAdvance = 0; - (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 1, - glyph_index, - &vertBearingY, - &vertAdvance ); + ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, + glyph_index, + &vertBearingY, + &vertAdvance ); metrics->vertBearingY = vertBearingY; metrics->vertAdvance = vertAdvance; } @@ -3041,7 +3064,9 @@ metrics->width = cbox.xMax - cbox.xMin; metrics->height = cbox.yMax - cbox.yMin; - metrics->horiBearingX = cbox.xMin; + if ( !face->horizontal.number_Of_HMetrics ) + metrics->horiBearingX = cbox.xMin; + metrics->horiBearingY = cbox.yMax; if ( has_vertical_info ) diff --git a/freetype/src/cff/cffgload.h b/freetype/src/cff/cffgload.h index 41df7db69..5f2655f3d 100644 --- a/freetype/src/cff/cffgload.h +++ b/freetype/src/cff/cffgload.h @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (specification). */ /* */ -/* Copyright 1996-2004, 2006-2009, 2013 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, */ @@ -29,7 +29,12 @@ FT_BEGIN_HEADER #define CFF_MAX_OPERANDS 48 -#define CFF_MAX_SUBRS_CALLS 32 +#define CFF_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */ + /* only 10 are allowed but there exist */ + /* fonts like `HiraKakuProN-W3.ttf' */ + /* (Hiragino Kaku Gothic ProN W3; */ + /* 8.2d6e1; 2014-12-19) that exceed */ + /* this limit */ #define CFF_MAX_TRANS_ELEMENTS 32 diff --git a/freetype/src/cff/cffload.c b/freetype/src/cff/cffload.c index d9bec5966..fcb7348e8 100644 --- a/freetype/src/cff/cffload.c +++ b/freetype/src/cff/cffload.c @@ -4,7 +4,7 @@ /* */ /* OpenType and CFF data/program tables loader (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, */ @@ -357,7 +357,7 @@ case 3: for ( ; p < p_end; p += 3, poff++ ) - poff[0] = FT_PEEK_OFF3( p ); + poff[0] = FT_PEEK_UOFF3( p ); break; default: @@ -809,7 +809,7 @@ /* When multiple GIDs map to the same CID, we choose the lowest */ /* GID. This is not described in any spec, but it matches the */ /* behaviour of recent Acroread versions. */ - for ( j = num_glyphs - 1; j >= 0 ; j-- ) + for ( j = (FT_Long)num_glyphs - 1; j >= 0 ; j-- ) charset->cids[charset->sids[j]] = (FT_UShort)j; charset->max_cid = max_cid; @@ -1447,7 +1447,7 @@ FT_ULong base_offset; CFF_FontRecDict dict; CFF_IndexRec string_index; - FT_Int subfont_index; + FT_UInt subfont_index; FT_ZERO( font ); @@ -1495,9 +1495,9 @@ if ( pure_cff ) { /* well, we don't really forget the `disabled' fonts... */ - subfont_index = face_index; + subfont_index = (FT_UInt)face_index; - if ( subfont_index >= (FT_Int)font->name_index.count ) + if ( subfont_index >= font->name_index.count ) { FT_ERROR(( "cff_font_load:" " invalid subfont index for pure CFF font (%d)\n", diff --git a/freetype/src/cff/cffload.h b/freetype/src/cff/cffload.h index 804961964..459e7b044 100644 --- a/freetype/src/cff/cffload.h +++ b/freetype/src/cff/cffload.h @@ -4,7 +4,7 @@ /* */ /* OpenType & CFF data/program tables loader (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2007, 2008, 2010 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/freetype/src/cff/cffobjs.c b/freetype/src/cff/cffobjs.c index da3d0190f..4a1ef115f 100644 --- a/freetype/src/cff/cffobjs.c +++ b/freetype/src/cff/cffobjs.c @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (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, */ @@ -226,8 +226,8 @@ CFF_Font font = (CFF_Font)face->extra.data; CFF_Internal internal = (CFF_Internal)size->internal; - FT_ULong top_upm = font->top_font.font_dict.units_per_em; - FT_UInt i; + FT_Long top_upm = (FT_Long)font->top_font.font_dict.units_per_em; + FT_UInt i; funcs->set_scale( internal->topfont, @@ -237,7 +237,7 @@ for ( i = font->num_subfonts; i > 0; i-- ) { CFF_SubFont sub = font->subfonts[i - 1]; - FT_ULong sub_upm = sub->font_dict.units_per_em; + FT_Long sub_upm = (FT_Long)sub->font_dict.units_per_em; FT_Pos x_scale, y_scale; @@ -298,8 +298,8 @@ CFF_Font font = (CFF_Font)cffface->extra.data; CFF_Internal internal = (CFF_Internal)size->internal; - FT_ULong top_upm = font->top_font.font_dict.units_per_em; - FT_UInt i; + FT_Long top_upm = (FT_Long)font->top_font.font_dict.units_per_em; + FT_UInt i; funcs->set_scale( internal->topfont, @@ -309,7 +309,7 @@ for ( i = font->num_subfonts; i > 0; i-- ) { CFF_SubFont sub = font->subfonts[i - 1]; - FT_ULong sub_upm = sub->font_dict.units_per_em; + FT_Long sub_upm = (FT_Long)sub->font_dict.units_per_em; FT_Pos x_scale, y_scale; @@ -342,7 +342,7 @@ FT_LOCAL_DEF( void ) cff_slot_done( FT_GlyphSlot slot ) { - slot->internal->glyph_hints = 0; + slot->internal->glyph_hints = NULL; } @@ -592,7 +592,7 @@ /* Note that this is only necessary for pure CFF and CEF fonts; */ /* SFNT based fonts use the `name' table instead. */ - cffface->num_glyphs = cff->num_glyphs; + cffface->num_glyphs = (FT_Long)cff->num_glyphs; dict = &cff->top_font.font_dict; @@ -646,7 +646,7 @@ if ( temp != 0x10000L ) { - *upm = FT_DivFix( *upm, temp ); + *upm = (FT_ULong)FT_DivFix( (FT_Long)*upm, temp ); matrix->xx = FT_DivFix( matrix->xx, temp ); matrix->yx = FT_DivFix( matrix->yx, temp ); @@ -682,7 +682,8 @@ if ( top->has_font_matrix ) { if ( top->units_per_em > 1 && sub->units_per_em > 1 ) - scaling = FT_MIN( top->units_per_em, sub->units_per_em ); + scaling = (FT_Long)FT_MIN( top->units_per_em, + sub->units_per_em ); else scaling = 1; @@ -693,9 +694,10 @@ &top->font_matrix, scaling ); - sub->units_per_em = FT_MulDiv( sub->units_per_em, - top->units_per_em, - scaling ); + sub->units_per_em = (FT_ULong) + FT_MulDiv( (FT_Long)sub->units_per_em, + (FT_Long)top->units_per_em, + scaling ); } } else @@ -713,7 +715,7 @@ if ( temp != 0x10000L ) { - *upm = FT_DivFix( *upm, temp ); + *upm = (FT_ULong)FT_DivFix( (FT_Long)*upm, temp ); matrix->xx = FT_DivFix( matrix->xx, temp ); matrix->yx = FT_DivFix( matrix->yx, temp ); @@ -733,13 +735,13 @@ /* set up num_faces */ - cffface->num_faces = cff->num_faces; + cffface->num_faces = (FT_Long)cff->num_faces; /* compute number of glyphs */ if ( dict->cid_registry != 0xFFFFU ) - cffface->num_glyphs = cff->charset.max_cid + 1; + cffface->num_glyphs = (FT_Long)( cff->charset.max_cid + 1 ); else - cffface->num_glyphs = cff->charstrings_index.count; + cffface->num_glyphs = (FT_Long)cff->charstrings_index.count; /* set global bbox, as well as EM size */ cffface->bbox.xMin = dict->font_bbox.xMin >> 16; @@ -763,7 +765,8 @@ (FT_Short)( dict->underline_thickness >> 16 ); /* retrieve font family & style name */ - cffface->family_name = cff_index_get_name( cff, face_index ); + cffface->family_name = cff_index_get_name( cff, + (FT_UInt)face_index ); if ( cffface->family_name ) { char* full = cff_index_get_sid_string( cff, diff --git a/freetype/src/cff/cffobjs.h b/freetype/src/cff/cffobjs.h index dfbf9a96b..3cc953143 100644 --- a/freetype/src/cff/cffobjs.h +++ b/freetype/src/cff/cffobjs.h @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (specification). */ /* */ -/* Copyright 1996-2004, 2006-2008, 2013 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/freetype/src/cff/cffparse.c b/freetype/src/cff/cffparse.c index c79ab623d..063b3517c 100644 --- a/freetype/src/cff/cffparse.c +++ b/freetype/src/cff/cffparse.c @@ -4,7 +4,7 @@ /* */ /* CFF token stream parser (body) */ /* */ -/* Copyright 1996-2004, 2007-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, */ @@ -129,7 +129,7 @@ FT_Long* scaling ) { FT_Byte* p = start; - FT_UInt nib; + FT_Int nib; FT_UInt phase; FT_Long result, number, exponent; @@ -166,7 +166,7 @@ } /* Get the nibble. */ - nib = ( p[0] >> phase ) & 0xF; + nib = (FT_Int)( p[0] >> phase ) & 0xF; phase = 4 - phase; if ( nib == 0xE ) @@ -559,7 +559,7 @@ offset->x = cff_parse_fixed_scaled( data++, scaling ); offset->y = cff_parse_fixed_scaled( data, scaling ); - *upm = power_tens[scaling]; + *upm = (FT_ULong)power_tens[scaling]; FT_TRACE4(( " [%f %f %f %f %f %f]\n", (double)matrix->xx / *upm / 65536, @@ -617,14 +617,34 @@ if ( parser->top >= parser->stack + 2 ) { - dict->private_size = cff_parse_num( data++ ); - dict->private_offset = cff_parse_num( data ); + FT_Long tmp; + + + tmp = cff_parse_num( data++ ); + if ( tmp < 0 ) + { + FT_ERROR(( "cff_parse_private_dict: Invalid dictionary size\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + dict->private_size = (FT_ULong)tmp; + + tmp = cff_parse_num( data ); + if ( tmp < 0 ) + { + FT_ERROR(( "cff_parse_private_dict: Invalid dictionary offset\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + dict->private_offset = (FT_ULong)tmp; + FT_TRACE4(( " %lu %lu\n", dict->private_size, dict->private_offset )); error = FT_Err_Ok; } + Fail: return error; } diff --git a/freetype/src/cff/cffparse.h b/freetype/src/cff/cffparse.h index 61d91ed2e..8ad02ea1e 100644 --- a/freetype/src/cff/cffparse.h +++ b/freetype/src/cff/cffparse.h @@ -4,7 +4,7 @@ /* */ /* CFF token stream parser (specification) */ /* */ -/* Copyright 1996-2003, 2011 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/freetype/src/cff/cffpic.c b/freetype/src/cff/cffpic.c index f22e4f0d5..d40dec50e 100644 --- a/freetype/src/cff/cffpic.c +++ b/freetype/src/cff/cffpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for cff module. */ /* */ -/* Copyright 2009, 2010, 2012, 2013 by */ +/* Copyright 2009-2015 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/freetype/src/cff/cffpic.h b/freetype/src/cff/cffpic.h index 50bab4c17..a29620e07 100644 --- a/freetype/src/cff/cffpic.h +++ b/freetype/src/cff/cffpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for cff module. */ /* */ -/* Copyright 2009, 2012, 2013 by */ +/* Copyright 2009-2015 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/freetype/src/cff/cfftoken.h b/freetype/src/cff/cfftoken.h index bcb4276a7..5b32076ab 100644 --- a/freetype/src/cff/cfftoken.h +++ b/freetype/src/cff/cfftoken.h @@ -4,7 +4,7 @@ /* */ /* CFF token definitions (specification only). */ /* */ -/* Copyright 1996-2003, 2011 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/freetype/src/cff/cfftypes.h b/freetype/src/cff/cfftypes.h index 872744666..de8a5ee9b 100644 --- a/freetype/src/cff/cfftypes.h +++ b/freetype/src/cff/cfftypes.h @@ -5,7 +5,7 @@ /* Basic OpenType/CFF type definitions and interface (specification */ /* only). */ /* */ -/* Copyright 1996-2003, 2006-2008, 2010-2011, 2013 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/freetype/src/cff/module.mk b/freetype/src/cff/module.mk index ef1391c27..ba08ebcb7 100644 --- a/freetype/src/cff/module.mk +++ b/freetype/src/cff/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2000, 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, modified, diff --git a/freetype/src/cff/rules.mk b/freetype/src/cff/rules.mk index 13115c255..7f6e857e2 100644 --- a/freetype/src/cff/rules.mk +++ b/freetype/src/cff/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2001, 2003, 2011, 2013 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, modified, @@ -18,7 +18,10 @@ CFF_DIR := $(SRC_DIR)/cff -CFF_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(CFF_DIR)) +CFF_COMPILE := $(CC) $(ANSIFLAGS) \ + $I$(subst /,$(COMPILER_SEP),$(CFF_DIR)) \ + $(INCLUDE_FLAGS) \ + $(FT_CFLAGS) # CFF driver sources (i.e., C files) |