OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* t1load.c */ | 3 /* t1load.c */ |
4 /* */ | 4 /* */ |
5 /* Type 1 font loader (body). */ | 5 /* Type 1 font loader (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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 return error; | 220 return error; |
221 } | 221 } |
222 | 222 |
223 | 223 |
224 /*************************************************************************/ | 224 /*************************************************************************/ |
225 /* */ | 225 /* */ |
226 /* Given a normalized (blend) coordinate, figure out the design */ | 226 /* Given a normalized (blend) coordinate, figure out the design */ |
227 /* coordinate appropriate for that value. */ | 227 /* coordinate appropriate for that value. */ |
228 /* */ | 228 /* */ |
229 FT_LOCAL_DEF( FT_Fixed ) | 229 static FT_Fixed |
230 mm_axis_unmap( PS_DesignMap axismap, | 230 mm_axis_unmap( PS_DesignMap axismap, |
231 FT_Fixed ncv ) | 231 FT_Fixed ncv ) |
232 { | 232 { |
233 int j; | 233 int j; |
234 | 234 |
235 | 235 |
236 if ( ncv <= axismap->blend_points[0] ) | 236 if ( ncv <= axismap->blend_points[0] ) |
237 return INT_TO_FIXED( axismap->design_points[0] ); | 237 return INT_TO_FIXED( axismap->design_points[0] ); |
238 | 238 |
239 for ( j = 1; j < axismap->num_points; ++j ) | 239 for ( j = 1; j < axismap->num_points; ++j ) |
240 { | 240 { |
241 if ( ncv <= axismap->blend_points[j] ) | 241 if ( ncv <= axismap->blend_points[j] ) |
242 return INT_TO_FIXED( axismap->design_points[j - 1] ) + | 242 return INT_TO_FIXED( axismap->design_points[j - 1] ) + |
243 ( axismap->design_points[j] - axismap->design_points[j - 1] ) * | 243 ( axismap->design_points[j] - axismap->design_points[j - 1] ) * |
244 FT_DivFix( ncv - axismap->blend_points[j - 1], | 244 FT_DivFix( ncv - axismap->blend_points[j - 1], |
245 axismap->blend_points[j] - | 245 axismap->blend_points[j] - |
246 axismap->blend_points[j - 1] ); | 246 axismap->blend_points[j - 1] ); |
247 } | 247 } |
248 | 248 |
249 return INT_TO_FIXED( axismap->design_points[axismap->num_points - 1] ); | 249 return INT_TO_FIXED( axismap->design_points[axismap->num_points - 1] ); |
250 } | 250 } |
251 | 251 |
252 | 252 |
253 /*************************************************************************/ | 253 /*************************************************************************/ |
254 /* */ | 254 /* */ |
255 /* Given a vector of weights, one for each design, figure out the */ | 255 /* Given a vector of weights, one for each design, figure out the */ |
256 /* normalized axis coordinates which gave rise to those weights. */ | 256 /* normalized axis coordinates which gave rise to those weights. */ |
257 /* */ | 257 /* */ |
258 FT_LOCAL_DEF( void ) | 258 static void |
259 mm_weights_unmap( FT_Fixed* weights, | 259 mm_weights_unmap( FT_Fixed* weights, |
260 FT_Fixed* axiscoords, | 260 FT_Fixed* axiscoords, |
261 FT_UInt axis_count ) | 261 FT_UInt axis_count ) |
262 { | 262 { |
263 FT_ASSERT( axis_count <= T1_MAX_MM_AXIS ); | 263 FT_ASSERT( axis_count <= T1_MAX_MM_AXIS ); |
264 | 264 |
265 if ( axis_count == 1 ) | 265 if ( axis_count == 1 ) |
266 axiscoords[0] = weights[1]; | 266 axiscoords[0] = weights[1]; |
267 | 267 |
268 else if ( axis_count == 2 ) | 268 else if ( axis_count == 2 ) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 return error; | 361 return error; |
362 } | 362 } |
363 | 363 |
364 | 364 |
365 FT_LOCAL_DEF( FT_Error ) | 365 FT_LOCAL_DEF( FT_Error ) |
366 T1_Set_MM_Blend( T1_Face face, | 366 T1_Set_MM_Blend( T1_Face face, |
367 FT_UInt num_coords, | 367 FT_UInt num_coords, |
368 FT_Fixed* coords ) | 368 FT_Fixed* coords ) |
369 { | 369 { |
370 PS_Blend blend = face->blend; | 370 PS_Blend blend = face->blend; |
371 FT_Error error; | |
372 FT_UInt n, m; | 371 FT_UInt n, m; |
373 | 372 |
374 | 373 |
375 error = FT_ERR( Invalid_Argument ); | 374 if ( !blend ) |
| 375 return FT_THROW( Invalid_Argument ); |
376 | 376 |
377 if ( blend && blend->num_axis == num_coords ) | 377 if ( num_coords > blend->num_axis ) |
| 378 num_coords = blend->num_axis; |
| 379 |
| 380 /* recompute the weight vector from the blend coordinates */ |
| 381 for ( n = 0; n < blend->num_designs; n++ ) |
378 { | 382 { |
379 /* recompute the weight vector from the blend coordinates */ | 383 FT_Fixed result = 0x10000L; /* 1.0 fixed */ |
380 for ( n = 0; n < blend->num_designs; n++ ) | |
381 { | |
382 FT_Fixed result = 0x10000L; /* 1.0 fixed */ | |
383 | 384 |
384 | 385 |
385 for ( m = 0; m < blend->num_axis; m++ ) | 386 for ( m = 0; m < blend->num_axis; m++ ) |
386 { | 387 { |
387 FT_Fixed factor; | 388 FT_Fixed factor; |
388 | 389 |
389 | 390 |
390 /* get current blend axis position */ | 391 /* get current blend axis position; */ |
391 factor = coords[m]; | 392 /* use a default value if we don't have a coordinate */ |
392 if ( factor < 0 ) | 393 factor = m < num_coords ? coords[m] : 0x8000; |
393 factor = 0; | 394 if ( factor < 0 ) |
394 if ( factor > 0x10000L ) | 395 factor = 0; |
395 factor = 0x10000L; | 396 if ( factor > 0x10000L ) |
| 397 factor = 0x10000L; |
396 | 398 |
397 if ( ( n & ( 1 << m ) ) == 0 ) | 399 if ( ( n & ( 1 << m ) ) == 0 ) |
398 factor = 0x10000L - factor; | 400 factor = 0x10000L - factor; |
399 | 401 |
400 result = FT_MulFix( result, factor ); | 402 result = FT_MulFix( result, factor ); |
401 } | |
402 blend->weight_vector[n] = result; | |
403 } | 403 } |
404 | 404 blend->weight_vector[n] = result; |
405 error = FT_Err_Ok; | |
406 } | 405 } |
407 | 406 |
408 return error; | 407 return FT_Err_Ok; |
409 } | 408 } |
410 | 409 |
411 | 410 |
412 FT_LOCAL_DEF( FT_Error ) | 411 FT_LOCAL_DEF( FT_Error ) |
413 T1_Set_MM_Design( T1_Face face, | 412 T1_Set_MM_Design( T1_Face face, |
414 FT_UInt num_coords, | 413 FT_UInt num_coords, |
415 FT_Long* coords ) | 414 FT_Long* coords ) |
416 { | 415 { |
417 PS_Blend blend = face->blend; | 416 PS_Blend blend = face->blend; |
418 FT_Error error; | |
419 FT_UInt n, p; | 417 FT_UInt n, p; |
| 418 FT_Fixed final_blends[T1_MAX_MM_DESIGNS]; |
420 | 419 |
421 | 420 |
422 error = FT_ERR( Invalid_Argument ); | 421 if ( !blend ) |
423 if ( blend && blend->num_axis == num_coords ) | 422 return FT_THROW( Invalid_Argument ); |
| 423 |
| 424 if ( num_coords > blend->num_axis ) |
| 425 num_coords = blend->num_axis; |
| 426 |
| 427 /* compute the blend coordinates through the blend design map */ |
| 428 |
| 429 for ( n = 0; n < blend->num_axis; n++ ) |
424 { | 430 { |
425 /* compute the blend coordinates through the blend design map */ | 431 FT_Long design; |
426 FT_Fixed final_blends[T1_MAX_MM_DESIGNS]; | 432 FT_Fixed the_blend; |
| 433 PS_DesignMap map = blend->design_map + n; |
| 434 FT_Long* designs = map->design_points; |
| 435 FT_Fixed* blends = map->blend_points; |
| 436 FT_Int before = -1, after = -1; |
427 | 437 |
428 | 438 |
429 for ( n = 0; n < blend->num_axis; n++ ) | 439 /* use a default value if we don't have a coordinate */ |
| 440 if ( n < num_coords ) |
| 441 design = coords[n]; |
| 442 else |
| 443 design = ( designs[map->num_points - 1] - designs[0] ) / 2; |
| 444 |
| 445 for ( p = 0; p < (FT_UInt)map->num_points; p++ ) |
430 { | 446 { |
431 FT_Long design = coords[n]; | 447 FT_Long p_design = designs[p]; |
432 FT_Fixed the_blend; | |
433 PS_DesignMap map = blend->design_map + n; | |
434 FT_Long* designs = map->design_points; | |
435 FT_Fixed* blends = map->blend_points; | |
436 FT_Int before = -1, after = -1; | |
437 | 448 |
438 | 449 |
439 for ( p = 0; p < (FT_UInt)map->num_points; p++ ) | 450 /* exact match? */ |
| 451 if ( design == p_design ) |
440 { | 452 { |
441 FT_Long p_design = designs[p]; | 453 the_blend = blends[p]; |
442 | 454 goto Found; |
443 | |
444 /* exact match? */ | |
445 if ( design == p_design ) | |
446 { | |
447 the_blend = blends[p]; | |
448 goto Found; | |
449 } | |
450 | |
451 if ( design < p_design ) | |
452 { | |
453 after = p; | |
454 break; | |
455 } | |
456 | |
457 before = p; | |
458 } | 455 } |
459 | 456 |
460 /* now interpolate if necessary */ | 457 if ( design < p_design ) |
461 if ( before < 0 ) | 458 { |
462 the_blend = blends[0]; | 459 after = (FT_Int)p; |
| 460 break; |
| 461 } |
463 | 462 |
464 else if ( after < 0 ) | 463 before = (FT_Int)p; |
465 the_blend = blends[map->num_points - 1]; | |
466 | |
467 else | |
468 the_blend = FT_MulDiv( design - designs[before], | |
469 blends [after] - blends [before], | |
470 designs[after] - designs[before] ); | |
471 | |
472 Found: | |
473 final_blends[n] = the_blend; | |
474 } | 464 } |
475 | 465 |
476 error = T1_Set_MM_Blend( face, num_coords, final_blends ); | 466 /* now interpolate if necessary */ |
| 467 if ( before < 0 ) |
| 468 the_blend = blends[0]; |
| 469 |
| 470 else if ( after < 0 ) |
| 471 the_blend = blends[map->num_points - 1]; |
| 472 |
| 473 else |
| 474 the_blend = FT_MulDiv( design - designs[before], |
| 475 blends [after] - blends [before], |
| 476 designs[after] - designs[before] ); |
| 477 |
| 478 Found: |
| 479 final_blends[n] = the_blend; |
477 } | 480 } |
478 | 481 |
479 return error; | 482 return T1_Set_MM_Blend( face, blend->num_axis, final_blends ); |
480 } | 483 } |
481 | 484 |
482 | 485 |
483 /*************************************************************************/ | 486 /*************************************************************************/ |
484 /* */ | 487 /* */ |
485 /* Just a wrapper around T1_Set_MM_Design to support the different */ | 488 /* Just a wrapper around T1_Set_MM_Design to support the different */ |
486 /* arguments needed by the GX var distortable fonts. */ | 489 /* arguments needed by the GX var distortable fonts. */ |
487 /* */ | 490 /* */ |
488 FT_LOCAL_DEF( FT_Error ) | 491 FT_LOCAL_DEF( FT_Error ) |
489 T1_Set_Var_Design( T1_Face face, | 492 T1_Set_Var_Design( T1_Face face, |
490 FT_UInt num_coords, | 493 FT_UInt num_coords, |
491 FT_Fixed* coords ) | 494 FT_Fixed* coords ) |
492 { | 495 { |
493 FT_Long lcoords[4]; /* maximum axis count is 4 */ | 496 FT_Long lcoords[T1_MAX_MM_AXIS]; |
494 FT_UInt i; | 497 FT_UInt i; |
495 FT_Error error; | |
496 | 498 |
497 | 499 |
498 error = FT_ERR( Invalid_Argument ); | 500 if ( num_coords > T1_MAX_MM_AXIS ) |
499 if ( num_coords <= 4 && num_coords > 0 ) | 501 num_coords = T1_MAX_MM_AXIS; |
500 { | |
501 for ( i = 0; i < num_coords; ++i ) | |
502 lcoords[i] = FIXED_TO_INT( coords[i] ); | |
503 error = T1_Set_MM_Design( face, num_coords, lcoords ); | |
504 } | |
505 | 502 |
506 return error; | 503 for ( i = 0; i < num_coords; ++i ) |
| 504 lcoords[i] = FIXED_TO_INT( coords[i] ); |
| 505 |
| 506 return T1_Set_MM_Design( face, num_coords, lcoords ); |
507 } | 507 } |
508 | 508 |
509 | 509 |
510 FT_LOCAL_DEF( void ) | 510 FT_LOCAL_DEF( void ) |
511 T1_Done_Blend( T1_Face face ) | 511 T1_Done_Blend( T1_Face face ) |
512 { | 512 { |
513 FT_Memory memory = face->root.memory; | 513 FT_Memory memory = face->root.memory; |
514 PS_Blend blend = face->blend; | 514 PS_Blend blend = face->blend; |
515 | 515 |
516 | 516 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 error = t1_allocate_blend( face, 0, (FT_UInt)num_axis ); | 592 error = t1_allocate_blend( face, 0, (FT_UInt)num_axis ); |
593 if ( error ) | 593 if ( error ) |
594 goto Exit; | 594 goto Exit; |
595 | 595 |
596 blend = face->blend; | 596 blend = face->blend; |
597 memory = face->root.memory; | 597 memory = face->root.memory; |
598 | 598 |
599 /* each token is an immediate containing the name of the axis */ | 599 /* each token is an immediate containing the name of the axis */ |
600 for ( n = 0; n < num_axis; n++ ) | 600 for ( n = 0; n < num_axis; n++ ) |
601 { | 601 { |
602 T1_Token token = axis_tokens + n; | 602 T1_Token token = axis_tokens + n; |
603 FT_Byte* name; | 603 FT_Byte* name; |
604 FT_PtrDist len; | 604 FT_UInt len; |
605 | 605 |
606 | 606 |
607 /* skip first slash, if any */ | 607 /* skip first slash, if any */ |
608 if ( token->start[0] == '/' ) | 608 if ( token->start[0] == '/' ) |
609 token->start++; | 609 token->start++; |
610 | 610 |
611 len = token->limit - token->start; | 611 len = (FT_UInt)( token->limit - token->start ); |
612 if ( len == 0 ) | 612 if ( len == 0 ) |
613 { | 613 { |
614 error = FT_THROW( Invalid_File_Format ); | 614 error = FT_THROW( Invalid_File_Format ); |
615 goto Exit; | 615 goto Exit; |
616 } | 616 } |
617 | 617 |
618 if ( FT_ALLOC( blend->axis_names[n], (FT_Long)( len + 1 ) ) ) | 618 name = (FT_Byte*)blend->axis_names[n]; |
| 619 if ( name ) |
| 620 { |
| 621 FT_TRACE0(( "parse_blend_axis_types:" |
| 622 " overwriting axis name `%s' with `%*.s'\n", |
| 623 name, len, token->start )); |
| 624 FT_FREE( name ); |
| 625 } |
| 626 |
| 627 if ( FT_ALLOC( blend->axis_names[n], len + 1 ) ) |
619 goto Exit; | 628 goto Exit; |
620 | 629 |
621 name = (FT_Byte*)blend->axis_names[n]; | 630 name = (FT_Byte*)blend->axis_names[n]; |
622 FT_MEM_COPY( name, token->start, len ); | 631 FT_MEM_COPY( name, token->start, len ); |
623 name[len] = '\0'; | 632 name[len] = '\0'; |
624 } | 633 } |
625 | 634 |
626 Exit: | 635 Exit: |
627 loader->parser.root.error = error; | 636 loader->parser.root.error = error; |
628 } | 637 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 if ( n_axis <= 0 || n_axis > T1_MAX_MM_AXIS ) | 694 if ( n_axis <= 0 || n_axis > T1_MAX_MM_AXIS ) |
686 { | 695 { |
687 FT_ERROR(( "parse_blend_design_positions:" | 696 FT_ERROR(( "parse_blend_design_positions:" |
688 " invalid number of axes: %d\n", | 697 " invalid number of axes: %d\n", |
689 n_axis )); | 698 n_axis )); |
690 error = FT_THROW( Invalid_File_Format ); | 699 error = FT_THROW( Invalid_File_Format ); |
691 goto Exit; | 700 goto Exit; |
692 } | 701 } |
693 | 702 |
694 num_axis = n_axis; | 703 num_axis = n_axis; |
695 error = t1_allocate_blend( face, num_designs, num_axis ); | 704 error = t1_allocate_blend( face, |
| 705 (FT_UInt)num_designs, |
| 706 (FT_UInt)num_axis ); |
696 if ( error ) | 707 if ( error ) |
697 goto Exit; | 708 goto Exit; |
698 blend = face->blend; | 709 blend = face->blend; |
699 } | 710 } |
700 else if ( n_axis != num_axis ) | 711 else if ( n_axis != num_axis ) |
701 { | 712 { |
702 FT_ERROR(( "parse_blend_design_positions: incorrect table\n" )); | 713 FT_ERROR(( "parse_blend_design_positions: incorrect table\n" )); |
703 error = FT_THROW( Invalid_File_Format ); | 714 error = FT_THROW( Invalid_File_Format ); |
704 goto Exit; | 715 goto Exit; |
705 } | 716 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 { | 761 { |
751 FT_ERROR(( "parse_blend_design_map: incorrect number of axes: %d\n", | 762 FT_ERROR(( "parse_blend_design_map: incorrect number of axes: %d\n", |
752 num_axis )); | 763 num_axis )); |
753 error = FT_THROW( Invalid_File_Format ); | 764 error = FT_THROW( Invalid_File_Format ); |
754 goto Exit; | 765 goto Exit; |
755 } | 766 } |
756 | 767 |
757 old_cursor = parser->root.cursor; | 768 old_cursor = parser->root.cursor; |
758 old_limit = parser->root.limit; | 769 old_limit = parser->root.limit; |
759 | 770 |
760 error = t1_allocate_blend( face, 0, num_axis ); | 771 error = t1_allocate_blend( face, 0, (FT_UInt)num_axis ); |
761 if ( error ) | 772 if ( error ) |
762 goto Exit; | 773 goto Exit; |
763 blend = face->blend; | 774 blend = face->blend; |
764 | 775 |
765 /* now read each axis design map */ | 776 /* now read each axis design map */ |
766 for ( n = 0; n < num_axis; n++ ) | 777 for ( n = 0; n < num_axis; n++ ) |
767 { | 778 { |
768 PS_DesignMap map = blend->design_map + n; | 779 PS_DesignMap map = blend->design_map + n; |
769 T1_Token axis_token; | 780 T1_Token axis_token; |
770 T1_TokenRec point_tokens[T1_MAX_MM_MAP_POINTS]; | 781 T1_TokenRec point_tokens[T1_MAX_MM_MAP_POINTS]; |
771 FT_Int p, num_points; | 782 FT_Int p, num_points; |
772 | 783 |
773 | 784 |
774 axis_token = axis_tokens + n; | 785 axis_token = axis_tokens + n; |
775 | 786 |
776 parser->root.cursor = axis_token->start; | 787 parser->root.cursor = axis_token->start; |
777 parser->root.limit = axis_token->limit; | 788 parser->root.limit = axis_token->limit; |
778 T1_ToTokenArray( parser, point_tokens, | 789 T1_ToTokenArray( parser, point_tokens, |
779 T1_MAX_MM_MAP_POINTS, &num_points ); | 790 T1_MAX_MM_MAP_POINTS, &num_points ); |
780 | 791 |
781 if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS ) | 792 if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS ) |
782 { | 793 { |
783 FT_ERROR(( "parse_blend_design_map: incorrect table\n" )); | 794 FT_ERROR(( "parse_blend_design_map: incorrect table\n" )); |
784 error = FT_THROW( Invalid_File_Format ); | 795 error = FT_THROW( Invalid_File_Format ); |
785 goto Exit; | 796 goto Exit; |
786 } | 797 } |
787 | 798 |
| 799 if ( map->design_points ) |
| 800 { |
| 801 FT_ERROR(( "parse_blend_design_map: duplicate table\n" )); |
| 802 error = FT_THROW( Invalid_File_Format ); |
| 803 goto Exit; |
| 804 } |
| 805 |
788 /* allocate design map data */ | 806 /* allocate design map data */ |
789 if ( FT_NEW_ARRAY( map->design_points, num_points * 2 ) ) | 807 if ( FT_NEW_ARRAY( map->design_points, num_points * 2 ) ) |
790 goto Exit; | 808 goto Exit; |
791 map->blend_points = map->design_points + num_points; | 809 map->blend_points = map->design_points + num_points; |
792 map->num_points = (FT_Byte)num_points; | 810 map->num_points = (FT_Byte)num_points; |
793 | 811 |
794 for ( p = 0; p < num_points; p++ ) | 812 for ( p = 0; p < num_points; p++ ) |
795 { | 813 { |
796 T1_Token point_token; | 814 T1_Token point_token; |
797 | 815 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 { | 859 { |
842 FT_ERROR(( "parse_weight_vector:" | 860 FT_ERROR(( "parse_weight_vector:" |
843 " incorrect number of designs: %d\n", | 861 " incorrect number of designs: %d\n", |
844 num_designs )); | 862 num_designs )); |
845 error = FT_THROW( Invalid_File_Format ); | 863 error = FT_THROW( Invalid_File_Format ); |
846 goto Exit; | 864 goto Exit; |
847 } | 865 } |
848 | 866 |
849 if ( !blend || !blend->num_designs ) | 867 if ( !blend || !blend->num_designs ) |
850 { | 868 { |
851 error = t1_allocate_blend( face, num_designs, 0 ); | 869 error = t1_allocate_blend( face, (FT_UInt)num_designs, 0 ); |
852 if ( error ) | 870 if ( error ) |
853 goto Exit; | 871 goto Exit; |
854 blend = face->blend; | 872 blend = face->blend; |
855 } | 873 } |
856 else if ( blend->num_designs != (FT_UInt)num_designs ) | 874 else if ( blend->num_designs != (FT_UInt)num_designs ) |
857 { | 875 { |
858 FT_ERROR(( "parse_weight_vector:" | 876 FT_ERROR(( "parse_weight_vector:" |
859 " /BlendDesignPosition and /WeightVector have\n" | 877 " /BlendDesignPosition and /WeightVector have\n" |
860 " " | 878 " " |
861 " different number of elements\n" )); | 879 " different number of elements\n" )); |
(...skipping 21 matching lines...) Expand all Loading... |
883 parser->root.error = error; | 901 parser->root.error = error; |
884 } | 902 } |
885 | 903 |
886 | 904 |
887 /* e.g., /BuildCharArray [0 0 0 0 0 0 0 0] def */ | 905 /* e.g., /BuildCharArray [0 0 0 0 0 0 0 0] def */ |
888 /* we're only interested in the number of array elements */ | 906 /* we're only interested in the number of array elements */ |
889 static void | 907 static void |
890 parse_buildchar( T1_Face face, | 908 parse_buildchar( T1_Face face, |
891 T1_Loader loader ) | 909 T1_Loader loader ) |
892 { | 910 { |
893 face->len_buildchar = T1_ToFixedArray( &loader->parser, 0, NULL, 0 ); | 911 face->len_buildchar = (FT_UInt)T1_ToFixedArray( &loader->parser, |
894 | 912 0, NULL, 0 ); |
895 return; | 913 return; |
896 } | 914 } |
897 | 915 |
898 | 916 |
899 #endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */ | 917 #endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */ |
900 | 918 |
901 | 919 |
902 | 920 |
903 | 921 |
904 /*************************************************************************/ | 922 /*************************************************************************/ |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 static void | 1049 static void |
1032 parse_private( T1_Face face, | 1050 parse_private( T1_Face face, |
1033 T1_Loader loader ) | 1051 T1_Loader loader ) |
1034 { | 1052 { |
1035 FT_UNUSED( face ); | 1053 FT_UNUSED( face ); |
1036 | 1054 |
1037 loader->keywords_encountered |= T1_PRIVATE; | 1055 loader->keywords_encountered |= T1_PRIVATE; |
1038 } | 1056 } |
1039 | 1057 |
1040 | 1058 |
| 1059 /* return 1 in case of success */ |
| 1060 |
1041 static int | 1061 static int |
1042 read_binary_data( T1_Parser parser, | 1062 read_binary_data( T1_Parser parser, |
1043 FT_Long* size, | 1063 FT_ULong* size, |
1044 FT_Byte** base, | 1064 FT_Byte** base, |
1045 FT_Bool incremental ) | 1065 FT_Bool incremental ) |
1046 { | 1066 { |
1047 FT_Byte* cur; | 1067 FT_Byte* cur; |
1048 FT_Byte* limit = parser->root.limit; | 1068 FT_Byte* limit = parser->root.limit; |
1049 | 1069 |
1050 | 1070 |
1051 /* the binary data has one of the following formats */ | 1071 /* the binary data has one of the following formats */ |
1052 /* */ | 1072 /* */ |
1053 /* `size' [white*] RD white ....... ND */ | 1073 /* `size' [white*] RD white ....... ND */ |
(...skipping 11 matching lines...) Expand all Loading... |
1065 | 1085 |
1066 T1_Skip_PS_Token( parser ); /* `RD' or `-|' or something else */ | 1086 T1_Skip_PS_Token( parser ); /* `RD' or `-|' or something else */ |
1067 | 1087 |
1068 /* there is only one whitespace char after the */ | 1088 /* there is only one whitespace char after the */ |
1069 /* `RD' or `-|' token */ | 1089 /* `RD' or `-|' token */ |
1070 *base = parser->root.cursor + 1; | 1090 *base = parser->root.cursor + 1; |
1071 | 1091 |
1072 if ( s >= 0 && s < limit - *base ) | 1092 if ( s >= 0 && s < limit - *base ) |
1073 { | 1093 { |
1074 parser->root.cursor += s + 1; | 1094 parser->root.cursor += s + 1; |
1075 *size = s; | 1095 *size = (FT_ULong)s; |
1076 return !parser->root.error; | 1096 return !parser->root.error; |
1077 } | 1097 } |
1078 } | 1098 } |
1079 | 1099 |
1080 if( !incremental ) | 1100 if( !incremental ) |
1081 { | 1101 { |
1082 FT_ERROR(( "read_binary_data: invalid size field\n" )); | 1102 FT_ERROR(( "read_binary_data: invalid size field\n" )); |
1083 parser->root.error = FT_THROW( Invalid_File_Format ); | 1103 parser->root.error = FT_THROW( Invalid_File_Format ); |
1084 } | 1104 } |
1085 | 1105 |
(...skipping 10 matching lines...) Expand all Loading... |
1096 { | 1116 { |
1097 T1_Parser parser = &loader->parser; | 1117 T1_Parser parser = &loader->parser; |
1098 FT_Matrix* matrix = &face->type1.font_matrix; | 1118 FT_Matrix* matrix = &face->type1.font_matrix; |
1099 FT_Vector* offset = &face->type1.font_offset; | 1119 FT_Vector* offset = &face->type1.font_offset; |
1100 FT_Face root = (FT_Face)&face->root; | 1120 FT_Face root = (FT_Face)&face->root; |
1101 FT_Fixed temp[6]; | 1121 FT_Fixed temp[6]; |
1102 FT_Fixed temp_scale; | 1122 FT_Fixed temp_scale; |
1103 FT_Int result; | 1123 FT_Int result; |
1104 | 1124 |
1105 | 1125 |
| 1126 /* input is scaled by 1000 to accommodate default FontMatrix */ |
1106 result = T1_ToFixedArray( parser, 6, temp, 3 ); | 1127 result = T1_ToFixedArray( parser, 6, temp, 3 ); |
1107 | 1128 |
1108 if ( result < 6 ) | 1129 if ( result < 6 ) |
1109 { | 1130 { |
1110 parser->root.error = FT_THROW( Invalid_File_Format ); | 1131 parser->root.error = FT_THROW( Invalid_File_Format ); |
1111 return; | 1132 return; |
1112 } | 1133 } |
1113 | 1134 |
1114 temp_scale = FT_ABS( temp[3] ); | 1135 temp_scale = FT_ABS( temp[3] ); |
1115 | 1136 |
1116 if ( temp_scale == 0 ) | 1137 if ( temp_scale == 0 ) |
1117 { | 1138 { |
1118 FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" )); | 1139 FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" )); |
1119 parser->root.error = FT_THROW( Invalid_File_Format ); | 1140 parser->root.error = FT_THROW( Invalid_File_Format ); |
1120 return; | 1141 return; |
1121 } | 1142 } |
1122 | 1143 |
1123 /* Set Units per EM based on FontMatrix values. We set the value to */ | 1144 /* atypical case */ |
1124 /* 1000 / temp_scale, because temp_scale was already multiplied by */ | |
1125 /* 1000 (in t1_tofixed, from psobjs.c). */ | |
1126 | |
1127 root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale ); | |
1128 | |
1129 /* we need to scale the values by 1.0/temp_scale */ | |
1130 if ( temp_scale != 0x10000L ) | 1145 if ( temp_scale != 0x10000L ) |
1131 { | 1146 { |
| 1147 /* set units per EM based on FontMatrix values */ |
| 1148 root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale ); |
| 1149 |
1132 temp[0] = FT_DivFix( temp[0], temp_scale ); | 1150 temp[0] = FT_DivFix( temp[0], temp_scale ); |
1133 temp[1] = FT_DivFix( temp[1], temp_scale ); | 1151 temp[1] = FT_DivFix( temp[1], temp_scale ); |
1134 temp[2] = FT_DivFix( temp[2], temp_scale ); | 1152 temp[2] = FT_DivFix( temp[2], temp_scale ); |
1135 temp[4] = FT_DivFix( temp[4], temp_scale ); | 1153 temp[4] = FT_DivFix( temp[4], temp_scale ); |
1136 temp[5] = FT_DivFix( temp[5], temp_scale ); | 1154 temp[5] = FT_DivFix( temp[5], temp_scale ); |
1137 temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L; | 1155 temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L; |
1138 } | 1156 } |
1139 | 1157 |
1140 matrix->xx = temp[0]; | 1158 matrix->xx = temp[0]; |
1141 matrix->yx = temp[1]; | 1159 matrix->yx = temp[1]; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 /* read the number of entries in the encoding; should be 256 */ | 1201 /* read the number of entries in the encoding; should be 256 */ |
1184 if ( *cur == '[' ) | 1202 if ( *cur == '[' ) |
1185 { | 1203 { |
1186 count = 256; | 1204 count = 256; |
1187 only_immediates = 1; | 1205 only_immediates = 1; |
1188 parser->root.cursor++; | 1206 parser->root.cursor++; |
1189 } | 1207 } |
1190 else | 1208 else |
1191 count = (FT_Int)T1_ToInt( parser ); | 1209 count = (FT_Int)T1_ToInt( parser ); |
1192 | 1210 |
| 1211 /* only composite fonts (which we don't support) */ |
| 1212 /* can have larger values */ |
| 1213 if ( count > 256 ) |
| 1214 { |
| 1215 FT_ERROR(( "parse_encoding: invalid encoding array size\n" )); |
| 1216 parser->root.error = FT_THROW( Invalid_File_Format ); |
| 1217 return; |
| 1218 } |
| 1219 |
1193 T1_Skip_Spaces( parser ); | 1220 T1_Skip_Spaces( parser ); |
1194 if ( parser->root.cursor >= limit ) | 1221 if ( parser->root.cursor >= limit ) |
1195 return; | 1222 return; |
1196 | 1223 |
| 1224 /* PostScript happily allows overwriting of encoding arrays */ |
| 1225 if ( encode->char_index ) |
| 1226 { |
| 1227 FT_FREE( encode->char_index ); |
| 1228 FT_FREE( encode->char_name ); |
| 1229 T1_Release_Table( char_table ); |
| 1230 } |
| 1231 |
1197 /* we use a T1_Table to store our charnames */ | 1232 /* we use a T1_Table to store our charnames */ |
1198 loader->num_chars = encode->num_chars = count; | 1233 loader->num_chars = encode->num_chars = count; |
1199 if ( FT_NEW_ARRAY( encode->char_index, count ) || | 1234 if ( FT_NEW_ARRAY( encode->char_index, count ) || |
1200 FT_NEW_ARRAY( encode->char_name, count ) || | 1235 FT_NEW_ARRAY( encode->char_name, count ) || |
1201 FT_SET_ERROR( psaux->ps_table_funcs->init( | 1236 FT_SET_ERROR( psaux->ps_table_funcs->init( |
1202 char_table, count, memory ) ) ) | 1237 char_table, count, memory ) ) ) |
1203 { | 1238 { |
1204 parser->root.error = error; | 1239 parser->root.error = error; |
1205 return; | 1240 return; |
1206 } | 1241 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 { | 1313 { |
1279 parser->root.error = FT_THROW( Unknown_File_Format ); | 1314 parser->root.error = FT_THROW( Unknown_File_Format ); |
1280 return; | 1315 return; |
1281 } | 1316 } |
1282 } | 1317 } |
1283 | 1318 |
1284 cur = parser->root.cursor; | 1319 cur = parser->root.cursor; |
1285 | 1320 |
1286 if ( cur + 2 < limit && *cur == '/' && n < count ) | 1321 if ( cur + 2 < limit && *cur == '/' && n < count ) |
1287 { | 1322 { |
1288 FT_PtrDist len; | 1323 FT_UInt len; |
1289 | 1324 |
1290 | 1325 |
1291 cur++; | 1326 cur++; |
1292 | 1327 |
1293 parser->root.cursor = cur; | 1328 parser->root.cursor = cur; |
1294 T1_Skip_PS_Token( parser ); | 1329 T1_Skip_PS_Token( parser ); |
1295 if ( parser->root.cursor >= limit ) | 1330 if ( parser->root.cursor >= limit ) |
1296 return; | 1331 return; |
1297 if ( parser->root.error ) | 1332 if ( parser->root.error ) |
1298 return; | 1333 return; |
1299 | 1334 |
1300 len = parser->root.cursor - cur; | 1335 len = (FT_UInt)( parser->root.cursor - cur ); |
1301 | 1336 |
1302 parser->root.error = T1_Add_Table( char_table, charcode, | 1337 parser->root.error = T1_Add_Table( char_table, charcode, |
1303 cur, len + 1 ); | 1338 cur, len + 1 ); |
1304 if ( parser->root.error ) | 1339 if ( parser->root.error ) |
1305 return; | 1340 return; |
1306 char_table->elements[charcode][len] = '\0'; | 1341 char_table->elements[charcode][len] = '\0'; |
1307 | 1342 |
1308 n++; | 1343 n++; |
1309 } | 1344 } |
1310 else if ( only_immediates ) | 1345 else if ( only_immediates ) |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 if ( error ) | 1435 if ( error ) |
1401 goto Fail; | 1436 goto Fail; |
1402 } | 1437 } |
1403 | 1438 |
1404 /* the format is simple: */ | 1439 /* the format is simple: */ |
1405 /* */ | 1440 /* */ |
1406 /* `index' + binary data */ | 1441 /* `index' + binary data */ |
1407 /* */ | 1442 /* */ |
1408 for (;;) | 1443 for (;;) |
1409 { | 1444 { |
1410 FT_Long idx, size; | 1445 FT_Long idx; |
| 1446 FT_ULong size; |
1411 FT_Byte* base; | 1447 FT_Byte* base; |
1412 | 1448 |
1413 | 1449 |
1414 /* If we are out of data, or if the next token isn't `dup', */ | 1450 /* If we are out of data, or if the next token isn't `dup', */ |
1415 /* we are done. */ | 1451 /* we are done. */ |
1416 if ( parser->root.cursor + 4 >= parser->root.limit || | 1452 if ( parser->root.cursor + 4 >= parser->root.limit || |
1417 ft_strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 ) | 1453 ft_strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 ) |
1418 break; | 1454 break; |
1419 | 1455 |
1420 T1_Skip_PS_Token( parser ); /* `dup' */ | 1456 T1_Skip_PS_Token( parser ); /* `dup' */ |
(...skipping 29 matching lines...) Expand all Loading... |
1450 /* thanks to Tom Kacvinsky for pointing this out */ | 1486 /* thanks to Tom Kacvinsky for pointing this out */ |
1451 /* */ | 1487 /* */ |
1452 if ( face->type1.private_dict.lenIV >= 0 ) | 1488 if ( face->type1.private_dict.lenIV >= 0 ) |
1453 { | 1489 { |
1454 FT_Byte* temp; | 1490 FT_Byte* temp; |
1455 | 1491 |
1456 | 1492 |
1457 /* some fonts define empty subr records -- this is not totally */ | 1493 /* some fonts define empty subr records -- this is not totally */ |
1458 /* compliant to the specification (which says they should at */ | 1494 /* compliant to the specification (which says they should at */ |
1459 /* least contain a `return'), but we support them anyway */ | 1495 /* least contain a `return'), but we support them anyway */ |
1460 if ( size < face->type1.private_dict.lenIV ) | 1496 if ( size < (FT_ULong)face->type1.private_dict.lenIV ) |
1461 { | 1497 { |
1462 error = FT_THROW( Invalid_File_Format ); | 1498 error = FT_THROW( Invalid_File_Format ); |
1463 goto Fail; | 1499 goto Fail; |
1464 } | 1500 } |
1465 | 1501 |
1466 /* t1_decrypt() shouldn't write to base -- make temporary copy */ | 1502 /* t1_decrypt() shouldn't write to base -- make temporary copy */ |
1467 if ( FT_ALLOC( temp, size ) ) | 1503 if ( FT_ALLOC( temp, size ) ) |
1468 goto Fail; | 1504 goto Fail; |
1469 FT_MEM_COPY( temp, base, size ); | 1505 FT_MEM_COPY( temp, base, size ); |
1470 psaux->t1_decrypt( temp, size, 4330 ); | 1506 psaux->t1_decrypt( temp, size, 4330 ); |
1471 size -= face->type1.private_dict.lenIV; | 1507 size -= (FT_ULong)face->type1.private_dict.lenIV; |
1472 error = T1_Add_Table( table, (FT_Int)idx, | 1508 error = T1_Add_Table( table, (FT_Int)idx, |
1473 temp + face->type1.private_dict.lenIV, size ); | 1509 temp + face->type1.private_dict.lenIV, size ); |
1474 FT_FREE( temp ); | 1510 FT_FREE( temp ); |
1475 } | 1511 } |
1476 else | 1512 else |
1477 error = T1_Add_Table( table, (FT_Int)idx, base, size ); | 1513 error = T1_Add_Table( table, (FT_Int)idx, base, size ); |
1478 if ( error ) | 1514 if ( error ) |
1479 goto Fail; | 1515 goto Fail; |
1480 } | 1516 } |
1481 | 1517 |
(...skipping 16 matching lines...) Expand all Loading... |
1498 { | 1534 { |
1499 T1_Parser parser = &loader->parser; | 1535 T1_Parser parser = &loader->parser; |
1500 PS_Table code_table = &loader->charstrings; | 1536 PS_Table code_table = &loader->charstrings; |
1501 PS_Table name_table = &loader->glyph_names; | 1537 PS_Table name_table = &loader->glyph_names; |
1502 PS_Table swap_table = &loader->swap_table; | 1538 PS_Table swap_table = &loader->swap_table; |
1503 FT_Memory memory = parser->root.memory; | 1539 FT_Memory memory = parser->root.memory; |
1504 FT_Error error; | 1540 FT_Error error; |
1505 | 1541 |
1506 PSAux_Service psaux = (PSAux_Service)face->psaux; | 1542 PSAux_Service psaux = (PSAux_Service)face->psaux; |
1507 | 1543 |
1508 FT_Byte* cur; | 1544 FT_Byte* cur = parser->root.cursor; |
1509 FT_Byte* limit = parser->root.limit; | 1545 FT_Byte* limit = parser->root.limit; |
1510 FT_Int n, num_glyphs; | 1546 FT_Int n, num_glyphs; |
1511 FT_UInt notdef_index = 0; | 1547 FT_Int notdef_index = 0; |
1512 FT_Byte notdef_found = 0; | 1548 FT_Byte notdef_found = 0; |
1513 | 1549 |
1514 | 1550 |
1515 num_glyphs = (FT_Int)T1_ToInt( parser ); | 1551 num_glyphs = (FT_Int)T1_ToInt( parser ); |
1516 if ( num_glyphs < 0 ) | 1552 if ( num_glyphs < 0 ) |
1517 { | 1553 { |
1518 error = FT_THROW( Invalid_File_Format ); | 1554 error = FT_THROW( Invalid_File_Format ); |
1519 goto Fail; | 1555 goto Fail; |
1520 } | 1556 } |
1521 | 1557 |
| 1558 /* we certainly need more than 8 bytes per glyph */ |
| 1559 if ( num_glyphs > ( limit - cur ) >> 3 ) |
| 1560 { |
| 1561 FT_TRACE0(( "parse_charstrings: adjusting number of glyphs" |
| 1562 " (from %d to %d)\n", |
| 1563 num_glyphs, ( limit - cur ) >> 3 )); |
| 1564 num_glyphs = ( limit - cur ) >> 3; |
| 1565 } |
| 1566 |
1522 /* some fonts like Optima-Oblique not only define the /CharStrings */ | 1567 /* some fonts like Optima-Oblique not only define the /CharStrings */ |
1523 /* array but access it also */ | 1568 /* array but access it also */ |
1524 if ( num_glyphs == 0 || parser->root.error ) | 1569 if ( num_glyphs == 0 || parser->root.error ) |
1525 return; | 1570 return; |
1526 | 1571 |
1527 /* initialize tables, leaving space for addition of .notdef, */ | 1572 /* initialize tables, leaving space for addition of .notdef, */ |
1528 /* if necessary, and a few other glyphs to handle buggy */ | 1573 /* if necessary, and a few other glyphs to handle buggy */ |
1529 /* fonts which have more glyphs than specified. */ | 1574 /* fonts which have more glyphs than specified. */ |
1530 | 1575 |
1531 /* for some non-standard fonts like `Optima' which provides */ | 1576 /* for some non-standard fonts like `Optima' which provides */ |
(...skipping 16 matching lines...) Expand all Loading... |
1548 | 1593 |
1549 error = psaux->ps_table_funcs->init( swap_table, 4, memory ); | 1594 error = psaux->ps_table_funcs->init( swap_table, 4, memory ); |
1550 if ( error ) | 1595 if ( error ) |
1551 goto Fail; | 1596 goto Fail; |
1552 } | 1597 } |
1553 | 1598 |
1554 n = 0; | 1599 n = 0; |
1555 | 1600 |
1556 for (;;) | 1601 for (;;) |
1557 { | 1602 { |
1558 FT_Long size; | 1603 FT_ULong size; |
1559 FT_Byte* base; | 1604 FT_Byte* base; |
1560 | 1605 |
1561 | 1606 |
1562 /* the format is simple: */ | 1607 /* the format is simple: */ |
1563 /* `/glyphname' + binary data */ | 1608 /* `/glyphname' + binary data */ |
1564 | 1609 |
1565 T1_Skip_Spaces( parser ); | 1610 T1_Skip_Spaces( parser ); |
1566 | 1611 |
1567 cur = parser->root.cursor; | 1612 cur = parser->root.cursor; |
1568 if ( cur >= limit ) | 1613 if ( cur >= limit ) |
(...skipping 30 matching lines...) Expand all Loading... |
1599 if ( parser->root.cursor >= limit ) | 1644 if ( parser->root.cursor >= limit ) |
1600 { | 1645 { |
1601 error = FT_THROW( Invalid_File_Format ); | 1646 error = FT_THROW( Invalid_File_Format ); |
1602 goto Fail; | 1647 goto Fail; |
1603 } | 1648 } |
1604 if ( parser->root.error ) | 1649 if ( parser->root.error ) |
1605 return; | 1650 return; |
1606 | 1651 |
1607 if ( *cur == '/' ) | 1652 if ( *cur == '/' ) |
1608 { | 1653 { |
1609 FT_PtrDist len; | 1654 FT_UInt len; |
1610 | 1655 |
1611 | 1656 |
1612 if ( cur + 2 >= limit ) | 1657 if ( cur + 2 >= limit ) |
1613 { | 1658 { |
1614 error = FT_THROW( Invalid_File_Format ); | 1659 error = FT_THROW( Invalid_File_Format ); |
1615 goto Fail; | 1660 goto Fail; |
1616 } | 1661 } |
1617 | 1662 |
1618 cur++; /* skip `/' */ | 1663 cur++; /* skip `/' */ |
1619 len = parser->root.cursor - cur; | 1664 len = (FT_UInt)( parser->root.cursor - cur ); |
1620 | 1665 |
1621 if ( !read_binary_data( parser, &size, &base, IS_INCREMENTAL ) ) | 1666 if ( !read_binary_data( parser, &size, &base, IS_INCREMENTAL ) ) |
1622 return; | 1667 return; |
1623 | 1668 |
1624 /* for some non-standard fonts like `Optima' which provides */ | 1669 /* for some non-standard fonts like `Optima' which provides */ |
1625 /* different outlines depending on the resolution it is */ | 1670 /* different outlines depending on the resolution it is */ |
1626 /* possible to get here twice */ | 1671 /* possible to get here twice */ |
1627 if ( loader->num_glyphs ) | 1672 if ( loader->num_glyphs ) |
1628 continue; | 1673 continue; |
1629 | 1674 |
(...skipping 12 matching lines...) Expand all Loading... |
1642 notdef_index = n; | 1687 notdef_index = n; |
1643 notdef_found = 1; | 1688 notdef_found = 1; |
1644 } | 1689 } |
1645 | 1690 |
1646 if ( face->type1.private_dict.lenIV >= 0 && | 1691 if ( face->type1.private_dict.lenIV >= 0 && |
1647 n < num_glyphs + TABLE_EXTEND ) | 1692 n < num_glyphs + TABLE_EXTEND ) |
1648 { | 1693 { |
1649 FT_Byte* temp; | 1694 FT_Byte* temp; |
1650 | 1695 |
1651 | 1696 |
1652 if ( size <= face->type1.private_dict.lenIV ) | 1697 if ( size <= (FT_ULong)face->type1.private_dict.lenIV ) |
1653 { | 1698 { |
1654 error = FT_THROW( Invalid_File_Format ); | 1699 error = FT_THROW( Invalid_File_Format ); |
1655 goto Fail; | 1700 goto Fail; |
1656 } | 1701 } |
1657 | 1702 |
1658 /* t1_decrypt() shouldn't write to base -- make temporary copy */ | 1703 /* t1_decrypt() shouldn't write to base -- make temporary copy */ |
1659 if ( FT_ALLOC( temp, size ) ) | 1704 if ( FT_ALLOC( temp, size ) ) |
1660 goto Fail; | 1705 goto Fail; |
1661 FT_MEM_COPY( temp, base, size ); | 1706 FT_MEM_COPY( temp, base, size ); |
1662 psaux->t1_decrypt( temp, size, 4330 ); | 1707 psaux->t1_decrypt( temp, size, 4330 ); |
1663 size -= face->type1.private_dict.lenIV; | 1708 size -= (FT_ULong)face->type1.private_dict.lenIV; |
1664 error = T1_Add_Table( code_table, n, | 1709 error = T1_Add_Table( code_table, n, |
1665 temp + face->type1.private_dict.lenIV, size ); | 1710 temp + face->type1.private_dict.lenIV, size ); |
1666 FT_FREE( temp ); | 1711 FT_FREE( temp ); |
1667 } | 1712 } |
1668 else | 1713 else |
1669 error = T1_Add_Table( code_table, n, base, size ); | 1714 error = T1_Add_Table( code_table, n, base, size ); |
1670 if ( error ) | 1715 if ( error ) |
1671 goto Fail; | 1716 goto Fail; |
1672 | 1717 |
1673 n++; | 1718 n++; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1831 T1_FIELD_CALLBACK( "WeightVector", parse_weight_vector, | 1876 T1_FIELD_CALLBACK( "WeightVector", parse_weight_vector, |
1832 T1_FIELD_DICT_FONTDICT ) | 1877 T1_FIELD_DICT_FONTDICT ) |
1833 T1_FIELD_CALLBACK( "BuildCharArray", parse_buildchar, | 1878 T1_FIELD_CALLBACK( "BuildCharArray", parse_buildchar, |
1834 T1_FIELD_DICT_PRIVATE ) | 1879 T1_FIELD_DICT_PRIVATE ) |
1835 #endif | 1880 #endif |
1836 | 1881 |
1837 { 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0, 0 } | 1882 { 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0, 0 } |
1838 }; | 1883 }; |
1839 | 1884 |
1840 | 1885 |
1841 #define T1_FIELD_COUNT \ | |
1842 ( sizeof ( t1_keywords ) / sizeof ( t1_keywords[0] ) ) | |
1843 | |
1844 | |
1845 static FT_Error | 1886 static FT_Error |
1846 parse_dict( T1_Face face, | 1887 parse_dict( T1_Face face, |
1847 T1_Loader loader, | 1888 T1_Loader loader, |
1848 FT_Byte* base, | 1889 FT_Byte* base, |
1849 FT_Long size ) | 1890 FT_ULong size ) |
1850 { | 1891 { |
1851 T1_Parser parser = &loader->parser; | 1892 T1_Parser parser = &loader->parser; |
1852 FT_Byte *limit, *start_binary = NULL; | 1893 FT_Byte *limit, *start_binary = NULL; |
1853 FT_Bool have_integer = 0; | 1894 FT_Bool have_integer = 0; |
1854 | 1895 |
1855 | 1896 |
1856 parser->root.cursor = base; | 1897 parser->root.cursor = base; |
1857 parser->root.limit = base + size; | 1898 parser->root.limit = base + size; |
1858 parser->root.error = FT_Err_Ok; | 1899 parser->root.error = FT_Err_Ok; |
1859 | 1900 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 goto Exit; | 1936 goto Exit; |
1896 have_integer = 1; | 1937 have_integer = 1; |
1897 } | 1938 } |
1898 | 1939 |
1899 /* in valid Type 1 fonts we don't see `RD' or `-|' directly */ | 1940 /* in valid Type 1 fonts we don't see `RD' or `-|' directly */ |
1900 /* since those tokens are handled by parse_subrs and */ | 1941 /* since those tokens are handled by parse_subrs and */ |
1901 /* parse_charstrings */ | 1942 /* parse_charstrings */ |
1902 else if ( *cur == 'R' && cur + 6 < limit && *(cur + 1) == 'D' && | 1943 else if ( *cur == 'R' && cur + 6 < limit && *(cur + 1) == 'D' && |
1903 have_integer ) | 1944 have_integer ) |
1904 { | 1945 { |
1905 FT_Long s; | 1946 FT_ULong s; |
1906 FT_Byte* b; | 1947 FT_Byte* b; |
1907 | 1948 |
1908 | 1949 |
1909 parser->root.cursor = start_binary; | 1950 parser->root.cursor = start_binary; |
1910 if ( !read_binary_data( parser, &s, &b, IS_INCREMENTAL ) ) | 1951 if ( !read_binary_data( parser, &s, &b, IS_INCREMENTAL ) ) |
1911 return FT_THROW( Invalid_File_Format ); | 1952 return FT_THROW( Invalid_File_Format ); |
1912 have_integer = 0; | 1953 have_integer = 0; |
1913 } | 1954 } |
1914 | 1955 |
1915 else if ( *cur == '-' && cur + 6 < limit && *(cur + 1) == '|' && | 1956 else if ( *cur == '-' && cur + 6 < limit && *(cur + 1) == '|' && |
1916 have_integer ) | 1957 have_integer ) |
1917 { | 1958 { |
1918 FT_Long s; | 1959 FT_ULong s; |
1919 FT_Byte* b; | 1960 FT_Byte* b; |
1920 | 1961 |
1921 | 1962 |
1922 parser->root.cursor = start_binary; | 1963 parser->root.cursor = start_binary; |
1923 if ( !read_binary_data( parser, &s, &b, IS_INCREMENTAL ) ) | 1964 if ( !read_binary_data( parser, &s, &b, IS_INCREMENTAL ) ) |
1924 return FT_THROW( Invalid_File_Format ); | 1965 return FT_THROW( Invalid_File_Format ); |
1925 have_integer = 0; | 1966 have_integer = 0; |
1926 } | 1967 } |
1927 | 1968 |
1928 /* look for immediates */ | 1969 /* look for immediates */ |
1929 else if ( *cur == '/' && cur + 2 < limit ) | 1970 else if ( *cur == '/' && cur + 2 < limit ) |
1930 { | 1971 { |
1931 FT_PtrDist len; | 1972 FT_UInt len; |
1932 | 1973 |
1933 | 1974 |
1934 cur++; | 1975 cur++; |
1935 | 1976 |
1936 parser->root.cursor = cur; | 1977 parser->root.cursor = cur; |
1937 T1_Skip_PS_Token( parser ); | 1978 T1_Skip_PS_Token( parser ); |
1938 if ( parser->root.error ) | 1979 if ( parser->root.error ) |
1939 goto Exit; | 1980 goto Exit; |
1940 | 1981 |
1941 len = parser->root.cursor - cur; | 1982 len = (FT_UInt)( parser->root.cursor - cur ); |
1942 | 1983 |
1943 if ( len > 0 && len < 22 && parser->root.cursor < limit ) | 1984 if ( len > 0 && len < 22 && parser->root.cursor < limit ) |
1944 { | 1985 { |
1945 /* now compare the immediate name to the keyword table */ | 1986 /* now compare the immediate name to the keyword table */ |
1946 T1_Field keyword = (T1_Field)t1_keywords; | 1987 T1_Field keyword = (T1_Field)t1_keywords; |
1947 | 1988 |
1948 | 1989 |
1949 for (;;) | 1990 for (;;) |
1950 { | 1991 { |
1951 FT_Byte* name; | 1992 FT_Byte* name; |
1952 | 1993 |
1953 | 1994 |
1954 name = (FT_Byte*)keyword->ident; | 1995 name = (FT_Byte*)keyword->ident; |
1955 if ( !name ) | 1996 if ( !name ) |
1956 break; | 1997 break; |
1957 | 1998 |
1958 if ( cur[0] == name[0] && | 1999 if ( cur[0] == name[0] && |
1959 len == (FT_PtrDist)ft_strlen( (const char *)name ) && | 2000 len == ft_strlen( (const char *)name ) && |
1960 ft_memcmp( cur, name, len ) == 0 ) | 2001 ft_memcmp( cur, name, len ) == 0 ) |
1961 { | 2002 { |
1962 /* We found it -- run the parsing callback! */ | 2003 /* We found it -- run the parsing callback! */ |
1963 /* We record every instance of every field */ | 2004 /* We record every instance of every field */ |
1964 /* (until we reach the base font of a */ | 2005 /* (until we reach the base font of a */ |
1965 /* synthetic font) to deal adequately with */ | 2006 /* synthetic font) to deal adequately with */ |
1966 /* multiple master fonts; this is also */ | 2007 /* multiple master fonts; this is also */ |
1967 /* necessary because later PostScript */ | 2008 /* necessary because later PostScript */ |
1968 /* definitions override earlier ones. */ | 2009 /* definitions override earlier ones. */ |
1969 | 2010 |
1970 /* Once we encounter `FontDirectory' after */ | 2011 /* Once we encounter `FontDirectory' after */ |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2205 | 2246 |
2206 loader.charstrings.init = 0; | 2247 loader.charstrings.init = 0; |
2207 type1->charstrings_block = loader.charstrings.block; | 2248 type1->charstrings_block = loader.charstrings.block; |
2208 type1->charstrings = loader.charstrings.elements; | 2249 type1->charstrings = loader.charstrings.elements; |
2209 type1->charstrings_len = loader.charstrings.lengths; | 2250 type1->charstrings_len = loader.charstrings.lengths; |
2210 | 2251 |
2211 /* we copy the glyph names `block' and `elements' fields; */ | 2252 /* we copy the glyph names `block' and `elements' fields; */ |
2212 /* the `lengths' field must be released later */ | 2253 /* the `lengths' field must be released later */ |
2213 type1->glyph_names_block = loader.glyph_names.block; | 2254 type1->glyph_names_block = loader.glyph_names.block; |
2214 type1->glyph_names = (FT_String**)loader.glyph_names.elements; | 2255 type1->glyph_names = (FT_String**)loader.glyph_names.elements; |
2215 loader.glyph_names.block = 0; | 2256 loader.glyph_names.block = NULL; |
2216 loader.glyph_names.elements = 0; | 2257 loader.glyph_names.elements = NULL; |
2217 | 2258 |
2218 /* we must now build type1.encoding when we have a custom array */ | 2259 /* we must now build type1.encoding when we have a custom array */ |
2219 if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY ) | 2260 if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY ) |
2220 { | 2261 { |
2221 FT_Int charcode, idx, min_char, max_char; | 2262 FT_Int charcode, idx, min_char, max_char; |
2222 FT_Byte* glyph_name; | 2263 FT_Byte* glyph_name; |
2223 | 2264 |
2224 | 2265 |
2225 /* OK, we do the following: for each element in the encoding */ | 2266 /* OK, we do the following: for each element in the encoding */ |
2226 /* table, look up the index of the glyph having the same name */ | 2267 /* table, look up the index of the glyph having the same name */ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2270 type1->encoding.num_chars = loader.num_chars; | 2311 type1->encoding.num_chars = loader.num_chars; |
2271 } | 2312 } |
2272 | 2313 |
2273 Exit: | 2314 Exit: |
2274 t1_done_loader( &loader ); | 2315 t1_done_loader( &loader ); |
2275 return error; | 2316 return error; |
2276 } | 2317 } |
2277 | 2318 |
2278 | 2319 |
2279 /* END */ | 2320 /* END */ |
OLD | NEW |