| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* psobjs.c */ | 3 /* psobjs.c */ |
| 4 /* */ | 4 /* */ |
| 5 /* Auxiliary functions for PostScript fonts (body). */ | 5 /* Auxiliary functions for PostScript fonts (body). */ |
| 6 /* */ | 6 /* */ |
| 7 /* Copyright 1996-2014 by */ | 7 /* Copyright 1996-2015 by */ |
| 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 9 /* */ | 9 /* */ |
| 10 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
| 11 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
| 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
| 14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
| 15 /* */ | 15 /* */ |
| 16 /***************************************************************************/ | 16 /***************************************************************************/ |
| 17 | 17 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 | 75 |
| 76 table->memory = memory; | 76 table->memory = memory; |
| 77 if ( FT_NEW_ARRAY( table->elements, count ) || | 77 if ( FT_NEW_ARRAY( table->elements, count ) || |
| 78 FT_NEW_ARRAY( table->lengths, count ) ) | 78 FT_NEW_ARRAY( table->lengths, count ) ) |
| 79 goto Exit; | 79 goto Exit; |
| 80 | 80 |
| 81 table->max_elems = count; | 81 table->max_elems = count; |
| 82 table->init = 0xDEADBEEFUL; | 82 table->init = 0xDEADBEEFUL; |
| 83 table->num_elems = 0; | 83 table->num_elems = 0; |
| 84 table->block = 0; | 84 table->block = NULL; |
| 85 table->capacity = 0; | 85 table->capacity = 0; |
| 86 table->cursor = 0; | 86 table->cursor = 0; |
| 87 | 87 |
| 88 *(PS_Table_FuncsRec*)&table->funcs = ps_table_funcs; | 88 *(PS_Table_FuncsRec*)&table->funcs = ps_table_funcs; |
| 89 | 89 |
| 90 Exit: | 90 Exit: |
| 91 if ( error ) | 91 if ( error ) |
| 92 FT_FREE( table->elements ); | 92 FT_FREE( table->elements ); |
| 93 | 93 |
| 94 return error; | 94 return error; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 /* */ | 158 /* */ |
| 159 /* object :: The address of the object to copy in memory. */ | 159 /* object :: The address of the object to copy in memory. */ |
| 160 /* */ | 160 /* */ |
| 161 /* length :: The length in bytes of the source object. */ | 161 /* length :: The length in bytes of the source object. */ |
| 162 /* */ | 162 /* */ |
| 163 /* <Return> */ | 163 /* <Return> */ |
| 164 /* FreeType error code. 0 means success. An error is returned if a */ | 164 /* FreeType error code. 0 means success. An error is returned if a */ |
| 165 /* reallocation fails. */ | 165 /* reallocation fails. */ |
| 166 /* */ | 166 /* */ |
| 167 FT_LOCAL_DEF( FT_Error ) | 167 FT_LOCAL_DEF( FT_Error ) |
| 168 ps_table_add( PS_Table table, | 168 ps_table_add( PS_Table table, |
| 169 FT_Int idx, | 169 FT_Int idx, |
| 170 void* object, | 170 void* object, |
| 171 FT_PtrDist length ) | 171 FT_UInt length ) |
| 172 { | 172 { |
| 173 if ( idx < 0 || idx >= table->max_elems ) | 173 if ( idx < 0 || idx >= table->max_elems ) |
| 174 { | 174 { |
| 175 FT_ERROR(( "ps_table_add: invalid index\n" )); | 175 FT_ERROR(( "ps_table_add: invalid index\n" )); |
| 176 return FT_THROW( Invalid_Argument ); | 176 return FT_THROW( Invalid_Argument ); |
| 177 } | 177 } |
| 178 | 178 |
| 179 if ( length < 0 ) | |
| 180 { | |
| 181 FT_ERROR(( "ps_table_add: invalid length\n" )); | |
| 182 return FT_THROW( Invalid_Argument ); | |
| 183 } | |
| 184 | |
| 185 /* grow the base block if needed */ | 179 /* grow the base block if needed */ |
| 186 if ( table->cursor + length > table->capacity ) | 180 if ( table->cursor + length > table->capacity ) |
| 187 { | 181 { |
| 188 FT_Error error; | 182 FT_Error error; |
| 189 FT_Offset new_size = table->capacity; | 183 FT_Offset new_size = table->capacity; |
| 190 FT_PtrDist in_offset; | 184 FT_PtrDist in_offset; |
| 191 | 185 |
| 192 | 186 |
| 193 in_offset = (FT_Byte*)object - table->block; | 187 in_offset = (FT_Byte*)object - table->block; |
| 194 if ( in_offset < 0 || (FT_Offset)in_offset >= table->capacity ) | 188 if ( in_offset < 0 || (FT_Offset)in_offset >= table->capacity ) |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 { | 587 { |
| 594 FT_ERROR(( "ps_parser_skip_PS_token:" | 588 FT_ERROR(( "ps_parser_skip_PS_token:" |
| 595 " current token is `%c' which is self-delimiting\n" | 589 " current token is `%c' which is self-delimiting\n" |
| 596 " " | 590 " " |
| 597 " but invalid at this point\n", | 591 " but invalid at this point\n", |
| 598 *cur )); | 592 *cur )); |
| 599 | 593 |
| 600 error = FT_THROW( Invalid_File_Format ); | 594 error = FT_THROW( Invalid_File_Format ); |
| 601 } | 595 } |
| 602 | 596 |
| 597 if ( cur > limit ) |
| 598 cur = limit; |
| 599 |
| 603 parser->error = error; | 600 parser->error = error; |
| 604 parser->cursor = cur; | 601 parser->cursor = cur; |
| 605 } | 602 } |
| 606 | 603 |
| 607 | 604 |
| 608 FT_LOCAL_DEF( void ) | 605 FT_LOCAL_DEF( void ) |
| 609 ps_parser_skip_spaces( PS_Parser parser ) | 606 ps_parser_skip_spaces( PS_Parser parser ) |
| 610 { | 607 { |
| 611 skip_spaces( &parser->cursor, parser->limit ); | 608 skip_spaces( &parser->cursor, parser->limit ); |
| 612 } | 609 } |
| 613 | 610 |
| 614 | 611 |
| 615 /* `token' here means either something between balanced delimiters */ | 612 /* `token' here means either something between balanced delimiters */ |
| 616 /* or the next token; the delimiters are not removed. */ | 613 /* or the next token; the delimiters are not removed. */ |
| 617 | 614 |
| 618 FT_LOCAL_DEF( void ) | 615 FT_LOCAL_DEF( void ) |
| 619 ps_parser_to_token( PS_Parser parser, | 616 ps_parser_to_token( PS_Parser parser, |
| 620 T1_Token token ) | 617 T1_Token token ) |
| 621 { | 618 { |
| 622 FT_Byte* cur; | 619 FT_Byte* cur; |
| 623 FT_Byte* limit; | 620 FT_Byte* limit; |
| 624 FT_Int embed; | 621 FT_Int embed; |
| 625 | 622 |
| 626 | 623 |
| 627 token->type = T1_TOKEN_TYPE_NONE; | 624 token->type = T1_TOKEN_TYPE_NONE; |
| 628 token->start = 0; | 625 token->start = NULL; |
| 629 token->limit = 0; | 626 token->limit = NULL; |
| 630 | 627 |
| 631 /* first of all, skip leading whitespace */ | 628 /* first of all, skip leading whitespace */ |
| 632 ps_parser_skip_spaces( parser ); | 629 ps_parser_skip_spaces( parser ); |
| 633 | 630 |
| 634 cur = parser->cursor; | 631 cur = parser->cursor; |
| 635 limit = parser->limit; | 632 limit = parser->limit; |
| 636 | 633 |
| 637 if ( cur >= limit ) | 634 if ( cur >= limit ) |
| 638 return; | 635 return; |
| 639 | 636 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 token->start = cur; | 697 token->start = cur; |
| 701 token->type = ( *cur == '/' ? T1_TOKEN_TYPE_KEY : T1_TOKEN_TYPE_ANY ); | 698 token->type = ( *cur == '/' ? T1_TOKEN_TYPE_KEY : T1_TOKEN_TYPE_ANY ); |
| 702 ps_parser_skip_PS_token( parser ); | 699 ps_parser_skip_PS_token( parser ); |
| 703 cur = parser->cursor; | 700 cur = parser->cursor; |
| 704 if ( !parser->error ) | 701 if ( !parser->error ) |
| 705 token->limit = cur; | 702 token->limit = cur; |
| 706 } | 703 } |
| 707 | 704 |
| 708 if ( !token->limit ) | 705 if ( !token->limit ) |
| 709 { | 706 { |
| 710 token->start = 0; | 707 token->start = NULL; |
| 711 token->type = T1_TOKEN_TYPE_NONE; | 708 token->type = T1_TOKEN_TYPE_NONE; |
| 712 } | 709 } |
| 713 | 710 |
| 714 parser->cursor = cur; | 711 parser->cursor = cur; |
| 715 } | 712 } |
| 716 | 713 |
| 717 | 714 |
| 718 /* NB: `tokens' can be NULL if we only want to count */ | 715 /* NB: `tokens' can be NULL if we only want to count */ |
| 719 /* the number of array elements */ | 716 /* the number of array elements */ |
| 720 | 717 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 | 922 |
| 926 | 923 |
| 927 #if 0 | 924 #if 0 |
| 928 | 925 |
| 929 static FT_String* | 926 static FT_String* |
| 930 ps_tostring( FT_Byte** cursor, | 927 ps_tostring( FT_Byte** cursor, |
| 931 FT_Byte* limit, | 928 FT_Byte* limit, |
| 932 FT_Memory memory ) | 929 FT_Memory memory ) |
| 933 { | 930 { |
| 934 FT_Byte* cur = *cursor; | 931 FT_Byte* cur = *cursor; |
| 935 FT_PtrDist len = 0; | 932 FT_UInt len = 0; |
| 936 FT_Int count; | 933 FT_Int count; |
| 937 FT_String* result; | 934 FT_String* result; |
| 938 FT_Error error; | 935 FT_Error error; |
| 939 | 936 |
| 940 | 937 |
| 941 /* XXX: some stupid fonts have a `Notice' or `Copyright' string */ | 938 /* XXX: some stupid fonts have a `Notice' or `Copyright' string */ |
| 942 /* that simply doesn't begin with an opening parenthesis, even */ | 939 /* that simply doesn't begin with an opening parenthesis, even */ |
| 943 /* though they have a closing one! E.g. "amuncial.pfb" */ | 940 /* though they have a closing one! E.g. "amuncial.pfb" */ |
| 944 /* */ | 941 /* */ |
| 945 /* We must deal with these ill-fated cases there. Note that */ | 942 /* We must deal with these ill-fated cases there. Note that */ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 965 count++; | 962 count++; |
| 966 | 963 |
| 967 else if ( *cur == ')' ) | 964 else if ( *cur == ')' ) |
| 968 { | 965 { |
| 969 count--; | 966 count--; |
| 970 if ( count < 0 ) | 967 if ( count < 0 ) |
| 971 break; | 968 break; |
| 972 } | 969 } |
| 973 } | 970 } |
| 974 | 971 |
| 975 len = cur - *cursor; | 972 len = (FT_UInt)( cur - *cursor ); |
| 976 if ( cur >= limit || FT_ALLOC( result, len + 1 ) ) | 973 if ( cur >= limit || FT_ALLOC( result, len + 1 ) ) |
| 977 return 0; | 974 return 0; |
| 978 | 975 |
| 979 /* now copy the string */ | 976 /* now copy the string */ |
| 980 FT_MEM_COPY( result, *cursor, len ); | 977 FT_MEM_COPY( result, *cursor, len ); |
| 981 result[len] = '\0'; | 978 result[len] = '\0'; |
| 982 *cursor = cur; | 979 *cursor = cur; |
| 983 return result; | 980 return result; |
| 984 } | 981 } |
| 985 | 982 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 FT_Fixed* temp; | 1220 FT_Fixed* temp; |
| 1224 FT_Int result; | 1221 FT_Int result; |
| 1225 FT_UInt i; | 1222 FT_UInt i; |
| 1226 | 1223 |
| 1227 | 1224 |
| 1228 if ( FT_NEW_ARRAY( temp, max_objects * 4 ) ) | 1225 if ( FT_NEW_ARRAY( temp, max_objects * 4 ) ) |
| 1229 goto Exit; | 1226 goto Exit; |
| 1230 | 1227 |
| 1231 for ( i = 0; i < 4; i++ ) | 1228 for ( i = 0; i < 4; i++ ) |
| 1232 { | 1229 { |
| 1233 result = ps_tofixedarray( &cur, limit, max_objects, | 1230 result = ps_tofixedarray( &cur, limit, (FT_Int)max_objects, |
| 1234 temp + i * max_objects, 0 ); | 1231 temp + i * max_objects, 0 ); |
| 1235 if ( result < 0 || (FT_UInt)result < max_objects ) | 1232 if ( result < 0 || (FT_UInt)result < max_objects ) |
| 1236 { | 1233 { |
| 1237 FT_ERROR(( "ps_parser_load_field:" | 1234 FT_ERROR(( "ps_parser_load_field:" |
| 1238 " expected %d integers in the %s subarray\n" | 1235 " expected %d integer%s in the %s subarray\n" |
| 1239 " " | 1236 " " |
| 1240 " of /FontBBox in the /Blend dictionary\n", | 1237 " of /FontBBox in the /Blend dictionary\n", |
| 1241 max_objects, | 1238 max_objects, max_objects > 1 ? "s" : "", |
| 1242 i == 0 ? "first" | 1239 i == 0 ? "first" |
| 1243 : ( i == 1 ? "second" | 1240 : ( i == 1 ? "second" |
| 1244 : ( i == 2 ? "third" | 1241 : ( i == 2 ? "third" |
| 1245 : "fourth" ) ) )); | 1242 : "fourth" ) ) )); |
| 1246 error = FT_THROW( Invalid_File_Format ); | 1243 error = FT_THROW( Invalid_File_Format ); |
| 1244 |
| 1245 FT_FREE( temp ); |
| 1247 goto Exit; | 1246 goto Exit; |
| 1248 } | 1247 } |
| 1249 | 1248 |
| 1250 skip_spaces( &cur, limit ); | 1249 skip_spaces( &cur, limit ); |
| 1251 } | 1250 } |
| 1252 | 1251 |
| 1253 for ( i = 0; i < max_objects; i++ ) | 1252 for ( i = 0; i < max_objects; i++ ) |
| 1254 { | 1253 { |
| 1255 FT_BBox* bbox = (FT_BBox*)objects[i]; | 1254 FT_BBox* bbox = (FT_BBox*)objects[i]; |
| 1256 | 1255 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 fieldrec.type = T1_FIELD_TYPE_FIXED; | 1313 fieldrec.type = T1_FIELD_TYPE_FIXED; |
| 1315 | 1314 |
| 1316 ps_parser_to_token_array( parser, elements, | 1315 ps_parser_to_token_array( parser, elements, |
| 1317 T1_MAX_TABLE_ELEMENTS, &num_elements ); | 1316 T1_MAX_TABLE_ELEMENTS, &num_elements ); |
| 1318 if ( num_elements < 0 ) | 1317 if ( num_elements < 0 ) |
| 1319 { | 1318 { |
| 1320 error = FT_ERR( Ignore ); | 1319 error = FT_ERR( Ignore ); |
| 1321 goto Exit; | 1320 goto Exit; |
| 1322 } | 1321 } |
| 1323 if ( (FT_UInt)num_elements > field->array_max ) | 1322 if ( (FT_UInt)num_elements > field->array_max ) |
| 1324 num_elements = field->array_max; | 1323 num_elements = (FT_Int)field->array_max; |
| 1325 | 1324 |
| 1326 old_cursor = parser->cursor; | 1325 old_cursor = parser->cursor; |
| 1327 old_limit = parser->limit; | 1326 old_limit = parser->limit; |
| 1328 | 1327 |
| 1329 /* we store the elements count if necessary; */ | 1328 /* we store the elements count if necessary; */ |
| 1330 /* we further assume that `count_offset' can't be zero */ | 1329 /* we further assume that `count_offset' can't be zero */ |
| 1331 if ( field->type != T1_FIELD_TYPE_BBOX && field->count_offset != 0 ) | 1330 if ( field->type != T1_FIELD_TYPE_BBOX && field->count_offset != 0 ) |
| 1332 *(FT_Byte*)( (FT_Byte*)objects[0] + field->count_offset ) = | 1331 *(FT_Byte*)( (FT_Byte*)objects[0] + field->count_offset ) = |
| 1333 (FT_Byte)num_elements; | 1332 (FT_Byte)num_elements; |
| 1334 | 1333 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 return PS_Conv_ToInt( &parser->cursor, parser->limit ); | 1371 return PS_Conv_ToInt( &parser->cursor, parser->limit ); |
| 1373 } | 1372 } |
| 1374 | 1373 |
| 1375 | 1374 |
| 1376 /* first character must be `<' if `delimiters' is non-zero */ | 1375 /* first character must be `<' if `delimiters' is non-zero */ |
| 1377 | 1376 |
| 1378 FT_LOCAL_DEF( FT_Error ) | 1377 FT_LOCAL_DEF( FT_Error ) |
| 1379 ps_parser_to_bytes( PS_Parser parser, | 1378 ps_parser_to_bytes( PS_Parser parser, |
| 1380 FT_Byte* bytes, | 1379 FT_Byte* bytes, |
| 1381 FT_Offset max_bytes, | 1380 FT_Offset max_bytes, |
| 1382 FT_Long* pnum_bytes, | 1381 FT_ULong* pnum_bytes, |
| 1383 FT_Bool delimiters ) | 1382 FT_Bool delimiters ) |
| 1384 { | 1383 { |
| 1385 FT_Error error = FT_Err_Ok; | 1384 FT_Error error = FT_Err_Ok; |
| 1386 FT_Byte* cur; | 1385 FT_Byte* cur; |
| 1387 | 1386 |
| 1388 | 1387 |
| 1389 ps_parser_skip_spaces( parser ); | 1388 ps_parser_skip_spaces( parser ); |
| 1390 cur = parser->cursor; | 1389 cur = parser->cursor; |
| 1391 | 1390 |
| 1392 if ( cur >= parser->limit ) | 1391 if ( cur >= parser->limit ) |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 { | 1545 { |
| 1547 FT_GlyphLoader loader = glyph->internal->loader; | 1546 FT_GlyphLoader loader = glyph->internal->loader; |
| 1548 | 1547 |
| 1549 | 1548 |
| 1550 builder->loader = loader; | 1549 builder->loader = loader; |
| 1551 builder->base = &loader->base.outline; | 1550 builder->base = &loader->base.outline; |
| 1552 builder->current = &loader->current.outline; | 1551 builder->current = &loader->current.outline; |
| 1553 FT_GlyphLoader_Rewind( loader ); | 1552 FT_GlyphLoader_Rewind( loader ); |
| 1554 | 1553 |
| 1555 builder->hints_globals = size->internal; | 1554 builder->hints_globals = size->internal; |
| 1556 builder->hints_funcs = 0; | 1555 builder->hints_funcs = NULL; |
| 1557 | 1556 |
| 1558 if ( hinting ) | 1557 if ( hinting ) |
| 1559 builder->hints_funcs = glyph->internal->glyph_hints; | 1558 builder->hints_funcs = glyph->internal->glyph_hints; |
| 1560 } | 1559 } |
| 1561 | 1560 |
| 1562 builder->pos_x = 0; | 1561 builder->pos_x = 0; |
| 1563 builder->pos_y = 0; | 1562 builder->pos_y = 0; |
| 1564 | 1563 |
| 1565 builder->left_bearing.x = 0; | 1564 builder->left_bearing.x = 0; |
| 1566 builder->left_bearing.y = 0; | 1565 builder->left_bearing.y = 0; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1766 { | 1765 { |
| 1767 PS_Conv_EexecDecode( &buffer, | 1766 PS_Conv_EexecDecode( &buffer, |
| 1768 buffer + length, | 1767 buffer + length, |
| 1769 buffer, | 1768 buffer, |
| 1770 length, | 1769 length, |
| 1771 &seed ); | 1770 &seed ); |
| 1772 } | 1771 } |
| 1773 | 1772 |
| 1774 | 1773 |
| 1775 /* END */ | 1774 /* END */ |
| OLD | NEW |