diff options
Diffstat (limited to 'third_party/freetype/src/cid')
-rw-r--r-- | third_party/freetype/src/cid/Jamfile | 9 | ||||
-rw-r--r-- | third_party/freetype/src/cid/ciderrs.h | 2 | ||||
-rw-r--r-- | third_party/freetype/src/cid/cidgload.c | 56 | ||||
-rw-r--r-- | third_party/freetype/src/cid/cidgload.h | 2 | ||||
-rw-r--r-- | third_party/freetype/src/cid/cidload.c | 48 | ||||
-rw-r--r-- | third_party/freetype/src/cid/cidload.h | 4 | ||||
-rw-r--r-- | third_party/freetype/src/cid/cidobjs.c | 18 | ||||
-rw-r--r-- | third_party/freetype/src/cid/cidobjs.h | 2 | ||||
-rw-r--r-- | third_party/freetype/src/cid/cidparse.c | 19 | ||||
-rw-r--r-- | third_party/freetype/src/cid/cidparse.h | 6 | ||||
-rw-r--r-- | third_party/freetype/src/cid/cidriver.c | 6 | ||||
-rw-r--r-- | third_party/freetype/src/cid/cidriver.h | 2 | ||||
-rw-r--r-- | third_party/freetype/src/cid/cidtoken.h | 2 | ||||
-rw-r--r-- | third_party/freetype/src/cid/type1cid.c | 2 |
14 files changed, 101 insertions, 77 deletions
diff --git a/third_party/freetype/src/cid/Jamfile b/third_party/freetype/src/cid/Jamfile index ebeaed54ea..64e1523157 100644 --- a/third_party/freetype/src/cid/Jamfile +++ b/third_party/freetype/src/cid/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/cid Jamfile # -# Copyright 2001 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, @@ -16,7 +16,12 @@ SubDir FT2_TOP $(FT2_SRC_DIR) cid ; if $(FT2_MULTI) { - _sources = cidobjs cidload cidgload cidriver cidparse ; + _sources = cidgload + cidload + cidobjs + cidparse + cidriver + ; } else { diff --git a/third_party/freetype/src/cid/ciderrs.h b/third_party/freetype/src/cid/ciderrs.h index ef13155504..5e0e776ee1 100644 --- a/third_party/freetype/src/cid/ciderrs.h +++ b/third_party/freetype/src/cid/ciderrs.h @@ -4,7 +4,7 @@ /* */ /* CID 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/third_party/freetype/src/cid/cidgload.c b/third_party/freetype/src/cid/cidgload.c index 7febab81c4..d00674fe0d 100644 --- a/third_party/freetype/src/cid/cidgload.c +++ b/third_party/freetype/src/cid/cidgload.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 Glyph Loader (body). */ /* */ -/* Copyright 1996-2007, 2009, 2010, 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, */ @@ -44,10 +44,10 @@ CID_Face face = (CID_Face)decoder->builder.face; CID_FaceInfo cid = &face->cid; FT_Byte* p; - FT_UInt fd_select; + FT_ULong fd_select; FT_Stream stream = face->cid_stream; FT_Error error = FT_Err_Ok; - FT_Byte* charstring = 0; + FT_Byte* charstring = NULL; FT_Memory memory = face->root.memory; FT_ULong glyph_length = 0; PSAux_Service psaux = (PSAux_Service)face->psaux; @@ -75,11 +75,11 @@ goto Exit; p = (FT_Byte*)glyph_data.pointer; - fd_select = (FT_UInt)cid_get_offset( &p, (FT_Byte)cid->fd_bytes ); + fd_select = cid_get_offset( &p, (FT_Byte)cid->fd_bytes ); if ( glyph_data.length != 0 ) { - glyph_length = glyph_data.length - cid->fd_bytes; + glyph_length = (FT_ULong)( glyph_data.length - cid->fd_bytes ); (void)FT_ALLOC( charstring, glyph_length ); if ( !error ) ft_memcpy( charstring, glyph_data.pointer + cid->fd_bytes, @@ -99,7 +99,7 @@ /* For ordinary fonts read the CID font dictionary index */ /* and charstring offset from the CIDMap. */ { - FT_UInt entry_len = cid->fd_bytes + cid->gd_bytes; + FT_UInt entry_len = (FT_UInt)( cid->fd_bytes + cid->gd_bytes ); FT_ULong off1; @@ -109,13 +109,13 @@ goto Exit; p = (FT_Byte*)stream->cursor; - fd_select = (FT_UInt) cid_get_offset( &p, (FT_Byte)cid->fd_bytes ); - off1 = (FT_ULong)cid_get_offset( &p, (FT_Byte)cid->gd_bytes ); + fd_select = cid_get_offset( &p, (FT_Byte)cid->fd_bytes ); + off1 = cid_get_offset( &p, (FT_Byte)cid->gd_bytes ); p += cid->fd_bytes; glyph_length = cid_get_offset( &p, (FT_Byte)cid->gd_bytes ) - off1; FT_FRAME_EXIT(); - if ( fd_select >= (FT_UInt)cid->num_dicts ) + if ( fd_select >= (FT_ULong)cid->num_dicts ) { error = FT_THROW( Invalid_Offset ); goto Exit; @@ -133,7 +133,7 @@ { CID_FaceDict dict; CID_Subrs cid_subrs = face->subrs + fd_select; - FT_Int cs_offset; + FT_UInt cs_offset; /* Set up subrs */ @@ -151,7 +151,7 @@ /* Decode the charstring. */ /* Adjustment for seed bytes. */ - cs_offset = ( decoder->lenIV >= 0 ? decoder->lenIV : 0 ); + cs_offset = decoder->lenIV >= 0 ? (FT_UInt)decoder->lenIV : 0; /* Decrypt only if lenIV >= 0. */ if ( decoder->lenIV >= 0 ) @@ -159,7 +159,7 @@ error = decoder->funcs.parse_charstrings( decoder, charstring + cs_offset, - (FT_Int)glyph_length - cs_offset ); + glyph_length - cs_offset ); } FT_FREE( charstring ); @@ -357,7 +357,6 @@ { FT_BBox cbox; FT_Glyph_Metrics* metrics = &cidglyph->metrics; - FT_Vector advance; /* copy the _unscaled_ advance width */ @@ -377,22 +376,27 @@ if ( cidsize->metrics.y_ppem < 24 ) cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION; - /* apply the font matrix */ - FT_Outline_Transform( &cidglyph->outline, &font_matrix ); + /* apply the font matrix, if any */ + if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L || + font_matrix.xy != 0 || font_matrix.yx != 0 ) + { + FT_Outline_Transform( &cidglyph->outline, &font_matrix ); - FT_Outline_Translate( &cidglyph->outline, - font_offset.x, - font_offset.y ); + metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, + font_matrix.xx ); + metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, + font_matrix.yy ); + } - advance.x = metrics->horiAdvance; - advance.y = 0; - FT_Vector_Transform( &advance, &font_matrix ); - metrics->horiAdvance = advance.x + font_offset.x; + if ( font_offset.x || font_offset.y ) + { + FT_Outline_Translate( &cidglyph->outline, + font_offset.x, + font_offset.y ); - advance.x = 0; - advance.y = metrics->vertAdvance; - FT_Vector_Transform( &advance, &font_matrix ); - metrics->vertAdvance = advance.y + font_offset.y; + metrics->horiAdvance += font_offset.x; + metrics->vertAdvance += font_offset.y; + } if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ) { diff --git a/third_party/freetype/src/cid/cidgload.h b/third_party/freetype/src/cid/cidgload.h index a0a91bfea8..4a10ce505c 100644 --- a/third_party/freetype/src/cid/cidgload.h +++ b/third_party/freetype/src/cid/cidgload.h @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2004 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/third_party/freetype/src/cid/cidload.c b/third_party/freetype/src/cid/cidload.c index 1cda0eee7a..e23b82f673 100644 --- a/third_party/freetype/src/cid/cidload.c +++ b/third_party/freetype/src/cid/cidload.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 font loader (body). */ /* */ -/* Copyright 1996-2006, 2009, 2011-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, */ @@ -38,7 +38,7 @@ /* read a single offset */ - FT_LOCAL_DEF( FT_Long ) + FT_LOCAL_DEF( FT_ULong ) cid_get_offset( FT_Byte* *start, FT_Byte offsize ) { @@ -53,7 +53,7 @@ } *start = p; - return (FT_Long)result; + return result; } @@ -167,6 +167,7 @@ matrix = &dict->font_matrix; offset = &dict->font_offset; + /* input is scaled by 1000 to accommodate default FontMatrix */ result = cid_parser_to_fixed_array( parser, 6, temp, 3 ); if ( result < 6 ) @@ -180,15 +181,12 @@ return FT_THROW( Invalid_File_Format ); } - /* Set Units per EM based on FontMatrix values. We set the value to */ - /* 1000 / temp_scale, because temp_scale was already multiplied by */ - /* 1000 (in t1_tofixed, from psobjs.c). */ - - root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale ); - - /* we need to scale the values by 1.0/temp[3] */ + /* atypical case */ if ( temp_scale != 0x10000L ) { + /* set units per EM based on FontMatrix values */ + root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale ); + temp[0] = FT_DivFix( temp[0], temp_scale ); temp[1] = FT_DivFix( temp[1], temp_scale ); temp[2] = FT_DivFix( temp[2], temp_scale ); @@ -222,6 +220,12 @@ num_dicts = cid_parser_to_int( parser ); + if ( num_dicts < 0 ) + { + FT_ERROR(( "parse_fd_array: invalid number of dictionaries\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } if ( !cid->font_dicts ) { @@ -231,7 +235,7 @@ if ( FT_NEW_ARRAY( cid->font_dicts, num_dicts ) ) goto Exit; - cid->num_dicts = (FT_UInt)num_dicts; + cid->num_dicts = num_dicts; /* don't forget to set a few defaults */ for ( n = 0; n < cid->num_dicts; n++ ) @@ -290,7 +294,7 @@ cid_parse_dict( CID_Face face, CID_Loader* loader, FT_Byte* base, - FT_Long size ) + FT_ULong size ) { CID_Parser* parser = &loader->parser; @@ -342,11 +346,11 @@ /* look for immediates */ if ( *cur == '/' && cur + 2 < limit ) { - FT_PtrDist len; + FT_UInt len; cur++; - len = parser->root.cursor - cur; + len = (FT_UInt)( parser->root.cursor - cur ); if ( len > 0 && len < 22 ) { @@ -363,10 +367,10 @@ if ( !name ) break; - if ( cur[0] == name[0] && - len == (FT_PtrDist)ft_strlen( (const char*)name ) ) + if ( cur[0] == name[0] && + len == ft_strlen( (const char*)name ) ) { - FT_PtrDist n; + FT_UInt n; for ( n = 1; n < len; n++ ) @@ -407,7 +411,7 @@ FT_Int n; CID_Subrs subr; FT_UInt max_offsets = 0; - FT_ULong* offsets = 0; + FT_ULong* offsets = NULL; PSAux_Service psaux = (PSAux_Service)face->psaux; @@ -450,8 +454,8 @@ } /* read the subrmap's offsets */ - if ( FT_STREAM_SEEK( cid->data_offset + dict->subrmap_offset ) || - FT_FRAME_ENTER( ( num_subrs + 1 ) * dict->sd_bytes ) ) + if ( FT_STREAM_SEEK( cid->data_offset + dict->subrmap_offset ) || + FT_FRAME_ENTER( ( num_subrs + 1 ) * (FT_UInt)dict->sd_bytes ) ) goto Fail; p = (FT_Byte*)stream->cursor; @@ -500,7 +504,7 @@ } } - subr->num_subrs = num_subrs; + subr->num_subrs = (FT_Int)num_subrs; } Exit: @@ -546,7 +550,7 @@ static FT_Error cid_hex_to_binary( FT_Byte* data, - FT_Long data_len, + FT_ULong data_len, FT_ULong offset, CID_Face face ) { diff --git a/third_party/freetype/src/cid/cidload.h b/third_party/freetype/src/cid/cidload.h index 8c172ffee2..d7776d2f88 100644 --- a/third_party/freetype/src/cid/cidload.h +++ b/third_party/freetype/src/cid/cidload.h @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 font loader (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 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, */ @@ -36,7 +36,7 @@ FT_BEGIN_HEADER } CID_Loader; - FT_LOCAL( FT_Long ) + FT_LOCAL( FT_ULong ) cid_get_offset( FT_Byte** start, FT_Byte offsize ); diff --git a/third_party/freetype/src/cid/cidobjs.c b/third_party/freetype/src/cid/cidobjs.c index 5932ffa973..bf1519bc6e 100644 --- a/third_party/freetype/src/cid/cidobjs.c +++ b/third_party/freetype/src/cid/cidobjs.c @@ -4,7 +4,7 @@ /* */ /* CID objects manager (body). */ /* */ -/* Copyright 1996-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, */ @@ -49,7 +49,7 @@ FT_LOCAL_DEF( void ) cid_slot_done( FT_GlyphSlot slot ) { - slot->internal->glyph_hints = 0; + slot->internal->glyph_hints = NULL; } @@ -122,7 +122,7 @@ if ( funcs ) funcs->destroy( (PSH_Globals)cidsize->internal ); - cidsize->internal = 0; + cidsize->internal = NULL; } } @@ -243,8 +243,8 @@ FT_FREE( cid->registry ); FT_FREE( cid->ordering ); - cidface->family_name = 0; - cidface->style_name = 0; + cidface->family_name = NULL; + cidface->style_name = NULL; FT_FREE( face->binary_data ); FT_FREE( face->cid_stream ); @@ -334,7 +334,7 @@ /* check the face index */ /* XXX: handle CID fonts with more than a single face */ - if ( face_index != 0 ) + if ( ( face_index & 0xFFFF ) != 0 ) { FT_ERROR(( "cid_face_init: invalid face index\n" )); error = FT_THROW( Invalid_Argument ); @@ -351,10 +351,10 @@ PS_FontInfo info = &cid->font_info; - cidface->num_glyphs = cid->cid_count; + cidface->num_glyphs = (FT_Long)cid->cid_count; cidface->num_charmaps = 0; - cidface->face_index = face_index; + cidface->face_index = face_index & 0xFFFF; cidface->face_flags |= FT_FACE_FLAG_SCALABLE | /* scalable outlines */ FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ @@ -421,7 +421,7 @@ /* no embedded bitmap support */ cidface->num_fixed_sizes = 0; - cidface->available_sizes = 0; + cidface->available_sizes = NULL; cidface->bbox.xMin = cid->font_bbox.xMin >> 16; cidface->bbox.yMin = cid->font_bbox.yMin >> 16; diff --git a/third_party/freetype/src/cid/cidobjs.h b/third_party/freetype/src/cid/cidobjs.h index aee346d1c8..e9095ca68e 100644 --- a/third_party/freetype/src/cid/cidobjs.h +++ b/third_party/freetype/src/cid/cidobjs.h @@ -4,7 +4,7 @@ /* */ /* CID objects manager (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2004, 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/third_party/freetype/src/cid/cidparse.c b/third_party/freetype/src/cid/cidparse.c index d8476cdae8..c276949779 100644 --- a/third_party/freetype/src/cid/cidparse.c +++ b/third_party/freetype/src/cid/cidparse.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 parser (body). */ /* */ -/* Copyright 1996-2007, 2009, 2013, 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, */ @@ -86,13 +86,13 @@ /* `StartData' or `/sfnts' */ { FT_Byte buffer[256 + 10]; - FT_Long read_len = 256 + 10; /* same as signed FT_Stream->size */ + FT_ULong read_len = 256 + 10; FT_Byte* p = buffer; for ( offset = FT_STREAM_POS(); ; offset += 256 ) { - FT_Long stream_len; /* same as signed FT_Stream->size */ + FT_ULong stream_len; stream_len = stream->size - FT_STREAM_POS(); @@ -176,7 +176,18 @@ if ( cur[0] == 'S' && ft_strncmp( (char*)cur, "StartData", 9 ) == 0 ) { if ( ft_strncmp( (char*)arg1, "(Hex)", 5 ) == 0 ) - parser->binary_length = ft_atol( (const char *)arg2 ); + { + FT_Long tmp = ft_atol( (const char *)arg2 ); + + + if ( tmp < 0 ) + { + FT_ERROR(( "cid_parser_new: invalid length of hex data\n" )); + error = FT_THROW( Invalid_File_Format ); + } + else + parser->binary_length = (FT_ULong)tmp; + } goto Exit; } diff --git a/third_party/freetype/src/cid/cidparse.h b/third_party/freetype/src/cid/cidparse.h index f27be65a60..f581bb43ff 100644 --- a/third_party/freetype/src/cid/cidparse.h +++ b/third_party/freetype/src/cid/cidparse.h @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 parser (specification). */ /* */ -/* Copyright 1996-2004, 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, */ @@ -64,11 +64,11 @@ FT_BEGIN_HEADER FT_Stream stream; FT_Byte* postscript; - FT_Long postscript_len; + FT_ULong postscript_len; FT_ULong data_offset; - FT_Long binary_length; + FT_ULong binary_length; CID_FaceInfo cid; FT_Int num_dict; diff --git a/third_party/freetype/src/cid/cidriver.c b/third_party/freetype/src/cid/cidriver.c index 6132a27763..07c4cc410b 100644 --- a/third_party/freetype/src/cid/cidriver.c +++ b/third_party/freetype/src/cid/cidriver.c @@ -4,7 +4,7 @@ /* */ /* CID driver interface (body). */ /* */ -/* Copyright 1996-2004, 2006, 2008, 2009, 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, */ @@ -24,7 +24,7 @@ #include "ciderrs.h" #include FT_SERVICE_POSTSCRIPT_NAME_H -#include FT_SERVICE_XFREE86_NAME_H +#include FT_SERVICE_FONT_FORMAT_H #include FT_SERVICE_POSTSCRIPT_INFO_H #include FT_SERVICE_CID_H @@ -168,7 +168,7 @@ static const FT_ServiceDescRec cid_services[] = { - { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CID }, + { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CID }, { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cid_service_ps_name }, { FT_SERVICE_ID_POSTSCRIPT_INFO, &cid_service_ps_info }, { FT_SERVICE_ID_CID, &cid_service_cid_info }, diff --git a/third_party/freetype/src/cid/cidriver.h b/third_party/freetype/src/cid/cidriver.h index 3c45e06886..e5b8678464 100644 --- a/third_party/freetype/src/cid/cidriver.h +++ b/third_party/freetype/src/cid/cidriver.h @@ -4,7 +4,7 @@ /* */ /* High-level CID 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/third_party/freetype/src/cid/cidtoken.h b/third_party/freetype/src/cid/cidtoken.h index 904cb09cf4..82eae0ca6b 100644 --- a/third_party/freetype/src/cid/cidtoken.h +++ b/third_party/freetype/src/cid/cidtoken.h @@ -4,7 +4,7 @@ /* */ /* CID token definitions (specification only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2006, 2008, 2009 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/third_party/freetype/src/cid/type1cid.c b/third_party/freetype/src/cid/type1cid.c index 0b866e97c4..0d54ca7f44 100644 --- a/third_party/freetype/src/cid/type1cid.c +++ b/third_party/freetype/src/cid/type1cid.c @@ -4,7 +4,7 @@ /* */ /* FreeType OpenType driver component (body only). */ /* */ -/* Copyright 1996-2001 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, */ |