diff options
author | marha <marha@users.sourceforge.net> | 2013-06-21 10:45:51 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-06-21 10:48:19 +0200 |
commit | fa791414601df61d20d860299dba80fdb62565df (patch) | |
tree | eecc4c74bb78dece330009c571ed57d7f1aaede2 /freetype/src/psaux | |
parent | 7f9fb534564d0eb8a62cf444e569a07166e5ee03 (diff) | |
download | vcxsrv-fa791414601df61d20d860299dba80fdb62565df.tar.gz vcxsrv-fa791414601df61d20d860299dba80fdb62565df.tar.bz2 vcxsrv-fa791414601df61d20d860299dba80fdb62565df.zip |
Upgraded freetype to 2.5.0.1
Diffstat (limited to 'freetype/src/psaux')
-rw-r--r-- | freetype/src/psaux/afmparse.c | 45 | ||||
-rw-r--r-- | freetype/src/psaux/psconv.c | 4 | ||||
-rw-r--r-- | freetype/src/psaux/psobjs.c | 141 | ||||
-rw-r--r-- | freetype/src/psaux/t1decode.c | 66 |
4 files changed, 157 insertions, 99 deletions
diff --git a/freetype/src/psaux/afmparse.c b/freetype/src/psaux/afmparse.c index 5f3f9e615..6a40e110d 100644 --- a/freetype/src/psaux/afmparse.c +++ b/freetype/src/psaux/afmparse.c @@ -4,7 +4,7 @@ /* */ /* AFM parser (body). */ /* */ -/* Copyright 2006-2010, 2012 by */ +/* Copyright 2006-2010, 2012, 2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,6 +17,7 @@ #include <ft2build.h> #include FT_FREETYPE_H +#include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_POSTSCRIPT_AUX_H #include "afmparse.h" @@ -119,7 +120,6 @@ afm_stream_read_one( AFM_Stream stream ) { char* str; - int ch; afm_stream_skip_spaces( stream ); @@ -130,7 +130,9 @@ while ( 1 ) { - ch = AFM_GETC(); + int ch = AFM_GETC(); + + if ( AFM_IS_SPACE( ch ) ) break; else if ( AFM_IS_NEWLINE( ch ) ) @@ -159,7 +161,6 @@ afm_stream_read_string( AFM_Stream stream ) { char* str; - int ch; afm_stream_skip_spaces( stream ); @@ -171,7 +172,9 @@ /* scan to eol */ while ( 1 ) { - ch = AFM_GETC(); + int ch = AFM_GETC(); + + if ( AFM_IS_NEWLINE( ch ) ) { stream->status = AFM_STREAM_STATUS_EOL; @@ -545,7 +548,7 @@ parser->FontInfo = NULL; parser->get_index = NULL; - return PSaux_Err_Ok; + return FT_Err_Ok; } @@ -572,10 +575,10 @@ { *aint = val.u.i; - return PSaux_Err_Ok; + return FT_Err_Ok; } else - return PSaux_Err_Syntax_Error; + return FT_THROW( Syntax_Error ); } @@ -637,7 +640,7 @@ case AFM_TOKEN_ENDKERNDATA: case AFM_TOKEN_ENDFONTMETRICS: fi->NumTrackKern = n + 1; - return PSaux_Err_Ok; + return FT_Err_Ok; case AFM_TOKEN_UNKNOWN: break; @@ -648,7 +651,7 @@ } Fail: - return PSaux_Err_Syntax_Error; + return FT_THROW( Syntax_Error ); } @@ -753,7 +756,7 @@ ft_qsort( fi->KernPairs, fi->NumKernPair, sizeof ( AFM_KernPairRec ), afm_compare_kern_pairs ); - return PSaux_Err_Ok; + return FT_Err_Ok; case AFM_TOKEN_UNKNOWN: break; @@ -764,7 +767,7 @@ } Fail: - return PSaux_Err_Syntax_Error; + return FT_THROW( Syntax_Error ); } @@ -795,7 +798,7 @@ case AFM_TOKEN_ENDKERNDATA: case AFM_TOKEN_ENDFONTMETRICS: - return PSaux_Err_Ok; + return FT_Err_Ok; case AFM_TOKEN_UNKNOWN: break; @@ -806,7 +809,7 @@ } Fail: - return PSaux_Err_Syntax_Error; + return FT_THROW( Syntax_Error ); } @@ -832,11 +835,11 @@ if ( token == end_section || token == AFM_TOKEN_ENDFONTMETRICS ) - return PSaux_Err_Ok; + return FT_Err_Ok; } Fail: - return PSaux_Err_Syntax_Error; + return FT_THROW( Syntax_Error ); } @@ -845,19 +848,19 @@ { FT_Memory memory = parser->memory; AFM_FontInfo fi = parser->FontInfo; - FT_Error error = PSaux_Err_Syntax_Error; + FT_Error error = FT_ERR( Syntax_Error ); char* key; FT_Offset len; FT_Int metrics_sets = 0; if ( !fi ) - return PSaux_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); key = afm_parser_next_key( parser, 1, &len ); if ( !key || len != 16 || ft_strncmp( key, "StartFontMetrics", 16 ) != 0 ) - return PSaux_Err_Unknown_File_Format; + return FT_THROW( Unknown_File_Format ); while ( ( key = afm_parser_next_key( parser, 1, &len ) ) != 0 ) { @@ -872,7 +875,7 @@ if ( metrics_sets != 0 && metrics_sets != 2 ) { - error = PSaux_Err_Unimplemented_Feature; + error = FT_THROW( Unimplemented_Feature ); goto Fail; } @@ -938,7 +941,7 @@ /* fall through since we only support kern data */ case AFM_TOKEN_ENDFONTMETRICS: - return PSaux_Err_Ok; + return FT_Err_Ok; default: break; diff --git a/freetype/src/psaux/psconv.c b/freetype/src/psaux/psconv.c index b7870c5ae..d0d8861c2 100644 --- a/freetype/src/psaux/psconv.c +++ b/freetype/src/psaux/psconv.c @@ -4,7 +4,7 @@ /* */ /* Some convenience conversions (body). */ /* */ -/* Copyright 2006, 2008, 2009, 2012 by */ +/* Copyright 2006, 2008, 2009, 2012-2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -229,7 +229,7 @@ if ( integral > 0x7FFF ) have_overflow = 1; else - integral <<= 16; + integral = (FT_Fixed)( (FT_UInt32)integral << 16 ); } /* read the decimal part */ diff --git a/freetype/src/psaux/psobjs.c b/freetype/src/psaux/psobjs.c index 06df6e664..dd976d3a9 100644 --- a/freetype/src/psaux/psobjs.c +++ b/freetype/src/psaux/psobjs.c @@ -4,7 +4,7 @@ /* */ /* Auxiliary functions for PostScript fonts (body). */ /* */ -/* Copyright 1996-2012 by */ +/* Copyright 1996-2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -113,8 +113,8 @@ static FT_Error - reallocate_t1_table( PS_Table table, - FT_Long new_size ) + reallocate_t1_table( PS_Table table, + FT_Offset new_size ) { FT_Memory memory = table->memory; FT_Byte* old_base = table->block; @@ -138,7 +138,7 @@ table->capacity = new_size; - return PSaux_Err_Ok; + return FT_Err_Ok; } @@ -173,13 +173,13 @@ if ( idx < 0 || idx >= table->max_elems ) { FT_ERROR(( "ps_table_add: invalid index\n" )); - return PSaux_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); } if ( length < 0 ) { FT_ERROR(( "ps_table_add: invalid length\n" )); - return PSaux_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); } /* grow the base block if needed */ @@ -216,7 +216,7 @@ FT_MEM_COPY( table->block + table->cursor, object, length ); table->cursor += length; - return PSaux_Err_Ok; + return FT_Err_Ok; } @@ -341,7 +341,7 @@ { FT_Byte* cur = *acur; FT_Int embed = 0; - FT_Error error = PSaux_Err_Invalid_File_Format; + FT_Error error = FT_ERR( Invalid_File_Format ); unsigned int i; @@ -397,7 +397,7 @@ embed--; if ( embed == 0 ) { - error = PSaux_Err_Ok; + error = FT_Err_Ok; break; } } @@ -416,7 +416,7 @@ FT_Byte* limit ) { FT_Byte* cur = *acur; - FT_Error err = PSaux_Err_Ok; + FT_Error err = FT_Err_Ok; while ( ++cur < limit ) @@ -433,7 +433,7 @@ if ( cur < limit && *cur != '>' ) { FT_ERROR(( "skip_string: missing closing delimiter `>'\n" )); - err = PSaux_Err_Invalid_File_Format; + err = FT_THROW( Invalid_File_Format ); } else cur++; @@ -456,12 +456,12 @@ { FT_Byte* cur; FT_Int embed = 0; - FT_Error error = PSaux_Err_Ok; + FT_Error error = FT_Err_Ok; FT_ASSERT( **acur == '{' ); - for ( cur = *acur; cur < limit && error == PSaux_Err_Ok; ++cur ) + for ( cur = *acur; cur < limit && error == FT_Err_Ok; ++cur ) { switch ( *cur ) { @@ -494,7 +494,7 @@ end: if ( embed != 0 ) - error = PSaux_Err_Invalid_File_Format; + error = FT_THROW( Invalid_File_Format ); *acur = cur; @@ -519,7 +519,7 @@ FT_Byte* cur = parser->cursor; FT_Byte* limit = parser->limit; - FT_Error error = PSaux_Err_Ok; + FT_Error error = FT_Err_Ok; skip_spaces( &cur, limit ); /* this also skips comments */ @@ -567,7 +567,7 @@ { FT_ERROR(( "ps_parser_skip_PS_token:" " unexpected closing delimiter `>'\n" )); - error = PSaux_Err_Invalid_File_Format; + error = FT_THROW( Invalid_File_Format ); goto Exit; } cur++; @@ -597,7 +597,7 @@ " but invalid at this point\n", *cur )); - error = PSaux_Err_Invalid_File_Format; + error = FT_THROW( Invalid_File_Format ); } parser->error = error; @@ -644,7 +644,7 @@ token->type = T1_TOKEN_TYPE_STRING; token->start = cur; - if ( skip_literal_string( &cur, limit ) == PSaux_Err_Ok ) + if ( skip_literal_string( &cur, limit ) == FT_Err_Ok ) token->limit = cur; break; @@ -653,7 +653,7 @@ token->type = T1_TOKEN_TYPE_ARRAY; token->start = cur; - if ( skip_procedure( &cur, limit ) == PSaux_Err_Ok ) + if ( skip_procedure( &cur, limit ) == FT_Err_Ok ) token->limit = cur; break; @@ -1027,12 +1027,13 @@ FT_UInt max_objects, FT_ULong* pflags ) { - T1_TokenRec token; - FT_Byte* cur; - FT_Byte* limit; - FT_UInt count; - FT_UInt idx; - FT_Error error; + T1_TokenRec token; + FT_Byte* cur; + FT_Byte* limit; + FT_UInt count; + FT_UInt idx; + FT_Error error; + T1_FieldType type; /* this also skips leading whitespace */ @@ -1045,8 +1046,10 @@ cur = token.start; limit = token.limit; + type = field->type; + /* we must detect arrays in /FontBBox */ - if ( field->type == T1_FIELD_TYPE_BBOX ) + if ( type == T1_FIELD_TYPE_BBOX ) { T1_TokenRec token2; FT_Byte* old_cur = parser->cursor; @@ -1062,17 +1065,21 @@ parser->limit = old_limit; if ( token2.type == T1_TOKEN_TYPE_ARRAY ) + { + type = T1_FIELD_TYPE_MM_BBOX; goto FieldArray; + } } else if ( token.type == T1_TOKEN_TYPE_ARRAY ) { + count = max_objects; + FieldArray: /* if this is an array and we have no blend, an error occurs */ if ( max_objects == 0 ) goto Fail; - count = max_objects; - idx = 1; + idx = 1; /* don't include delimiters */ cur++; @@ -1088,7 +1095,7 @@ skip_spaces( &cur, limit ); - switch ( field->type ) + switch ( type ) { case T1_FIELD_TYPE_BOOL: val = ps_tobool( &cur, limit ); @@ -1160,7 +1167,7 @@ " " " but found token of type %d instead\n", token.type )); - error = PSaux_Err_Invalid_File_Format; + error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -1197,7 +1204,7 @@ { FT_ERROR(( "ps_parser_load_field:" " expected four integers in bounding box\n" )); - error = PSaux_Err_Invalid_File_Format; + error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -1208,6 +1215,54 @@ } break; + case T1_FIELD_TYPE_MM_BBOX: + { + FT_Memory memory = parser->memory; + FT_Fixed* temp; + FT_Int result; + FT_UInt i; + + + if ( FT_NEW_ARRAY( temp, max_objects * 4 ) ) + goto Exit; + + for ( i = 0; i < 4; i++ ) + { + result = ps_tofixedarray( &cur, limit, max_objects, + temp + i * max_objects, 0 ); + if ( result < 0 ) + { + FT_ERROR(( "ps_parser_load_field:" + " expected %d integers in the %s subarray\n" + " " + " of /FontBBox in the /Blend dictionary\n", + max_objects, + i == 0 ? "first" + : ( i == 1 ? "second" + : ( i == 2 ? "third" + : "fourth" ) ) )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + skip_spaces( &cur, limit ); + } + + for ( i = 0; i < max_objects; i++ ) + { + FT_BBox* bbox = (FT_BBox*)objects[i]; + + + bbox->xMin = FT_RoundFix( temp[i ] ); + bbox->yMin = FT_RoundFix( temp[i + max_objects] ); + bbox->xMax = FT_RoundFix( temp[i + 2 * max_objects] ); + bbox->yMax = FT_RoundFix( temp[i + 3 * max_objects] ); + } + + FT_FREE( temp ); + } + break; + default: /* an error occurred */ goto Fail; @@ -1221,13 +1276,13 @@ FT_UNUSED( pflags ); #endif - error = PSaux_Err_Ok; + error = FT_Err_Ok; Exit: return error; Fail: - error = PSaux_Err_Invalid_File_Format; + error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -1245,7 +1300,7 @@ T1_TokenRec elements[T1_MAX_TABLE_ELEMENTS]; T1_Token token; FT_Int num_elements; - FT_Error error = PSaux_Err_Ok; + FT_Error error = FT_Err_Ok; FT_Byte* old_cursor; FT_Byte* old_limit; T1_FieldRec fieldrec = *(T1_Field)field; @@ -1260,7 +1315,7 @@ T1_MAX_TABLE_ELEMENTS, &num_elements ); if ( num_elements < 0 ) { - error = PSaux_Err_Ignore; + error = FT_ERR( Ignore ); goto Exit; } if ( (FT_UInt)num_elements > field->array_max ) @@ -1317,7 +1372,7 @@ FT_Long* pnum_bytes, FT_Bool delimiters ) { - FT_Error error = PSaux_Err_Ok; + FT_Error error = FT_Err_Ok; FT_Byte* cur; @@ -1332,7 +1387,7 @@ if ( *cur != '<' ) { FT_ERROR(( "ps_parser_to_bytes: Missing starting delimiter `<'\n" )); - error = PSaux_Err_Invalid_File_Format; + error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -1349,7 +1404,7 @@ if ( cur < parser->limit && *cur != '>' ) { FT_ERROR(( "ps_parser_to_bytes: Missing closing delimiter `>'\n" )); - error = PSaux_Err_Invalid_File_Format; + error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -1419,7 +1474,7 @@ FT_Byte* limit, FT_Memory memory ) { - parser->error = PSaux_Err_Ok; + parser->error = FT_Err_Ok; parser->base = base; parser->limit = limit; parser->cursor = base; @@ -1592,13 +1647,13 @@ if ( !outline ) { FT_ERROR(( "t1_builder_add_contour: no outline to add points to\n" )); - return PSaux_Err_Invalid_File_Format; + return FT_THROW( Invalid_File_Format ); } if ( !builder->load_points ) { outline->n_contours++; - return PSaux_Err_Ok; + return FT_Err_Ok; } error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 ); @@ -1621,13 +1676,13 @@ FT_Pos x, FT_Pos y ) { - FT_Error error = PSaux_Err_Invalid_File_Format; + FT_Error error = FT_ERR( Invalid_File_Format ); /* test whether we are building a new contour */ if ( builder->parse_state == T1_Parse_Have_Path ) - error = PSaux_Err_Ok; + error = FT_Err_Ok; else { builder->parse_state = T1_Parse_Have_Path; diff --git a/freetype/src/psaux/t1decode.c b/freetype/src/psaux/t1decode.c index 8afe02193..6ce370bfa 100644 --- a/freetype/src/psaux/t1decode.c +++ b/freetype/src/psaux/t1decode.c @@ -4,7 +4,7 @@ /* */ /* PostScript Type 1 decoding routines (body). */ /* */ -/* Copyright 2000-2012 by */ +/* Copyright 2000-2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -205,13 +205,13 @@ if ( decoder->seac ) { FT_ERROR(( "t1operator_seac: invalid nested seac\n" )); - return PSaux_Err_Syntax_Error; + return FT_THROW( Syntax_Error ); } if ( decoder->builder.metrics_only ) { FT_ERROR(( "t1operator_seac: unexpected seac\n" )); - return PSaux_Err_Syntax_Error; + return FT_THROW( Syntax_Error ); } /* seac weirdness */ @@ -228,7 +228,7 @@ { FT_ERROR(( "t1operator_seac:" " glyph names table not available in this font\n" )); - return PSaux_Err_Syntax_Error; + return FT_THROW( Syntax_Error ); } #ifdef FT_CONFIG_OPTION_INCREMENTAL @@ -249,7 +249,7 @@ { FT_ERROR(( "t1operator_seac:" " invalid seac character code arguments\n" )); - return PSaux_Err_Syntax_Error; + return FT_THROW( Syntax_Error ); } /* if we are trying to load a composite glyph, do not load the */ @@ -415,7 +415,7 @@ limit = zone->limit = charstring_base + charstring_len; ip = zone->cursor = zone->base; - error = PSaux_Err_Ok; + error = FT_Err_Ok; x = orig_x = builder->pos_x; y = orig_y = builder->pos_y; @@ -565,10 +565,10 @@ goto Syntax_Error; } - value = (FT_Int32)( ( (FT_Long)ip[0] << 24 ) | - ( (FT_Long)ip[1] << 16 ) | - ( (FT_Long)ip[2] << 8 ) | - ip[3] ); + value = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) | + ( (FT_UInt32)ip[1] << 16 ) | + ( (FT_UInt32)ip[2] << 8 ) | + (FT_UInt32)ip[3] ); ip += 4; /* According to the specification, values > 32000 or < -32000 must */ @@ -591,7 +591,7 @@ else { if ( !large_int ) - value <<= 16; + value = (FT_Int32)( (FT_UInt32)value << 16 ); } break; @@ -611,13 +611,13 @@ } if ( ip[-2] < 251 ) - value = ( ( (FT_Int32)ip[-2] - 247 ) << 8 ) + ip[-1] + 108; + value = ( ( ip[-2] - 247 ) * 256 ) + ip[-1] + 108; else - value = -( ( ( (FT_Int32)ip[-2] - 251 ) << 8 ) + ip[-1] + 108 ); + value = -( ( ( ip[-2] - 251 ) * 256 ) + ip[-1] + 108 ); } if ( !large_int ) - value <<= 16; + value = (FT_Int32)( (FT_UInt32)value << 16 ); } else { @@ -756,9 +756,9 @@ decoder->flex_state = 1; decoder->num_flex_vectors = 0; if ( ( error = t1_builder_start_point( builder, x, y ) ) - != PSaux_Err_Ok || + != FT_Err_Ok || ( error = t1_builder_check_points( builder, 6 ) ) - != PSaux_Err_Ok ) + != FT_Err_Ok ) goto Fail; break; @@ -1129,7 +1129,7 @@ FT_TRACE4(( "\n" )); /* return now! */ - return PSaux_Err_Ok; + return FT_Err_Ok; case op_hsbw: FT_TRACE4(( " hsbw" )); @@ -1149,7 +1149,7 @@ /* the glyph's metrics (lsb + advance width), not load the */ /* rest of it; so exit immediately */ if ( builder->metrics_only ) - return PSaux_Err_Ok; + return FT_Err_Ok; break; @@ -1178,7 +1178,7 @@ /* the glyph's metrics (lsb + advance width), not load the */ /* rest of it; so exit immediately */ if ( builder->metrics_only ) - return PSaux_Err_Ok; + return FT_Err_Ok; break; @@ -1197,7 +1197,7 @@ FT_TRACE4(( " hlineto" )); if ( ( error = t1_builder_start_point( builder, x, y ) ) - != PSaux_Err_Ok ) + != FT_Err_Ok ) goto Fail; x += top[0]; @@ -1219,9 +1219,9 @@ FT_TRACE4(( " hvcurveto" )); if ( ( error = t1_builder_start_point( builder, x, y ) ) - != PSaux_Err_Ok || + != FT_Err_Ok || ( error = t1_builder_check_points( builder, 3 ) ) - != PSaux_Err_Ok ) + != FT_Err_Ok ) goto Fail; x += top[0]; @@ -1237,7 +1237,7 @@ FT_TRACE4(( " rlineto" )); if ( ( error = t1_builder_start_point( builder, x, y ) ) - != PSaux_Err_Ok ) + != FT_Err_Ok ) goto Fail; x += top[0]; @@ -1245,7 +1245,7 @@ Add_Line: if ( ( error = t1_builder_add_point1( builder, x, y ) ) - != PSaux_Err_Ok ) + != FT_Err_Ok ) goto Fail; break; @@ -1266,9 +1266,9 @@ FT_TRACE4(( " rrcurveto" )); if ( ( error = t1_builder_start_point( builder, x, y ) ) - != PSaux_Err_Ok || + != FT_Err_Ok || ( error = t1_builder_check_points( builder, 3 ) ) - != PSaux_Err_Ok ) + != FT_Err_Ok ) goto Fail; x += top[0]; @@ -1288,9 +1288,9 @@ FT_TRACE4(( " vhcurveto" )); if ( ( error = t1_builder_start_point( builder, x, y ) ) - != PSaux_Err_Ok || + != FT_Err_Ok || ( error = t1_builder_check_points( builder, 3 ) ) - != PSaux_Err_Ok ) + != FT_Err_Ok ) goto Fail; y += top[0]; @@ -1306,7 +1306,7 @@ FT_TRACE4(( " vlineto" )); if ( ( error = t1_builder_start_point( builder, x, y ) ) - != PSaux_Err_Ok ) + != FT_Err_Ok ) goto Fail; y += top[0]; @@ -1545,10 +1545,10 @@ return error; Syntax_Error: - return PSaux_Err_Syntax_Error; + return FT_THROW( Syntax_Error ); Stack_Underflow: - return PSaux_Err_Stack_Underflow; + return FT_THROW( Stack_Underflow ); } @@ -1585,7 +1585,7 @@ { FT_ERROR(( "t1_decoder_init:" " the `psnames' module is not available\n" )); - return PSaux_Err_Unimplemented_Feature; + return FT_THROW( Unimplemented_Feature ); } decoder->psnames = psnames; @@ -1605,7 +1605,7 @@ decoder->funcs = t1_decoder_funcs; - return PSaux_Err_Ok; + return FT_Err_Ok; } |