Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: src/psaux/psobjs.c

Issue 89753003: Update freetype to latest version of ASOP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src/third_party/freetype.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/psaux/psconv.c ('k') | src/psaux/t1decode.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2012 by */ 7 /* Copyright 1996-2013 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 for ( ; offset < limit; offset++ ) 107 for ( ; offset < limit; offset++ )
108 { 108 {
109 if ( offset[0] ) 109 if ( offset[0] )
110 offset[0] += delta; 110 offset[0] += delta;
111 } 111 }
112 } 112 }
113 113
114 114
115 static FT_Error 115 static FT_Error
116 reallocate_t1_table( PS_Table table, 116 reallocate_t1_table( PS_Table table,
117 FT_Long new_size ) 117 FT_Offset new_size )
118 { 118 {
119 FT_Memory memory = table->memory; 119 FT_Memory memory = table->memory;
120 FT_Byte* old_base = table->block; 120 FT_Byte* old_base = table->block;
121 FT_Error error; 121 FT_Error error;
122 122
123 123
124 /* allocate new base block */ 124 /* allocate new base block */
125 if ( FT_ALLOC( table->block, new_size ) ) 125 if ( FT_ALLOC( table->block, new_size ) )
126 { 126 {
127 table->block = old_base; 127 table->block = old_base;
128 return error; 128 return error;
129 } 129 }
130 130
131 /* copy elements and shift offsets */ 131 /* copy elements and shift offsets */
132 if ( old_base ) 132 if ( old_base )
133 { 133 {
134 FT_MEM_COPY( table->block, old_base, table->capacity ); 134 FT_MEM_COPY( table->block, old_base, table->capacity );
135 shift_elements( table, old_base ); 135 shift_elements( table, old_base );
136 FT_FREE( old_base ); 136 FT_FREE( old_base );
137 } 137 }
138 138
139 table->capacity = new_size; 139 table->capacity = new_size;
140 140
141 return PSaux_Err_Ok; 141 return FT_Err_Ok;
142 } 142 }
143 143
144 144
145 /*************************************************************************/ 145 /*************************************************************************/
146 /* */ 146 /* */
147 /* <Function> */ 147 /* <Function> */
148 /* ps_table_add */ 148 /* ps_table_add */
149 /* */ 149 /* */
150 /* <Description> */ 150 /* <Description> */
151 /* Adds an object to a PS_Table, possibly growing its memory block. */ 151 /* Adds an object to a PS_Table, possibly growing its memory block. */
(...skipping 14 matching lines...) Expand all
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_PtrDist 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 PSaux_Err_Invalid_Argument; 176 return FT_THROW( Invalid_Argument );
177 } 177 }
178 178
179 if ( length < 0 ) 179 if ( length < 0 )
180 { 180 {
181 FT_ERROR(( "ps_table_add: invalid length\n" )); 181 FT_ERROR(( "ps_table_add: invalid length\n" ));
182 return PSaux_Err_Invalid_Argument; 182 return FT_THROW( Invalid_Argument );
183 } 183 }
184 184
185 /* grow the base block if needed */ 185 /* grow the base block if needed */
186 if ( table->cursor + length > table->capacity ) 186 if ( table->cursor + length > table->capacity )
187 { 187 {
188 FT_Error error; 188 FT_Error error;
189 FT_Offset new_size = table->capacity; 189 FT_Offset new_size = table->capacity;
190 FT_PtrDist in_offset; 190 FT_PtrDist in_offset;
191 191
192 192
(...skipping 16 matching lines...) Expand all
209 if ( in_offset >= 0 ) 209 if ( in_offset >= 0 )
210 object = table->block + in_offset; 210 object = table->block + in_offset;
211 } 211 }
212 212
213 /* add the object to the base block and adjust offset */ 213 /* add the object to the base block and adjust offset */
214 table->elements[idx] = table->block + table->cursor; 214 table->elements[idx] = table->block + table->cursor;
215 table->lengths [idx] = length; 215 table->lengths [idx] = length;
216 FT_MEM_COPY( table->block + table->cursor, object, length ); 216 FT_MEM_COPY( table->block + table->cursor, object, length );
217 217
218 table->cursor += length; 218 table->cursor += length;
219 return PSaux_Err_Ok; 219 return FT_Err_Ok;
220 } 220 }
221 221
222 222
223 /*************************************************************************/ 223 /*************************************************************************/
224 /* */ 224 /* */
225 /* <Function> */ 225 /* <Function> */
226 /* ps_table_done */ 226 /* ps_table_done */
227 /* */ 227 /* */
228 /* <Description> */ 228 /* <Description> */
229 /* Finalizes a PS_TableRec (i.e., reallocate it to its current */ 229 /* Finalizes a PS_TableRec (i.e., reallocate it to its current */
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 /* first character must be `('; */ 335 /* first character must be `('; */
336 /* *acur is positioned at the character after the closing `)' */ 336 /* *acur is positioned at the character after the closing `)' */
337 337
338 static FT_Error 338 static FT_Error
339 skip_literal_string( FT_Byte* *acur, 339 skip_literal_string( FT_Byte* *acur,
340 FT_Byte* limit ) 340 FT_Byte* limit )
341 { 341 {
342 FT_Byte* cur = *acur; 342 FT_Byte* cur = *acur;
343 FT_Int embed = 0; 343 FT_Int embed = 0;
344 FT_Error error = PSaux_Err_Invalid_File_Format; 344 FT_Error error = FT_ERR( Invalid_File_Format );
345 unsigned int i; 345 unsigned int i;
346 346
347 347
348 while ( cur < limit ) 348 while ( cur < limit )
349 { 349 {
350 FT_Byte c = *cur; 350 FT_Byte c = *cur;
351 351
352 352
353 ++cur; 353 ++cur;
354 354
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 390 }
391 } 391 }
392 } 392 }
393 else if ( c == '(' ) 393 else if ( c == '(' )
394 embed++; 394 embed++;
395 else if ( c == ')' ) 395 else if ( c == ')' )
396 { 396 {
397 embed--; 397 embed--;
398 if ( embed == 0 ) 398 if ( embed == 0 )
399 { 399 {
400 error = PSaux_Err_Ok; 400 error = FT_Err_Ok;
401 break; 401 break;
402 } 402 }
403 } 403 }
404 } 404 }
405 405
406 *acur = cur; 406 *acur = cur;
407 407
408 return error; 408 return error;
409 } 409 }
410 410
411 411
412 /* first character must be `<' */ 412 /* first character must be `<' */
413 413
414 static FT_Error 414 static FT_Error
415 skip_string( FT_Byte* *acur, 415 skip_string( FT_Byte* *acur,
416 FT_Byte* limit ) 416 FT_Byte* limit )
417 { 417 {
418 FT_Byte* cur = *acur; 418 FT_Byte* cur = *acur;
419 FT_Error err = PSaux_Err_Ok; 419 FT_Error err = FT_Err_Ok;
420 420
421 421
422 while ( ++cur < limit ) 422 while ( ++cur < limit )
423 { 423 {
424 /* All whitespace characters are ignored. */ 424 /* All whitespace characters are ignored. */
425 skip_spaces( &cur, limit ); 425 skip_spaces( &cur, limit );
426 if ( cur >= limit ) 426 if ( cur >= limit )
427 break; 427 break;
428 428
429 if ( !IS_PS_XDIGIT( *cur ) ) 429 if ( !IS_PS_XDIGIT( *cur ) )
430 break; 430 break;
431 } 431 }
432 432
433 if ( cur < limit && *cur != '>' ) 433 if ( cur < limit && *cur != '>' )
434 { 434 {
435 FT_ERROR(( "skip_string: missing closing delimiter `>'\n" )); 435 FT_ERROR(( "skip_string: missing closing delimiter `>'\n" ));
436 err = PSaux_Err_Invalid_File_Format; 436 err = FT_THROW( Invalid_File_Format );
437 } 437 }
438 else 438 else
439 cur++; 439 cur++;
440 440
441 *acur = cur; 441 *acur = cur;
442 return err; 442 return err;
443 } 443 }
444 444
445 445
446 /* first character must be the opening brace that */ 446 /* first character must be the opening brace that */
447 /* starts the procedure */ 447 /* starts the procedure */
448 448
449 /* NB: [ and ] need not match: */ 449 /* NB: [ and ] need not match: */
450 /* `/foo {[} def' is a valid PostScript fragment, */ 450 /* `/foo {[} def' is a valid PostScript fragment, */
451 /* even within a Type1 font */ 451 /* even within a Type1 font */
452 452
453 static FT_Error 453 static FT_Error
454 skip_procedure( FT_Byte* *acur, 454 skip_procedure( FT_Byte* *acur,
455 FT_Byte* limit ) 455 FT_Byte* limit )
456 { 456 {
457 FT_Byte* cur; 457 FT_Byte* cur;
458 FT_Int embed = 0; 458 FT_Int embed = 0;
459 FT_Error error = PSaux_Err_Ok; 459 FT_Error error = FT_Err_Ok;
460 460
461 461
462 FT_ASSERT( **acur == '{' ); 462 FT_ASSERT( **acur == '{' );
463 463
464 for ( cur = *acur; cur < limit && error == PSaux_Err_Ok; ++cur ) 464 for ( cur = *acur; cur < limit && error == FT_Err_Ok; ++cur )
465 { 465 {
466 switch ( *cur ) 466 switch ( *cur )
467 { 467 {
468 case '{': 468 case '{':
469 ++embed; 469 ++embed;
470 break; 470 break;
471 471
472 case '}': 472 case '}':
473 --embed; 473 --embed;
474 if ( embed == 0 ) 474 if ( embed == 0 )
(...skipping 12 matching lines...) Expand all
487 break; 487 break;
488 488
489 case '%': 489 case '%':
490 skip_comment( &cur, limit ); 490 skip_comment( &cur, limit );
491 break; 491 break;
492 } 492 }
493 } 493 }
494 494
495 end: 495 end:
496 if ( embed != 0 ) 496 if ( embed != 0 )
497 error = PSaux_Err_Invalid_File_Format; 497 error = FT_THROW( Invalid_File_Format );
498 498
499 *acur = cur; 499 *acur = cur;
500 500
501 return error; 501 return error;
502 } 502 }
503 503
504 504
505 /***********************************************************************/ 505 /***********************************************************************/
506 /* */ 506 /* */
507 /* All exported parsing routines handle leading whitespace and stop at */ 507 /* All exported parsing routines handle leading whitespace and stop at */
508 /* the first character which isn't part of the just handled token. */ 508 /* the first character which isn't part of the just handled token. */
509 /* */ 509 /* */
510 /***********************************************************************/ 510 /***********************************************************************/
511 511
512 512
513 FT_LOCAL_DEF( void ) 513 FT_LOCAL_DEF( void )
514 ps_parser_skip_PS_token( PS_Parser parser ) 514 ps_parser_skip_PS_token( PS_Parser parser )
515 { 515 {
516 /* Note: PostScript allows any non-delimiting, non-whitespace */ 516 /* Note: PostScript allows any non-delimiting, non-whitespace */
517 /* character in a name (PS Ref Manual, 3rd ed, p31). */ 517 /* character in a name (PS Ref Manual, 3rd ed, p31). */
518 /* PostScript delimiters are (, ), <, >, [, ], {, }, /, and %. */ 518 /* PostScript delimiters are (, ), <, >, [, ], {, }, /, and %. */
519 519
520 FT_Byte* cur = parser->cursor; 520 FT_Byte* cur = parser->cursor;
521 FT_Byte* limit = parser->limit; 521 FT_Byte* limit = parser->limit;
522 FT_Error error = PSaux_Err_Ok; 522 FT_Error error = FT_Err_Ok;
523 523
524 524
525 skip_spaces( &cur, limit ); /* this also skips comments */ 525 skip_spaces( &cur, limit ); /* this also skips comments */
526 if ( cur >= limit ) 526 if ( cur >= limit )
527 goto Exit; 527 goto Exit;
528 528
529 /* self-delimiting, single-character tokens */ 529 /* self-delimiting, single-character tokens */
530 if ( *cur == '[' || *cur == ']' ) 530 if ( *cur == '[' || *cur == ']' )
531 { 531 {
532 cur++; 532 cur++;
(...skipping 27 matching lines...) Expand all
560 goto Exit; 560 goto Exit;
561 } 561 }
562 562
563 if ( *cur == '>' ) 563 if ( *cur == '>' )
564 { 564 {
565 cur++; 565 cur++;
566 if ( cur >= limit || *cur != '>' ) /* >> */ 566 if ( cur >= limit || *cur != '>' ) /* >> */
567 { 567 {
568 FT_ERROR(( "ps_parser_skip_PS_token:" 568 FT_ERROR(( "ps_parser_skip_PS_token:"
569 " unexpected closing delimiter `>'\n" )); 569 " unexpected closing delimiter `>'\n" ));
570 error = PSaux_Err_Invalid_File_Format; 570 error = FT_THROW( Invalid_File_Format );
571 goto Exit; 571 goto Exit;
572 } 572 }
573 cur++; 573 cur++;
574 goto Exit; 574 goto Exit;
575 } 575 }
576 576
577 if ( *cur == '/' ) 577 if ( *cur == '/' )
578 cur++; 578 cur++;
579 579
580 /* anything else */ 580 /* anything else */
581 while ( cur < limit ) 581 while ( cur < limit )
582 { 582 {
583 /* *cur might be invalid (e.g., ')' or '}'), but this */ 583 /* *cur might be invalid (e.g., ')' or '}'), but this */
584 /* is handled by the test `cur == parser->cursor' below */ 584 /* is handled by the test `cur == parser->cursor' below */
585 if ( IS_PS_DELIM( *cur ) ) 585 if ( IS_PS_DELIM( *cur ) )
586 break; 586 break;
587 587
588 cur++; 588 cur++;
589 } 589 }
590 590
591 Exit: 591 Exit:
592 if ( cur < limit && cur == parser->cursor ) 592 if ( cur < limit && cur == parser->cursor )
593 { 593 {
594 FT_ERROR(( "ps_parser_skip_PS_token:" 594 FT_ERROR(( "ps_parser_skip_PS_token:"
595 " current token is `%c' which is self-delimiting\n" 595 " current token is `%c' which is self-delimiting\n"
596 " " 596 " "
597 " but invalid at this point\n", 597 " but invalid at this point\n",
598 *cur )); 598 *cur ));
599 599
600 error = PSaux_Err_Invalid_File_Format; 600 error = FT_THROW( Invalid_File_Format );
601 } 601 }
602 602
603 parser->error = error; 603 parser->error = error;
604 parser->cursor = cur; 604 parser->cursor = cur;
605 } 605 }
606 606
607 607
608 FT_LOCAL_DEF( void ) 608 FT_LOCAL_DEF( void )
609 ps_parser_skip_spaces( PS_Parser parser ) 609 ps_parser_skip_spaces( PS_Parser parser )
610 { 610 {
(...skipping 26 matching lines...) Expand all
637 if ( cur >= limit ) 637 if ( cur >= limit )
638 return; 638 return;
639 639
640 switch ( *cur ) 640 switch ( *cur )
641 { 641 {
642 /************* check for literal string *****************/ 642 /************* check for literal string *****************/
643 case '(': 643 case '(':
644 token->type = T1_TOKEN_TYPE_STRING; 644 token->type = T1_TOKEN_TYPE_STRING;
645 token->start = cur; 645 token->start = cur;
646 646
647 if ( skip_literal_string( &cur, limit ) == PSaux_Err_Ok ) 647 if ( skip_literal_string( &cur, limit ) == FT_Err_Ok )
648 token->limit = cur; 648 token->limit = cur;
649 break; 649 break;
650 650
651 /************* check for programs/array *****************/ 651 /************* check for programs/array *****************/
652 case '{': 652 case '{':
653 token->type = T1_TOKEN_TYPE_ARRAY; 653 token->type = T1_TOKEN_TYPE_ARRAY;
654 token->start = cur; 654 token->start = cur;
655 655
656 if ( skip_procedure( &cur, limit ) == PSaux_Err_Ok ) 656 if ( skip_procedure( &cur, limit ) == FT_Err_Ok )
657 token->limit = cur; 657 token->limit = cur;
658 break; 658 break;
659 659
660 /************* check for table/array ********************/ 660 /************* check for table/array ********************/
661 /* XXX: in theory we should also look for "<<" */ 661 /* XXX: in theory we should also look for "<<" */
662 /* since this is semantically equivalent to "["; */ 662 /* since this is semantically equivalent to "["; */
663 /* in practice it doesn't matter (?) */ 663 /* in practice it doesn't matter (?) */
664 case '[': 664 case '[':
665 token->type = T1_TOKEN_TYPE_ARRAY; 665 token->type = T1_TOKEN_TYPE_ARRAY;
666 embed = 1; 666 embed = 1;
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 1020
1021 /* load a simple field (i.e. non-table) into the current list of objects */ 1021 /* load a simple field (i.e. non-table) into the current list of objects */
1022 1022
1023 FT_LOCAL_DEF( FT_Error ) 1023 FT_LOCAL_DEF( FT_Error )
1024 ps_parser_load_field( PS_Parser parser, 1024 ps_parser_load_field( PS_Parser parser,
1025 const T1_Field field, 1025 const T1_Field field,
1026 void** objects, 1026 void** objects,
1027 FT_UInt max_objects, 1027 FT_UInt max_objects,
1028 FT_ULong* pflags ) 1028 FT_ULong* pflags )
1029 { 1029 {
1030 T1_TokenRec token; 1030 T1_TokenRec token;
1031 FT_Byte* cur; 1031 FT_Byte* cur;
1032 FT_Byte* limit; 1032 FT_Byte* limit;
1033 FT_UInt count; 1033 FT_UInt count;
1034 FT_UInt idx; 1034 FT_UInt idx;
1035 FT_Error error; 1035 FT_Error error;
1036 T1_FieldType type;
1036 1037
1037 1038
1038 /* this also skips leading whitespace */ 1039 /* this also skips leading whitespace */
1039 ps_parser_to_token( parser, &token ); 1040 ps_parser_to_token( parser, &token );
1040 if ( !token.type ) 1041 if ( !token.type )
1041 goto Fail; 1042 goto Fail;
1042 1043
1043 count = 1; 1044 count = 1;
1044 idx = 0; 1045 idx = 0;
1045 cur = token.start; 1046 cur = token.start;
1046 limit = token.limit; 1047 limit = token.limit;
1047 1048
1049 type = field->type;
1050
1048 /* we must detect arrays in /FontBBox */ 1051 /* we must detect arrays in /FontBBox */
1049 if ( field->type == T1_FIELD_TYPE_BBOX ) 1052 if ( type == T1_FIELD_TYPE_BBOX )
1050 { 1053 {
1051 T1_TokenRec token2; 1054 T1_TokenRec token2;
1052 FT_Byte* old_cur = parser->cursor; 1055 FT_Byte* old_cur = parser->cursor;
1053 FT_Byte* old_limit = parser->limit; 1056 FT_Byte* old_limit = parser->limit;
1054 1057
1055 1058
1056 /* don't include delimiters */ 1059 /* don't include delimiters */
1057 parser->cursor = token.start + 1; 1060 parser->cursor = token.start + 1;
1058 parser->limit = token.limit - 1; 1061 parser->limit = token.limit - 1;
1059 1062
1060 ps_parser_to_token( parser, &token2 ); 1063 ps_parser_to_token( parser, &token2 );
1061 parser->cursor = old_cur; 1064 parser->cursor = old_cur;
1062 parser->limit = old_limit; 1065 parser->limit = old_limit;
1063 1066
1064 if ( token2.type == T1_TOKEN_TYPE_ARRAY ) 1067 if ( token2.type == T1_TOKEN_TYPE_ARRAY )
1068 {
1069 type = T1_FIELD_TYPE_MM_BBOX;
1065 goto FieldArray; 1070 goto FieldArray;
1071 }
1066 } 1072 }
1067 else if ( token.type == T1_TOKEN_TYPE_ARRAY ) 1073 else if ( token.type == T1_TOKEN_TYPE_ARRAY )
1068 { 1074 {
1075 count = max_objects;
1076
1069 FieldArray: 1077 FieldArray:
1070 /* if this is an array and we have no blend, an error occurs */ 1078 /* if this is an array and we have no blend, an error occurs */
1071 if ( max_objects == 0 ) 1079 if ( max_objects == 0 )
1072 goto Fail; 1080 goto Fail;
1073 1081
1074 count = max_objects; 1082 idx = 1;
1075 idx = 1;
1076 1083
1077 /* don't include delimiters */ 1084 /* don't include delimiters */
1078 cur++; 1085 cur++;
1079 limit--; 1086 limit--;
1080 } 1087 }
1081 1088
1082 for ( ; count > 0; count--, idx++ ) 1089 for ( ; count > 0; count--, idx++ )
1083 { 1090 {
1084 FT_Byte* q = (FT_Byte*)objects[idx] + field->offset; 1091 FT_Byte* q = (FT_Byte*)objects[idx] + field->offset;
1085 FT_Long val; 1092 FT_Long val;
1086 FT_String* string; 1093 FT_String* string;
1087 1094
1088 1095
1089 skip_spaces( &cur, limit ); 1096 skip_spaces( &cur, limit );
1090 1097
1091 switch ( field->type ) 1098 switch ( type )
1092 { 1099 {
1093 case T1_FIELD_TYPE_BOOL: 1100 case T1_FIELD_TYPE_BOOL:
1094 val = ps_tobool( &cur, limit ); 1101 val = ps_tobool( &cur, limit );
1095 goto Store_Integer; 1102 goto Store_Integer;
1096 1103
1097 case T1_FIELD_TYPE_FIXED: 1104 case T1_FIELD_TYPE_FIXED:
1098 val = PS_Conv_ToFixed( &cur, limit, 0 ); 1105 val = PS_Conv_ToFixed( &cur, limit, 0 );
1099 goto Store_Integer; 1106 goto Store_Integer;
1100 1107
1101 case T1_FIELD_TYPE_FIXED_1000: 1108 case T1_FIELD_TYPE_FIXED_1000:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 cur++; 1160 cur++;
1154 len -= 2; 1161 len -= 2;
1155 } 1162 }
1156 else 1163 else
1157 { 1164 {
1158 FT_ERROR(( "ps_parser_load_field:" 1165 FT_ERROR(( "ps_parser_load_field:"
1159 " expected a name or string\n" 1166 " expected a name or string\n"
1160 " " 1167 " "
1161 " but found token of type %d instead\n", 1168 " but found token of type %d instead\n",
1162 token.type )); 1169 token.type ));
1163 error = PSaux_Err_Invalid_File_Format; 1170 error = FT_THROW( Invalid_File_Format );
1164 goto Exit; 1171 goto Exit;
1165 } 1172 }
1166 1173
1167 /* for this to work (FT_String**)q must have been */ 1174 /* for this to work (FT_String**)q must have been */
1168 /* initialized to NULL */ 1175 /* initialized to NULL */
1169 if ( *(FT_String**)q != NULL ) 1176 if ( *(FT_String**)q != NULL )
1170 { 1177 {
1171 FT_TRACE0(( "ps_parser_load_field: overwriting field %s\n", 1178 FT_TRACE0(( "ps_parser_load_field: overwriting field %s\n",
1172 field->ident )); 1179 field->ident ));
1173 FT_FREE( *(FT_String**)q ); 1180 FT_FREE( *(FT_String**)q );
(...skipping 16 matching lines...) Expand all
1190 FT_BBox* bbox = (FT_BBox*)q; 1197 FT_BBox* bbox = (FT_BBox*)q;
1191 FT_Int result; 1198 FT_Int result;
1192 1199
1193 1200
1194 result = ps_tofixedarray( &cur, limit, 4, temp, 0 ); 1201 result = ps_tofixedarray( &cur, limit, 4, temp, 0 );
1195 1202
1196 if ( result < 0 ) 1203 if ( result < 0 )
1197 { 1204 {
1198 FT_ERROR(( "ps_parser_load_field:" 1205 FT_ERROR(( "ps_parser_load_field:"
1199 " expected four integers in bounding box\n" )); 1206 " expected four integers in bounding box\n" ));
1200 error = PSaux_Err_Invalid_File_Format; 1207 error = FT_THROW( Invalid_File_Format );
1201 goto Exit; 1208 goto Exit;
1202 } 1209 }
1203 1210
1204 bbox->xMin = FT_RoundFix( temp[0] ); 1211 bbox->xMin = FT_RoundFix( temp[0] );
1205 bbox->yMin = FT_RoundFix( temp[1] ); 1212 bbox->yMin = FT_RoundFix( temp[1] );
1206 bbox->xMax = FT_RoundFix( temp[2] ); 1213 bbox->xMax = FT_RoundFix( temp[2] );
1207 bbox->yMax = FT_RoundFix( temp[3] ); 1214 bbox->yMax = FT_RoundFix( temp[3] );
1208 } 1215 }
1209 break; 1216 break;
1210 1217
1218 case T1_FIELD_TYPE_MM_BBOX:
1219 {
1220 FT_Memory memory = parser->memory;
1221 FT_Fixed* temp;
1222 FT_Int result;
1223 FT_UInt i;
1224
1225
1226 if ( FT_NEW_ARRAY( temp, max_objects * 4 ) )
1227 goto Exit;
1228
1229 for ( i = 0; i < 4; i++ )
1230 {
1231 result = ps_tofixedarray( &cur, limit, max_objects,
1232 temp + i * max_objects, 0 );
1233 if ( result < 0 )
1234 {
1235 FT_ERROR(( "ps_parser_load_field:"
1236 " expected %d integers in the %s subarray\n"
1237 " "
1238 " of /FontBBox in the /Blend dictionary\n",
1239 max_objects,
1240 i == 0 ? "first"
1241 : ( i == 1 ? "second"
1242 : ( i == 2 ? "third"
1243 : "fourth" ) ) ));
1244 error = FT_THROW( Invalid_File_Format );
1245 goto Exit;
1246 }
1247
1248 skip_spaces( &cur, limit );
1249 }
1250
1251 for ( i = 0; i < max_objects; i++ )
1252 {
1253 FT_BBox* bbox = (FT_BBox*)objects[i];
1254
1255
1256 bbox->xMin = FT_RoundFix( temp[i ] );
1257 bbox->yMin = FT_RoundFix( temp[i + max_objects] );
1258 bbox->xMax = FT_RoundFix( temp[i + 2 * max_objects] );
1259 bbox->yMax = FT_RoundFix( temp[i + 3 * max_objects] );
1260 }
1261
1262 FT_FREE( temp );
1263 }
1264 break;
1265
1211 default: 1266 default:
1212 /* an error occurred */ 1267 /* an error occurred */
1213 goto Fail; 1268 goto Fail;
1214 } 1269 }
1215 } 1270 }
1216 1271
1217 #if 0 /* obsolete -- keep for reference */ 1272 #if 0 /* obsolete -- keep for reference */
1218 if ( pflags ) 1273 if ( pflags )
1219 *pflags |= 1L << field->flag_bit; 1274 *pflags |= 1L << field->flag_bit;
1220 #else 1275 #else
1221 FT_UNUSED( pflags ); 1276 FT_UNUSED( pflags );
1222 #endif 1277 #endif
1223 1278
1224 error = PSaux_Err_Ok; 1279 error = FT_Err_Ok;
1225 1280
1226 Exit: 1281 Exit:
1227 return error; 1282 return error;
1228 1283
1229 Fail: 1284 Fail:
1230 error = PSaux_Err_Invalid_File_Format; 1285 error = FT_THROW( Invalid_File_Format );
1231 goto Exit; 1286 goto Exit;
1232 } 1287 }
1233 1288
1234 1289
1235 #define T1_MAX_TABLE_ELEMENTS 32 1290 #define T1_MAX_TABLE_ELEMENTS 32
1236 1291
1237 1292
1238 FT_LOCAL_DEF( FT_Error ) 1293 FT_LOCAL_DEF( FT_Error )
1239 ps_parser_load_field_table( PS_Parser parser, 1294 ps_parser_load_field_table( PS_Parser parser,
1240 const T1_Field field, 1295 const T1_Field field,
1241 void** objects, 1296 void** objects,
1242 FT_UInt max_objects, 1297 FT_UInt max_objects,
1243 FT_ULong* pflags ) 1298 FT_ULong* pflags )
1244 { 1299 {
1245 T1_TokenRec elements[T1_MAX_TABLE_ELEMENTS]; 1300 T1_TokenRec elements[T1_MAX_TABLE_ELEMENTS];
1246 T1_Token token; 1301 T1_Token token;
1247 FT_Int num_elements; 1302 FT_Int num_elements;
1248 FT_Error error = PSaux_Err_Ok; 1303 FT_Error error = FT_Err_Ok;
1249 FT_Byte* old_cursor; 1304 FT_Byte* old_cursor;
1250 FT_Byte* old_limit; 1305 FT_Byte* old_limit;
1251 T1_FieldRec fieldrec = *(T1_Field)field; 1306 T1_FieldRec fieldrec = *(T1_Field)field;
1252 1307
1253 1308
1254 fieldrec.type = T1_FIELD_TYPE_INTEGER; 1309 fieldrec.type = T1_FIELD_TYPE_INTEGER;
1255 if ( field->type == T1_FIELD_TYPE_FIXED_ARRAY || 1310 if ( field->type == T1_FIELD_TYPE_FIXED_ARRAY ||
1256 field->type == T1_FIELD_TYPE_BBOX ) 1311 field->type == T1_FIELD_TYPE_BBOX )
1257 fieldrec.type = T1_FIELD_TYPE_FIXED; 1312 fieldrec.type = T1_FIELD_TYPE_FIXED;
1258 1313
1259 ps_parser_to_token_array( parser, elements, 1314 ps_parser_to_token_array( parser, elements,
1260 T1_MAX_TABLE_ELEMENTS, &num_elements ); 1315 T1_MAX_TABLE_ELEMENTS, &num_elements );
1261 if ( num_elements < 0 ) 1316 if ( num_elements < 0 )
1262 { 1317 {
1263 error = PSaux_Err_Ignore; 1318 error = FT_ERR( Ignore );
1264 goto Exit; 1319 goto Exit;
1265 } 1320 }
1266 if ( (FT_UInt)num_elements > field->array_max ) 1321 if ( (FT_UInt)num_elements > field->array_max )
1267 num_elements = field->array_max; 1322 num_elements = field->array_max;
1268 1323
1269 old_cursor = parser->cursor; 1324 old_cursor = parser->cursor;
1270 old_limit = parser->limit; 1325 old_limit = parser->limit;
1271 1326
1272 /* we store the elements count if necessary; */ 1327 /* we store the elements count if necessary; */
1273 /* we further assume that `count_offset' can't be zero */ 1328 /* we further assume that `count_offset' can't be zero */
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 1365
1311 /* first character must be `<' if `delimiters' is non-zero */ 1366 /* first character must be `<' if `delimiters' is non-zero */
1312 1367
1313 FT_LOCAL_DEF( FT_Error ) 1368 FT_LOCAL_DEF( FT_Error )
1314 ps_parser_to_bytes( PS_Parser parser, 1369 ps_parser_to_bytes( PS_Parser parser,
1315 FT_Byte* bytes, 1370 FT_Byte* bytes,
1316 FT_Offset max_bytes, 1371 FT_Offset max_bytes,
1317 FT_Long* pnum_bytes, 1372 FT_Long* pnum_bytes,
1318 FT_Bool delimiters ) 1373 FT_Bool delimiters )
1319 { 1374 {
1320 FT_Error error = PSaux_Err_Ok; 1375 FT_Error error = FT_Err_Ok;
1321 FT_Byte* cur; 1376 FT_Byte* cur;
1322 1377
1323 1378
1324 ps_parser_skip_spaces( parser ); 1379 ps_parser_skip_spaces( parser );
1325 cur = parser->cursor; 1380 cur = parser->cursor;
1326 1381
1327 if ( cur >= parser->limit ) 1382 if ( cur >= parser->limit )
1328 goto Exit; 1383 goto Exit;
1329 1384
1330 if ( delimiters ) 1385 if ( delimiters )
1331 { 1386 {
1332 if ( *cur != '<' ) 1387 if ( *cur != '<' )
1333 { 1388 {
1334 FT_ERROR(( "ps_parser_to_bytes: Missing starting delimiter `<'\n" )); 1389 FT_ERROR(( "ps_parser_to_bytes: Missing starting delimiter `<'\n" ));
1335 error = PSaux_Err_Invalid_File_Format; 1390 error = FT_THROW( Invalid_File_Format );
1336 goto Exit; 1391 goto Exit;
1337 } 1392 }
1338 1393
1339 cur++; 1394 cur++;
1340 } 1395 }
1341 1396
1342 *pnum_bytes = PS_Conv_ASCIIHexDecode( &cur, 1397 *pnum_bytes = PS_Conv_ASCIIHexDecode( &cur,
1343 parser->limit, 1398 parser->limit,
1344 bytes, 1399 bytes,
1345 max_bytes ); 1400 max_bytes );
1346 1401
1347 if ( delimiters ) 1402 if ( delimiters )
1348 { 1403 {
1349 if ( cur < parser->limit && *cur != '>' ) 1404 if ( cur < parser->limit && *cur != '>' )
1350 { 1405 {
1351 FT_ERROR(( "ps_parser_to_bytes: Missing closing delimiter `>'\n" )); 1406 FT_ERROR(( "ps_parser_to_bytes: Missing closing delimiter `>'\n" ));
1352 error = PSaux_Err_Invalid_File_Format; 1407 error = FT_THROW( Invalid_File_Format );
1353 goto Exit; 1408 goto Exit;
1354 } 1409 }
1355 1410
1356 cur++; 1411 cur++;
1357 } 1412 }
1358 1413
1359 parser->cursor = cur; 1414 parser->cursor = cur;
1360 1415
1361 Exit: 1416 Exit:
1362 return error; 1417 return error;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 1467
1413 #endif /* 0 */ 1468 #endif /* 0 */
1414 1469
1415 1470
1416 FT_LOCAL_DEF( void ) 1471 FT_LOCAL_DEF( void )
1417 ps_parser_init( PS_Parser parser, 1472 ps_parser_init( PS_Parser parser,
1418 FT_Byte* base, 1473 FT_Byte* base,
1419 FT_Byte* limit, 1474 FT_Byte* limit,
1420 FT_Memory memory ) 1475 FT_Memory memory )
1421 { 1476 {
1422 parser->error = PSaux_Err_Ok; 1477 parser->error = FT_Err_Ok;
1423 parser->base = base; 1478 parser->base = base;
1424 parser->limit = limit; 1479 parser->limit = limit;
1425 parser->cursor = base; 1480 parser->cursor = base;
1426 parser->memory = memory; 1481 parser->memory = memory;
1427 parser->funcs = ps_parser_funcs; 1482 parser->funcs = ps_parser_funcs;
1428 } 1483 }
1429 1484
1430 1485
1431 FT_LOCAL_DEF( void ) 1486 FT_LOCAL_DEF( void )
1432 ps_parser_done( PS_Parser parser ) 1487 ps_parser_done( PS_Parser parser )
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 t1_builder_add_contour( T1_Builder builder ) 1640 t1_builder_add_contour( T1_Builder builder )
1586 { 1641 {
1587 FT_Outline* outline = builder->current; 1642 FT_Outline* outline = builder->current;
1588 FT_Error error; 1643 FT_Error error;
1589 1644
1590 1645
1591 /* this might happen in invalid fonts */ 1646 /* this might happen in invalid fonts */
1592 if ( !outline ) 1647 if ( !outline )
1593 { 1648 {
1594 FT_ERROR(( "t1_builder_add_contour: no outline to add points to\n" )); 1649 FT_ERROR(( "t1_builder_add_contour: no outline to add points to\n" ));
1595 return PSaux_Err_Invalid_File_Format; 1650 return FT_THROW( Invalid_File_Format );
1596 } 1651 }
1597 1652
1598 if ( !builder->load_points ) 1653 if ( !builder->load_points )
1599 { 1654 {
1600 outline->n_contours++; 1655 outline->n_contours++;
1601 return PSaux_Err_Ok; 1656 return FT_Err_Ok;
1602 } 1657 }
1603 1658
1604 error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 ); 1659 error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
1605 if ( !error ) 1660 if ( !error )
1606 { 1661 {
1607 if ( outline->n_contours > 0 ) 1662 if ( outline->n_contours > 0 )
1608 outline->contours[outline->n_contours - 1] = 1663 outline->contours[outline->n_contours - 1] =
1609 (short)( outline->n_points - 1 ); 1664 (short)( outline->n_points - 1 );
1610 1665
1611 outline->n_contours++; 1666 outline->n_contours++;
1612 } 1667 }
1613 1668
1614 return error; 1669 return error;
1615 } 1670 }
1616 1671
1617 1672
1618 /* if a path was begun, add its first on-curve point */ 1673 /* if a path was begun, add its first on-curve point */
1619 FT_LOCAL_DEF( FT_Error ) 1674 FT_LOCAL_DEF( FT_Error )
1620 t1_builder_start_point( T1_Builder builder, 1675 t1_builder_start_point( T1_Builder builder,
1621 FT_Pos x, 1676 FT_Pos x,
1622 FT_Pos y ) 1677 FT_Pos y )
1623 { 1678 {
1624 FT_Error error = PSaux_Err_Invalid_File_Format; 1679 FT_Error error = FT_ERR( Invalid_File_Format );
1625 1680
1626 1681
1627 /* test whether we are building a new contour */ 1682 /* test whether we are building a new contour */
1628 1683
1629 if ( builder->parse_state == T1_Parse_Have_Path ) 1684 if ( builder->parse_state == T1_Parse_Have_Path )
1630 error = PSaux_Err_Ok; 1685 error = FT_Err_Ok;
1631 else 1686 else
1632 { 1687 {
1633 builder->parse_state = T1_Parse_Have_Path; 1688 builder->parse_state = T1_Parse_Have_Path;
1634 error = t1_builder_add_contour( builder ); 1689 error = t1_builder_add_contour( builder );
1635 if ( !error ) 1690 if ( !error )
1636 error = t1_builder_add_point1( builder, x, y ); 1691 error = t1_builder_add_point1( builder, x, y );
1637 } 1692 }
1638 1693
1639 return error; 1694 return error;
1640 } 1695 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 { 1756 {
1702 PS_Conv_EexecDecode( &buffer, 1757 PS_Conv_EexecDecode( &buffer,
1703 buffer + length, 1758 buffer + length,
1704 buffer, 1759 buffer,
1705 length, 1760 length,
1706 &seed ); 1761 &seed );
1707 } 1762 }
1708 1763
1709 1764
1710 /* END */ 1765 /* END */
OLDNEW
« no previous file with comments | « src/psaux/psconv.c ('k') | src/psaux/t1decode.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698