OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* cffgload.c */ | 3 /* cffgload.c */ |
4 /* */ | 4 /* */ |
5 /* OpenType Glyph Loader (body). */ | 5 /* OpenType Glyph Loader (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 |
18 | 18 |
19 #include <ft2build.h> | 19 #include <ft2build.h> |
20 #include FT_INTERNAL_DEBUG_H | 20 #include FT_INTERNAL_DEBUG_H |
21 #include FT_INTERNAL_STREAM_H | 21 #include FT_INTERNAL_STREAM_H |
22 #include FT_INTERNAL_SFNT_H | 22 #include FT_INTERNAL_SFNT_H |
23 #include FT_OUTLINE_H | 23 #include FT_OUTLINE_H |
| 24 #include FT_CFF_DRIVER_H |
24 | 25 |
25 #include "cffobjs.h" | 26 #include "cffobjs.h" |
26 #include "cffload.h" | 27 #include "cffload.h" |
27 #include "cffgload.h" | 28 #include "cffgload.h" |
| 29 #include "cf2ft.h" /* for cf2_decoder_parse_charstrings */ |
28 | 30 |
29 #include "cfferrs.h" | 31 #include "cfferrs.h" |
30 | 32 |
31 | 33 |
32 /*************************************************************************/ | 34 /*************************************************************************/ |
33 /* */ | 35 /* */ |
34 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ | 36 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
35 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ | 37 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
36 /* messages during execution. */ | 38 /* messages during execution. */ |
37 /* */ | 39 /* */ |
38 #undef FT_COMPONENT | 40 #undef FT_COMPONENT |
39 #define FT_COMPONENT trace_cffgload | 41 #define FT_COMPONENT trace_cffgload |
40 | 42 |
41 | 43 |
| 44 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE |
| 45 |
42 typedef enum CFF_Operator_ | 46 typedef enum CFF_Operator_ |
43 { | 47 { |
44 cff_op_unknown = 0, | 48 cff_op_unknown = 0, |
45 | 49 |
46 cff_op_rmoveto, | 50 cff_op_rmoveto, |
47 cff_op_hmoveto, | 51 cff_op_hmoveto, |
48 cff_op_vmoveto, | 52 cff_op_vmoveto, |
49 | 53 |
50 cff_op_rlineto, | 54 cff_op_rlineto, |
51 cff_op_hlineto, | 55 cff_op_hlineto, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 206 |
203 2, /* hsbw */ | 207 2, /* hsbw */ |
204 0, | 208 0, |
205 0, | 209 0, |
206 0, | 210 0, |
207 5, /* seac */ | 211 5, /* seac */ |
208 4, /* sbw */ | 212 4, /* sbw */ |
209 2 /* setcurrentpoint */ | 213 2 /* setcurrentpoint */ |
210 }; | 214 }; |
211 | 215 |
| 216 #endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ |
| 217 |
212 | 218 |
213 /*************************************************************************/ | 219 /*************************************************************************/ |
214 /*************************************************************************/ | 220 /*************************************************************************/ |
215 /*************************************************************************/ | 221 /*************************************************************************/ |
216 /********** *********/ | 222 /********** *********/ |
217 /********** *********/ | 223 /********** *********/ |
218 /********** GENERIC CHARSTRING PARSING *********/ | 224 /********** GENERIC CHARSTRING PARSING *********/ |
219 /********** *********/ | 225 /********** *********/ |
220 /********** *********/ | 226 /********** *********/ |
221 /*************************************************************************/ | 227 /*************************************************************************/ |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 /* this function is used to select the subfont */ | 411 /* this function is used to select the subfont */ |
406 /* and the locals subrs array */ | 412 /* and the locals subrs array */ |
407 FT_LOCAL_DEF( FT_Error ) | 413 FT_LOCAL_DEF( FT_Error ) |
408 cff_decoder_prepare( CFF_Decoder* decoder, | 414 cff_decoder_prepare( CFF_Decoder* decoder, |
409 CFF_Size size, | 415 CFF_Size size, |
410 FT_UInt glyph_index ) | 416 FT_UInt glyph_index ) |
411 { | 417 { |
412 CFF_Builder *builder = &decoder->builder; | 418 CFF_Builder *builder = &decoder->builder; |
413 CFF_Font cff = (CFF_Font)builder->face->extra.data; | 419 CFF_Font cff = (CFF_Font)builder->face->extra.data; |
414 CFF_SubFont sub = &cff->top_font; | 420 CFF_SubFont sub = &cff->top_font; |
415 FT_Error error = CFF_Err_Ok; | 421 FT_Error error = FT_Err_Ok; |
416 | 422 |
417 | 423 |
418 /* manage CID fonts */ | 424 /* manage CID fonts */ |
419 if ( cff->num_subfonts ) | 425 if ( cff->num_subfonts ) |
420 { | 426 { |
421 FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index ); | 427 FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index ); |
422 | 428 |
423 | 429 |
424 if ( fd_index >= cff->num_subfonts ) | 430 if ( fd_index >= cff->num_subfonts ) |
425 { | 431 { |
426 FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" )); | 432 FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" )); |
427 error = CFF_Err_Invalid_File_Format; | 433 error = FT_THROW( Invalid_File_Format ); |
428 goto Exit; | 434 goto Exit; |
429 } | 435 } |
430 | 436 |
431 FT_TRACE3(( "glyph index %d (subfont %d):\n", glyph_index, fd_index )); | 437 FT_TRACE3(( "glyph index %d (subfont %d):\n", glyph_index, fd_index )); |
432 | 438 |
433 sub = cff->subfonts[fd_index]; | 439 sub = cff->subfonts[fd_index]; |
434 | 440 |
435 if ( builder->hints_funcs && size ) | 441 if ( builder->hints_funcs && size ) |
436 { | 442 { |
437 CFF_Internal internal = (CFF_Internal)size->root.internal; | 443 CFF_Internal internal = (CFF_Internal)size->root.internal; |
(...skipping 10 matching lines...) Expand all Loading... |
448 | 454 |
449 decoder->num_locals = sub->local_subrs_index.count; | 455 decoder->num_locals = sub->local_subrs_index.count; |
450 decoder->locals = sub->local_subrs; | 456 decoder->locals = sub->local_subrs; |
451 decoder->locals_bias = cff_compute_bias( | 457 decoder->locals_bias = cff_compute_bias( |
452 decoder->cff->top_font.font_dict.charstring_type, | 458 decoder->cff->top_font.font_dict.charstring_type, |
453 decoder->num_locals ); | 459 decoder->num_locals ); |
454 | 460 |
455 decoder->glyph_width = sub->private_dict.default_width; | 461 decoder->glyph_width = sub->private_dict.default_width; |
456 decoder->nominal_width = sub->private_dict.nominal_width; | 462 decoder->nominal_width = sub->private_dict.nominal_width; |
457 | 463 |
| 464 decoder->current_subfont = sub; /* for Adobe's CFF handler */ |
| 465 |
458 Exit: | 466 Exit: |
459 return error; | 467 return error; |
460 } | 468 } |
461 | 469 |
462 | 470 |
463 /* check that there is enough space for `count' more points */ | 471 /* check that there is enough space for `count' more points */ |
464 static FT_Error | 472 FT_LOCAL_DEF( FT_Error ) |
465 check_points( CFF_Builder* builder, | 473 cff_check_points( CFF_Builder* builder, |
466 FT_Int count ) | 474 FT_Int count ) |
467 { | 475 { |
468 return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 ); | 476 return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 ); |
469 } | 477 } |
470 | 478 |
471 | 479 |
472 /* add a new point, do not check space */ | 480 /* add a new point, do not check space */ |
473 static void | 481 FT_LOCAL_DEF( void ) |
474 cff_builder_add_point( CFF_Builder* builder, | 482 cff_builder_add_point( CFF_Builder* builder, |
475 FT_Pos x, | 483 FT_Pos x, |
476 FT_Pos y, | 484 FT_Pos y, |
477 FT_Byte flag ) | 485 FT_Byte flag ) |
478 { | 486 { |
479 FT_Outline* outline = builder->current; | 487 FT_Outline* outline = builder->current; |
480 | 488 |
481 | 489 |
482 if ( builder->load_points ) | 490 if ( builder->load_points ) |
483 { | 491 { |
484 FT_Vector* point = outline->points + outline->n_points; | 492 FT_Vector* point = outline->points + outline->n_points; |
485 FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points; | 493 FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points; |
486 | 494 |
| 495 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE |
| 496 CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face ); |
487 | 497 |
488 point->x = x >> 16; | 498 |
489 point->y = y >> 16; | 499 if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE ) |
| 500 { |
| 501 point->x = x >> 16; |
| 502 point->y = y >> 16; |
| 503 } |
| 504 else |
| 505 #endif |
| 506 { |
| 507 /* cf2_decoder_parse_charstrings uses 16.16 coordinates */ |
| 508 point->x = x >> 10; |
| 509 point->y = y >> 10; |
| 510 } |
490 *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC ); | 511 *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC ); |
491 } | 512 } |
492 | 513 |
493 outline->n_points++; | 514 outline->n_points++; |
494 } | 515 } |
495 | 516 |
496 | 517 |
497 /* check space for a new on-curve point, then add it */ | 518 /* check space for a new on-curve point, then add it */ |
498 static FT_Error | 519 FT_LOCAL_DEF( FT_Error ) |
499 cff_builder_add_point1( CFF_Builder* builder, | 520 cff_builder_add_point1( CFF_Builder* builder, |
500 FT_Pos x, | 521 FT_Pos x, |
501 FT_Pos y ) | 522 FT_Pos y ) |
502 { | 523 { |
503 FT_Error error; | 524 FT_Error error; |
504 | 525 |
505 | 526 |
506 error = check_points( builder, 1 ); | 527 error = cff_check_points( builder, 1 ); |
507 if ( !error ) | 528 if ( !error ) |
508 cff_builder_add_point( builder, x, y, 1 ); | 529 cff_builder_add_point( builder, x, y, 1 ); |
509 | 530 |
510 return error; | 531 return error; |
511 } | 532 } |
512 | 533 |
513 | 534 |
514 /* check space for a new contour, then add it */ | 535 /* check space for a new contour, then add it */ |
515 static FT_Error | 536 static FT_Error |
516 cff_builder_add_contour( CFF_Builder* builder ) | 537 cff_builder_add_contour( CFF_Builder* builder ) |
517 { | 538 { |
518 FT_Outline* outline = builder->current; | 539 FT_Outline* outline = builder->current; |
519 FT_Error error; | 540 FT_Error error; |
520 | 541 |
521 | 542 |
522 if ( !builder->load_points ) | 543 if ( !builder->load_points ) |
523 { | 544 { |
524 outline->n_contours++; | 545 outline->n_contours++; |
525 return CFF_Err_Ok; | 546 return FT_Err_Ok; |
526 } | 547 } |
527 | 548 |
528 error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 ); | 549 error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 ); |
529 if ( !error ) | 550 if ( !error ) |
530 { | 551 { |
531 if ( outline->n_contours > 0 ) | 552 if ( outline->n_contours > 0 ) |
532 outline->contours[outline->n_contours - 1] = | 553 outline->contours[outline->n_contours - 1] = |
533 (short)( outline->n_points - 1 ); | 554 (short)( outline->n_points - 1 ); |
534 | 555 |
535 outline->n_contours++; | 556 outline->n_contours++; |
536 } | 557 } |
537 | 558 |
538 return error; | 559 return error; |
539 } | 560 } |
540 | 561 |
541 | 562 |
542 /* if a path was begun, add its first on-curve point */ | 563 /* if a path was begun, add its first on-curve point */ |
543 static FT_Error | 564 FT_LOCAL_DEF( FT_Error ) |
544 cff_builder_start_point( CFF_Builder* builder, | 565 cff_builder_start_point( CFF_Builder* builder, |
545 FT_Pos x, | 566 FT_Pos x, |
546 FT_Pos y ) | 567 FT_Pos y ) |
547 { | 568 { |
548 FT_Error error = CFF_Err_Ok; | 569 FT_Error error = FT_Err_Ok; |
549 | 570 |
550 | 571 |
551 /* test whether we are building a new contour */ | 572 /* test whether we are building a new contour */ |
552 if ( !builder->path_begun ) | 573 if ( !builder->path_begun ) |
553 { | 574 { |
554 builder->path_begun = 1; | 575 builder->path_begun = 1; |
555 error = cff_builder_add_contour( builder ); | 576 error = cff_builder_add_contour( builder ); |
556 if ( !error ) | 577 if ( !error ) |
557 error = cff_builder_add_point1( builder, x, y ); | 578 error = cff_builder_add_point1( builder, x, y ); |
558 } | 579 } |
559 | 580 |
560 return error; | 581 return error; |
561 } | 582 } |
562 | 583 |
563 | 584 |
564 /* close the current contour */ | 585 /* close the current contour */ |
565 static void | 586 FT_LOCAL_DEF( void ) |
566 cff_builder_close_contour( CFF_Builder* builder ) | 587 cff_builder_close_contour( CFF_Builder* builder ) |
567 { | 588 { |
568 FT_Outline* outline = builder->current; | 589 FT_Outline* outline = builder->current; |
569 FT_Int first; | 590 FT_Int first; |
570 | 591 |
571 | 592 |
572 if ( !outline ) | 593 if ( !outline ) |
573 return; | 594 return; |
574 | 595 |
575 first = outline->n_contours <= 1 | 596 first = outline->n_contours <= 1 |
(...skipping 24 matching lines...) Expand all Loading... |
600 outline->n_contours--; | 621 outline->n_contours--; |
601 outline->n_points--; | 622 outline->n_points--; |
602 } | 623 } |
603 else | 624 else |
604 outline->contours[outline->n_contours - 1] = | 625 outline->contours[outline->n_contours - 1] = |
605 (short)( outline->n_points - 1 ); | 626 (short)( outline->n_points - 1 ); |
606 } | 627 } |
607 } | 628 } |
608 | 629 |
609 | 630 |
610 static FT_Int | 631 FT_LOCAL_DEF( FT_Int ) |
611 cff_lookup_glyph_by_stdcharcode( CFF_Font cff, | 632 cff_lookup_glyph_by_stdcharcode( CFF_Font cff, |
612 FT_Int charcode ) | 633 FT_Int charcode ) |
613 { | 634 { |
614 FT_UInt n; | 635 FT_UInt n; |
615 FT_UShort glyph_sid; | 636 FT_UShort glyph_sid; |
616 | 637 |
617 | 638 |
618 /* CID-keyed fonts don't have glyph names */ | 639 /* CID-keyed fonts don't have glyph names */ |
619 if ( !cff->charset.sids ) | 640 if ( !cff->charset.sids ) |
620 return -1; | 641 return -1; |
621 | 642 |
622 /* check range of standard char code */ | 643 /* check range of standard char code */ |
623 if ( charcode < 0 || charcode > 255 ) | 644 if ( charcode < 0 || charcode > 255 ) |
624 return -1; | 645 return -1; |
625 | 646 |
626 /* Get code to SID mapping from `cff_standard_encoding'. */ | 647 /* Get code to SID mapping from `cff_standard_encoding'. */ |
627 glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode ); | 648 glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode ); |
628 | 649 |
629 for ( n = 0; n < cff->num_glyphs; n++ ) | 650 for ( n = 0; n < cff->num_glyphs; n++ ) |
630 { | 651 { |
631 if ( cff->charset.sids[n] == glyph_sid ) | 652 if ( cff->charset.sids[n] == glyph_sid ) |
632 return n; | 653 return n; |
633 } | 654 } |
634 | 655 |
635 return -1; | 656 return -1; |
636 } | 657 } |
637 | 658 |
638 | 659 |
639 static FT_Error | 660 FT_LOCAL_DEF( FT_Error ) |
640 cff_get_glyph_data( TT_Face face, | 661 cff_get_glyph_data( TT_Face face, |
641 FT_UInt glyph_index, | 662 FT_UInt glyph_index, |
642 FT_Byte** pointer, | 663 FT_Byte** pointer, |
643 FT_ULong* length ) | 664 FT_ULong* length ) |
644 { | 665 { |
645 #ifdef FT_CONFIG_OPTION_INCREMENTAL | 666 #ifdef FT_CONFIG_OPTION_INCREMENTAL |
646 /* For incremental fonts get the character data using the */ | 667 /* For incremental fonts get the character data using the */ |
647 /* callback function. */ | 668 /* callback function. */ |
648 if ( face->root.internal->incremental_interface ) | 669 if ( face->root.internal->incremental_interface ) |
649 { | 670 { |
(...skipping 15 matching lines...) Expand all Loading... |
665 { | 686 { |
666 CFF_Font cff = (CFF_Font)(face->extra.data); | 687 CFF_Font cff = (CFF_Font)(face->extra.data); |
667 | 688 |
668 | 689 |
669 return cff_index_access_element( &cff->charstrings_index, glyph_index, | 690 return cff_index_access_element( &cff->charstrings_index, glyph_index, |
670 pointer, length ); | 691 pointer, length ); |
671 } | 692 } |
672 } | 693 } |
673 | 694 |
674 | 695 |
675 static void | 696 FT_LOCAL_DEF( void ) |
676 cff_free_glyph_data( TT_Face face, | 697 cff_free_glyph_data( TT_Face face, |
677 FT_Byte** pointer, | 698 FT_Byte** pointer, |
678 FT_ULong length ) | 699 FT_ULong length ) |
679 { | 700 { |
680 #ifndef FT_CONFIG_OPTION_INCREMENTAL | 701 #ifndef FT_CONFIG_OPTION_INCREMENTAL |
681 FT_UNUSED( length ); | 702 FT_UNUSED( length ); |
682 #endif | 703 #endif |
683 | 704 |
684 #ifdef FT_CONFIG_OPTION_INCREMENTAL | 705 #ifdef FT_CONFIG_OPTION_INCREMENTAL |
685 /* For incremental fonts get the character data using the */ | 706 /* For incremental fonts get the character data using the */ |
(...skipping 14 matching lines...) Expand all Loading... |
700 | 721 |
701 { | 722 { |
702 CFF_Font cff = (CFF_Font)(face->extra.data); | 723 CFF_Font cff = (CFF_Font)(face->extra.data); |
703 | 724 |
704 | 725 |
705 cff_index_forget_element( &cff->charstrings_index, pointer ); | 726 cff_index_forget_element( &cff->charstrings_index, pointer ); |
706 } | 727 } |
707 } | 728 } |
708 | 729 |
709 | 730 |
| 731 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE |
| 732 |
710 static FT_Error | 733 static FT_Error |
711 cff_operator_seac( CFF_Decoder* decoder, | 734 cff_operator_seac( CFF_Decoder* decoder, |
712 FT_Pos asb, | 735 FT_Pos asb, |
713 FT_Pos adx, | 736 FT_Pos adx, |
714 FT_Pos ady, | 737 FT_Pos ady, |
715 FT_Int bchar, | 738 FT_Int bchar, |
716 FT_Int achar ) | 739 FT_Int achar ) |
717 { | 740 { |
718 FT_Error error; | 741 FT_Error error; |
719 CFF_Builder* builder = &decoder->builder; | 742 CFF_Builder* builder = &decoder->builder; |
720 FT_Int bchar_index, achar_index; | 743 FT_Int bchar_index, achar_index; |
721 TT_Face face = decoder->builder.face; | 744 TT_Face face = decoder->builder.face; |
722 FT_Vector left_bearing, advance; | 745 FT_Vector left_bearing, advance; |
723 FT_Byte* charstring; | 746 FT_Byte* charstring; |
724 FT_ULong charstring_len; | 747 FT_ULong charstring_len; |
725 FT_Pos glyph_width; | 748 FT_Pos glyph_width; |
726 | 749 |
727 | 750 |
728 if ( decoder->seac ) | 751 if ( decoder->seac ) |
729 { | 752 { |
730 FT_ERROR(( "cff_operator_seac: invalid nested seac\n" )); | 753 FT_ERROR(( "cff_operator_seac: invalid nested seac\n" )); |
731 return CFF_Err_Syntax_Error; | 754 return FT_THROW( Syntax_Error ); |
732 } | 755 } |
733 | 756 |
734 adx += decoder->builder.left_bearing.x; | 757 adx += decoder->builder.left_bearing.x; |
735 ady += decoder->builder.left_bearing.y; | 758 ady += decoder->builder.left_bearing.y; |
736 | 759 |
737 #ifdef FT_CONFIG_OPTION_INCREMENTAL | 760 #ifdef FT_CONFIG_OPTION_INCREMENTAL |
738 /* Incremental fonts don't necessarily have valid charsets. */ | 761 /* Incremental fonts don't necessarily have valid charsets. */ |
739 /* They use the character code, not the glyph index, in this case. */ | 762 /* They use the character code, not the glyph index, in this case. */ |
740 if ( face->root.internal->incremental_interface ) | 763 if ( face->root.internal->incremental_interface ) |
741 { | 764 { |
742 bchar_index = bchar; | 765 bchar_index = bchar; |
743 achar_index = achar; | 766 achar_index = achar; |
744 } | 767 } |
745 else | 768 else |
746 #endif /* FT_CONFIG_OPTION_INCREMENTAL */ | 769 #endif /* FT_CONFIG_OPTION_INCREMENTAL */ |
747 { | 770 { |
748 CFF_Font cff = (CFF_Font)(face->extra.data); | 771 CFF_Font cff = (CFF_Font)(face->extra.data); |
749 | 772 |
750 | 773 |
751 bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar ); | 774 bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar ); |
752 achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar ); | 775 achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar ); |
753 } | 776 } |
754 | 777 |
755 if ( bchar_index < 0 || achar_index < 0 ) | 778 if ( bchar_index < 0 || achar_index < 0 ) |
756 { | 779 { |
757 FT_ERROR(( "cff_operator_seac:" | 780 FT_ERROR(( "cff_operator_seac:" |
758 " invalid seac character code arguments\n" )); | 781 " invalid seac character code arguments\n" )); |
759 return CFF_Err_Syntax_Error; | 782 return FT_THROW( Syntax_Error ); |
760 } | 783 } |
761 | 784 |
762 /* If we are trying to load a composite glyph, do not load the */ | 785 /* If we are trying to load a composite glyph, do not load the */ |
763 /* accent character and return the array of subglyphs. */ | 786 /* accent character and return the array of subglyphs. */ |
764 if ( builder->no_recurse ) | 787 if ( builder->no_recurse ) |
765 { | 788 { |
766 FT_GlyphSlot glyph = (FT_GlyphSlot)builder->glyph; | 789 FT_GlyphSlot glyph = (FT_GlyphSlot)builder->glyph; |
767 FT_GlyphLoader loader = glyph->internal->loader; | 790 FT_GlyphLoader loader = glyph->internal->loader; |
768 FT_SubGlyph subg; | 791 FT_SubGlyph subg; |
769 | 792 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 stack = decoder->top; | 941 stack = decoder->top; |
919 | 942 |
920 hinter = (T2_Hints_Funcs)builder->hints_funcs; | 943 hinter = (T2_Hints_Funcs)builder->hints_funcs; |
921 | 944 |
922 builder->path_begun = 0; | 945 builder->path_begun = 0; |
923 | 946 |
924 zone->base = charstring_base; | 947 zone->base = charstring_base; |
925 limit = zone->limit = charstring_base + charstring_len; | 948 limit = zone->limit = charstring_base + charstring_len; |
926 ip = zone->cursor = zone->base; | 949 ip = zone->cursor = zone->base; |
927 | 950 |
928 error = CFF_Err_Ok; | 951 error = FT_Err_Ok; |
929 | 952 |
930 x = builder->pos_x; | 953 x = builder->pos_x; |
931 y = builder->pos_y; | 954 y = builder->pos_y; |
932 | 955 |
933 /* begin hints recording session, if any */ | 956 /* begin hints recording session, if any */ |
934 if ( hinter ) | 957 if ( hinter ) |
935 hinter->open( hinter->hints ); | 958 hinter->open( hinter->hints ); |
936 | 959 |
937 /* now execute loop */ | 960 /* now execute loop */ |
938 while ( ip < limit ) | 961 while ( ip < limit ) |
939 { | 962 { |
940 CFF_Operator op; | 963 CFF_Operator op; |
941 FT_Byte v; | 964 FT_Byte v; |
942 | 965 |
943 | 966 |
944 /********************************************************************/ | 967 /********************************************************************/ |
945 /* */ | 968 /* */ |
946 /* Decode operator or operand */ | 969 /* Decode operator or operand */ |
947 /* */ | 970 /* */ |
948 v = *ip++; | 971 v = *ip++; |
949 if ( v >= 32 || v == 28 ) | 972 if ( v >= 32 || v == 28 ) |
950 { | 973 { |
951 FT_Int shift = 16; | 974 FT_Int shift = 16; |
952 FT_Int32 val; | 975 FT_Int32 val; |
953 | 976 |
954 | 977 |
955 /* this is an operand, push it on the stack */ | 978 /* this is an operand, push it on the stack */ |
| 979 |
| 980 /* if we use shifts, all computations are done with unsigned */ |
| 981 /* values; the conversion to a signed value is the last step */ |
956 if ( v == 28 ) | 982 if ( v == 28 ) |
957 { | 983 { |
958 if ( ip + 1 >= limit ) | 984 if ( ip + 1 >= limit ) |
959 goto Syntax_Error; | 985 goto Syntax_Error; |
960 val = (FT_Short)( ( (FT_Short)ip[0] << 8 ) | ip[1] ); | 986 val = (FT_Short)( ( (FT_UShort)ip[0] << 8 ) | ip[1] ); |
961 ip += 2; | 987 ip += 2; |
962 } | 988 } |
963 else if ( v < 247 ) | 989 else if ( v < 247 ) |
964 val = (FT_Int32)v - 139; | 990 val = (FT_Int32)v - 139; |
965 else if ( v < 251 ) | 991 else if ( v < 251 ) |
966 { | 992 { |
967 if ( ip >= limit ) | 993 if ( ip >= limit ) |
968 goto Syntax_Error; | 994 goto Syntax_Error; |
969 val = ( (FT_Int32)v - 247 ) * 256 + *ip++ + 108; | 995 val = ( (FT_Int32)v - 247 ) * 256 + *ip++ + 108; |
970 } | 996 } |
971 else if ( v < 255 ) | 997 else if ( v < 255 ) |
972 { | 998 { |
973 if ( ip >= limit ) | 999 if ( ip >= limit ) |
974 goto Syntax_Error; | 1000 goto Syntax_Error; |
975 val = -( (FT_Int32)v - 251 ) * 256 - *ip++ - 108; | 1001 val = -( (FT_Int32)v - 251 ) * 256 - *ip++ - 108; |
976 } | 1002 } |
977 else | 1003 else |
978 { | 1004 { |
979 if ( ip + 3 >= limit ) | 1005 if ( ip + 3 >= limit ) |
980 goto Syntax_Error; | 1006 goto Syntax_Error; |
981 val = ( (FT_Int32)ip[0] << 24 ) | | 1007 val = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) | |
982 ( (FT_Int32)ip[1] << 16 ) | | 1008 ( (FT_UInt32)ip[1] << 16 ) | |
983 ( (FT_Int32)ip[2] << 8 ) | | 1009 ( (FT_UInt32)ip[2] << 8 ) | |
984 ip[3]; | 1010 (FT_UInt32)ip[3] ); |
985 ip += 4; | 1011 ip += 4; |
986 if ( charstring_type == 2 ) | 1012 if ( charstring_type == 2 ) |
987 shift = 0; | 1013 shift = 0; |
988 } | 1014 } |
989 if ( decoder->top - stack >= CFF_MAX_OPERANDS ) | 1015 if ( decoder->top - stack >= CFF_MAX_OPERANDS ) |
990 goto Stack_Overflow; | 1016 goto Stack_Overflow; |
991 | 1017 |
992 val <<= shift; | 1018 val = (FT_Int32)( (FT_UInt32)val << shift ); |
993 *decoder->top++ = val; | 1019 *decoder->top++ = val; |
994 | 1020 |
995 #ifdef FT_DEBUG_LEVEL_TRACE | 1021 #ifdef FT_DEBUG_LEVEL_TRACE |
996 if ( !( val & 0xFFFFL ) ) | 1022 if ( !( val & 0xFFFFL ) ) |
997 FT_TRACE4(( " %ld", (FT_Int32)( val >> 16 ) )); | 1023 FT_TRACE4(( " %hd", (FT_Short)( (FT_UInt32)val >> 16 ) )); |
998 else | 1024 else |
999 FT_TRACE4(( " %.2f", val / 65536.0 )); | 1025 FT_TRACE4(( " %.2f", val / 65536.0 )); |
1000 #endif | 1026 #endif |
1001 | 1027 |
1002 } | 1028 } |
1003 else | 1029 else |
1004 { | 1030 { |
1005 /* The specification says that normally arguments are to be taken */ | 1031 /* The specification says that normally arguments are to be taken */ |
1006 /* from the bottom of the stack. However, this seems not to be */ | 1032 /* from the bottom of the stack. However, this seems not to be */ |
1007 /* correct, at least for Acroread 7.0.8 on GNU/Linux: It pops the */ | 1033 /* correct, at least for Acroread 7.0.8 on GNU/Linux: It pops the */ |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 | 1430 |
1405 cff_builder_close_contour( builder ); | 1431 cff_builder_close_contour( builder ); |
1406 builder->path_begun = 0; | 1432 builder->path_begun = 0; |
1407 x += args[-1]; | 1433 x += args[-1]; |
1408 args = stack; | 1434 args = stack; |
1409 break; | 1435 break; |
1410 | 1436 |
1411 case cff_op_rlineto: | 1437 case cff_op_rlineto: |
1412 FT_TRACE4(( " rlineto\n" )); | 1438 FT_TRACE4(( " rlineto\n" )); |
1413 | 1439 |
1414 if ( cff_builder_start_point ( builder, x, y ) || | 1440 if ( cff_builder_start_point( builder, x, y ) || |
1415 check_points( builder, num_args / 2 ) ) | 1441 cff_check_points( builder, num_args / 2 ) ) |
1416 goto Fail; | 1442 goto Fail; |
1417 | 1443 |
1418 if ( num_args < 2 ) | 1444 if ( num_args < 2 ) |
1419 goto Stack_Underflow; | 1445 goto Stack_Underflow; |
1420 | 1446 |
1421 args -= num_args & ~1; | 1447 args -= num_args & ~1; |
1422 while ( args < decoder->top ) | 1448 while ( args < decoder->top ) |
1423 { | 1449 { |
1424 x += args[0]; | 1450 x += args[0]; |
1425 y += args[1]; | 1451 y += args[1]; |
(...skipping 13 matching lines...) Expand all Loading... |
1439 : " vlineto\n" )); | 1465 : " vlineto\n" )); |
1440 | 1466 |
1441 if ( num_args < 0 ) | 1467 if ( num_args < 0 ) |
1442 goto Stack_Underflow; | 1468 goto Stack_Underflow; |
1443 | 1469 |
1444 /* there exist subsetted fonts (found in PDFs) */ | 1470 /* there exist subsetted fonts (found in PDFs) */ |
1445 /* which call `hlineto' without arguments */ | 1471 /* which call `hlineto' without arguments */ |
1446 if ( num_args == 0 ) | 1472 if ( num_args == 0 ) |
1447 break; | 1473 break; |
1448 | 1474 |
1449 if ( cff_builder_start_point ( builder, x, y ) || | 1475 if ( cff_builder_start_point( builder, x, y ) || |
1450 check_points( builder, num_args ) ) | 1476 cff_check_points( builder, num_args ) ) |
1451 goto Fail; | 1477 goto Fail; |
1452 | 1478 |
1453 args = stack; | 1479 args = stack; |
1454 while ( args < decoder->top ) | 1480 while ( args < decoder->top ) |
1455 { | 1481 { |
1456 if ( phase ) | 1482 if ( phase ) |
1457 x += args[0]; | 1483 x += args[0]; |
1458 else | 1484 else |
1459 y += args[0]; | 1485 y += args[0]; |
1460 | 1486 |
(...skipping 12 matching lines...) Expand all Loading... |
1473 FT_Int nargs; | 1499 FT_Int nargs; |
1474 | 1500 |
1475 | 1501 |
1476 FT_TRACE4(( " rrcurveto\n" )); | 1502 FT_TRACE4(( " rrcurveto\n" )); |
1477 | 1503 |
1478 if ( num_args < 6 ) | 1504 if ( num_args < 6 ) |
1479 goto Stack_Underflow; | 1505 goto Stack_Underflow; |
1480 | 1506 |
1481 nargs = num_args - num_args % 6; | 1507 nargs = num_args - num_args % 6; |
1482 | 1508 |
1483 if ( cff_builder_start_point ( builder, x, y ) || | 1509 if ( cff_builder_start_point( builder, x, y ) || |
1484 check_points( builder, nargs / 2 ) ) | 1510 cff_check_points( builder, nargs / 2 ) ) |
1485 goto Fail; | 1511 goto Fail; |
1486 | 1512 |
1487 args -= nargs; | 1513 args -= nargs; |
1488 while ( args < decoder->top ) | 1514 while ( args < decoder->top ) |
1489 { | 1515 { |
1490 x += args[0]; | 1516 x += args[0]; |
1491 y += args[1]; | 1517 y += args[1]; |
1492 cff_builder_add_point( builder, x, y, 0 ); | 1518 cff_builder_add_point( builder, x, y, 0 ); |
1493 x += args[2]; | 1519 x += args[2]; |
1494 y += args[3]; | 1520 y += args[3]; |
(...skipping 27 matching lines...) Expand all Loading... |
1522 | 1548 |
1523 args -= nargs; | 1549 args -= nargs; |
1524 | 1550 |
1525 if ( nargs & 1 ) | 1551 if ( nargs & 1 ) |
1526 { | 1552 { |
1527 x += args[0]; | 1553 x += args[0]; |
1528 args++; | 1554 args++; |
1529 nargs--; | 1555 nargs--; |
1530 } | 1556 } |
1531 | 1557 |
1532 if ( check_points( builder, 3 * ( nargs / 4 ) ) ) | 1558 if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) ) |
1533 goto Fail; | 1559 goto Fail; |
1534 | 1560 |
1535 while ( args < decoder->top ) | 1561 while ( args < decoder->top ) |
1536 { | 1562 { |
1537 y += args[0]; | 1563 y += args[0]; |
1538 cff_builder_add_point( builder, x, y, 0 ); | 1564 cff_builder_add_point( builder, x, y, 0 ); |
1539 x += args[1]; | 1565 x += args[1]; |
1540 y += args[2]; | 1566 y += args[2]; |
1541 cff_builder_add_point( builder, x, y, 0 ); | 1567 cff_builder_add_point( builder, x, y, 0 ); |
1542 y += args[3]; | 1568 y += args[3]; |
(...skipping 23 matching lines...) Expand all Loading... |
1566 goto Fail; | 1592 goto Fail; |
1567 | 1593 |
1568 args -= nargs; | 1594 args -= nargs; |
1569 if ( nargs & 1 ) | 1595 if ( nargs & 1 ) |
1570 { | 1596 { |
1571 y += args[0]; | 1597 y += args[0]; |
1572 args++; | 1598 args++; |
1573 nargs--; | 1599 nargs--; |
1574 } | 1600 } |
1575 | 1601 |
1576 if ( check_points( builder, 3 * ( nargs / 4 ) ) ) | 1602 if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) ) |
1577 goto Fail; | 1603 goto Fail; |
1578 | 1604 |
1579 while ( args < decoder->top ) | 1605 while ( args < decoder->top ) |
1580 { | 1606 { |
1581 x += args[0]; | 1607 x += args[0]; |
1582 cff_builder_add_point( builder, x, y, 0 ); | 1608 cff_builder_add_point( builder, x, y, 0 ); |
1583 x += args[1]; | 1609 x += args[1]; |
1584 y += args[2]; | 1610 y += args[2]; |
1585 cff_builder_add_point( builder, x, y, 0 ); | 1611 cff_builder_add_point( builder, x, y, 0 ); |
1586 x += args[3]; | 1612 x += args[3]; |
(...skipping 19 matching lines...) Expand all Loading... |
1606 | 1632 |
1607 if ( num_args < 4 ) | 1633 if ( num_args < 4 ) |
1608 goto Stack_Underflow; | 1634 goto Stack_Underflow; |
1609 | 1635 |
1610 /* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */ | 1636 /* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */ |
1611 /* we enforce it by clearing the second bit */ | 1637 /* we enforce it by clearing the second bit */ |
1612 | 1638 |
1613 nargs = num_args & ~2; | 1639 nargs = num_args & ~2; |
1614 | 1640 |
1615 args -= nargs; | 1641 args -= nargs; |
1616 if ( check_points( builder, ( nargs / 4 ) * 3 ) ) | 1642 if ( cff_check_points( builder, ( nargs / 4 ) * 3 ) ) |
1617 goto Stack_Underflow; | 1643 goto Stack_Underflow; |
1618 | 1644 |
1619 phase = ( op == cff_op_hvcurveto ); | 1645 phase = ( op == cff_op_hvcurveto ); |
1620 | 1646 |
1621 while ( nargs >= 4 ) | 1647 while ( nargs >= 4 ) |
1622 { | 1648 { |
1623 nargs -= 4; | 1649 nargs -= 4; |
1624 if ( phase ) | 1650 if ( phase ) |
1625 { | 1651 { |
1626 x += args[0]; | 1652 x += args[0]; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 | 1685 |
1660 | 1686 |
1661 FT_TRACE4(( " rlinecurve\n" )); | 1687 FT_TRACE4(( " rlinecurve\n" )); |
1662 | 1688 |
1663 if ( num_args < 8 ) | 1689 if ( num_args < 8 ) |
1664 goto Stack_Underflow; | 1690 goto Stack_Underflow; |
1665 | 1691 |
1666 nargs = num_args & ~1; | 1692 nargs = num_args & ~1; |
1667 num_lines = ( nargs - 6 ) / 2; | 1693 num_lines = ( nargs - 6 ) / 2; |
1668 | 1694 |
1669 if ( cff_builder_start_point( builder, x, y ) || | 1695 if ( cff_builder_start_point( builder, x, y ) || |
1670 check_points( builder, num_lines + 3 ) ) | 1696 cff_check_points( builder, num_lines + 3 ) ) |
1671 goto Fail; | 1697 goto Fail; |
1672 | 1698 |
1673 args -= nargs; | 1699 args -= nargs; |
1674 | 1700 |
1675 /* first, add the line segments */ | 1701 /* first, add the line segments */ |
1676 while ( num_lines > 0 ) | 1702 while ( num_lines > 0 ) |
1677 { | 1703 { |
1678 x += args[0]; | 1704 x += args[0]; |
1679 y += args[1]; | 1705 y += args[1]; |
1680 cff_builder_add_point( builder, x, y, 1 ); | 1706 cff_builder_add_point( builder, x, y, 1 ); |
(...skipping 23 matching lines...) Expand all Loading... |
1704 | 1730 |
1705 FT_TRACE4(( " rcurveline\n" )); | 1731 FT_TRACE4(( " rcurveline\n" )); |
1706 | 1732 |
1707 if ( num_args < 8 ) | 1733 if ( num_args < 8 ) |
1708 goto Stack_Underflow; | 1734 goto Stack_Underflow; |
1709 | 1735 |
1710 nargs = num_args - 2; | 1736 nargs = num_args - 2; |
1711 nargs = nargs - nargs % 6 + 2; | 1737 nargs = nargs - nargs % 6 + 2; |
1712 num_curves = ( nargs - 2 ) / 6; | 1738 num_curves = ( nargs - 2 ) / 6; |
1713 | 1739 |
1714 if ( cff_builder_start_point ( builder, x, y ) || | 1740 if ( cff_builder_start_point( builder, x, y ) || |
1715 check_points( builder, num_curves * 3 + 2 ) ) | 1741 cff_check_points( builder, num_curves * 3 + 2 ) ) |
1716 goto Fail; | 1742 goto Fail; |
1717 | 1743 |
1718 args -= nargs; | 1744 args -= nargs; |
1719 | 1745 |
1720 /* first, add the curves */ | 1746 /* first, add the curves */ |
1721 while ( num_curves > 0 ) | 1747 while ( num_curves > 0 ) |
1722 { | 1748 { |
1723 x += args[0]; | 1749 x += args[0]; |
1724 y += args[1]; | 1750 y += args[1]; |
1725 cff_builder_add_point( builder, x, y, 0 ); | 1751 cff_builder_add_point( builder, x, y, 0 ); |
(...skipping 19 matching lines...) Expand all Loading... |
1745 { | 1771 { |
1746 FT_Pos start_y; | 1772 FT_Pos start_y; |
1747 | 1773 |
1748 | 1774 |
1749 FT_TRACE4(( " hflex1\n" )); | 1775 FT_TRACE4(( " hflex1\n" )); |
1750 | 1776 |
1751 /* adding five more points: 4 control points, 1 on-curve point */ | 1777 /* adding five more points: 4 control points, 1 on-curve point */ |
1752 /* -- make sure we have enough space for the start point if it */ | 1778 /* -- make sure we have enough space for the start point if it */ |
1753 /* needs to be added */ | 1779 /* needs to be added */ |
1754 if ( cff_builder_start_point( builder, x, y ) || | 1780 if ( cff_builder_start_point( builder, x, y ) || |
1755 check_points( builder, 6 ) ) | 1781 cff_check_points( builder, 6 ) ) |
1756 goto Fail; | 1782 goto Fail; |
1757 | 1783 |
1758 /* record the starting point's y position for later use */ | 1784 /* record the starting point's y position for later use */ |
1759 start_y = y; | 1785 start_y = y; |
1760 | 1786 |
1761 /* first control point */ | 1787 /* first control point */ |
1762 x += args[0]; | 1788 x += args[0]; |
1763 y += args[1]; | 1789 y += args[1]; |
1764 cff_builder_add_point( builder, x, y, 0 ); | 1790 cff_builder_add_point( builder, x, y, 0 ); |
1765 | 1791 |
(...skipping 28 matching lines...) Expand all Loading... |
1794 | 1820 |
1795 case cff_op_hflex: | 1821 case cff_op_hflex: |
1796 { | 1822 { |
1797 FT_Pos start_y; | 1823 FT_Pos start_y; |
1798 | 1824 |
1799 | 1825 |
1800 FT_TRACE4(( " hflex\n" )); | 1826 FT_TRACE4(( " hflex\n" )); |
1801 | 1827 |
1802 /* adding six more points; 4 control points, 2 on-curve points */ | 1828 /* adding six more points; 4 control points, 2 on-curve points */ |
1803 if ( cff_builder_start_point( builder, x, y ) || | 1829 if ( cff_builder_start_point( builder, x, y ) || |
1804 check_points( builder, 6 ) ) | 1830 cff_check_points( builder, 6 ) ) |
1805 goto Fail; | 1831 goto Fail; |
1806 | 1832 |
1807 /* record the starting point's y-position for later use */ | 1833 /* record the starting point's y-position for later use */ |
1808 start_y = y; | 1834 start_y = y; |
1809 | 1835 |
1810 /* first control point */ | 1836 /* first control point */ |
1811 x += args[0]; | 1837 x += args[0]; |
1812 cff_builder_add_point( builder, x, y, 0 ); | 1838 cff_builder_add_point( builder, x, y, 0 ); |
1813 | 1839 |
1814 /* second control point */ | 1840 /* second control point */ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 FT_Fixed dx = 0, dy = 0; /* used in horizontal/vertical */ | 1873 FT_Fixed dx = 0, dy = 0; /* used in horizontal/vertical */ |
1848 /* algorithm below */ | 1874 /* algorithm below */ |
1849 FT_Int horizontal, count; | 1875 FT_Int horizontal, count; |
1850 FT_Fixed* temp; | 1876 FT_Fixed* temp; |
1851 | 1877 |
1852 | 1878 |
1853 FT_TRACE4(( " flex1\n" )); | 1879 FT_TRACE4(( " flex1\n" )); |
1854 | 1880 |
1855 /* adding six more points; 4 control points, 2 on-curve points */ | 1881 /* adding six more points; 4 control points, 2 on-curve points */ |
1856 if ( cff_builder_start_point( builder, x, y ) || | 1882 if ( cff_builder_start_point( builder, x, y ) || |
1857 check_points( builder, 6 ) ) | 1883 cff_check_points( builder, 6 ) ) |
1858 goto Fail; | 1884 goto Fail; |
1859 | 1885 |
1860 /* record the starting point's x, y position for later use */ | 1886 /* record the starting point's x, y position for later use */ |
1861 start_x = x; | 1887 start_x = x; |
1862 start_y = y; | 1888 start_y = y; |
1863 | 1889 |
1864 /* XXX: figure out whether this is supposed to be a horizontal */ | 1890 /* XXX: figure out whether this is supposed to be a horizontal */ |
1865 /* or vertical flex; the Type 2 specification is vague... */ | 1891 /* or vertical flex; the Type 2 specification is vague... */ |
1866 | 1892 |
1867 temp = args; | 1893 temp = args; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 } | 1936 } |
1911 | 1937 |
1912 case cff_op_flex: | 1938 case cff_op_flex: |
1913 { | 1939 { |
1914 FT_UInt count; | 1940 FT_UInt count; |
1915 | 1941 |
1916 | 1942 |
1917 FT_TRACE4(( " flex\n" )); | 1943 FT_TRACE4(( " flex\n" )); |
1918 | 1944 |
1919 if ( cff_builder_start_point( builder, x, y ) || | 1945 if ( cff_builder_start_point( builder, x, y ) || |
1920 check_points( builder, 6 ) ) | 1946 cff_check_points( builder, 6 ) ) |
1921 goto Fail; | 1947 goto Fail; |
1922 | 1948 |
1923 for ( count = 6; count > 0; count-- ) | 1949 for ( count = 6; count > 0; count-- ) |
1924 { | 1950 { |
1925 x += args[0]; | 1951 x += args[0]; |
1926 y += args[1]; | 1952 y += args[1]; |
1927 cff_builder_add_point( builder, x, y, | 1953 cff_builder_add_point( builder, x, y, |
1928 (FT_Bool)( count == 4 || count == 1 ) ); | 1954 (FT_Bool)( count == 4 || count == 1 ) ); |
1929 args += 2; | 1955 args += 2; |
1930 } | 1956 } |
(...skipping 30 matching lines...) Expand all Loading... |
1961 error = cff_operator_seac( decoder, | 1987 error = cff_operator_seac( decoder, |
1962 0L, args[-4], args[-3], | 1988 0L, args[-4], args[-3], |
1963 (FT_Int)( args[-2] >> 16 ), | 1989 (FT_Int)( args[-2] >> 16 ), |
1964 (FT_Int)( args[-1] >> 16 ) ); | 1990 (FT_Int)( args[-1] >> 16 ) ); |
1965 | 1991 |
1966 decoder->glyph_width = glyph_width; | 1992 decoder->glyph_width = glyph_width; |
1967 } | 1993 } |
1968 else | 1994 else |
1969 { | 1995 { |
1970 if ( !error ) | 1996 if ( !error ) |
1971 error = CFF_Err_Ok; | 1997 error = FT_Err_Ok; |
1972 | 1998 |
1973 cff_builder_close_contour( builder ); | 1999 cff_builder_close_contour( builder ); |
1974 | 2000 |
1975 /* close hints recording session */ | 2001 /* close hints recording session */ |
1976 if ( hinter ) | 2002 if ( hinter ) |
1977 { | 2003 { |
1978 if ( hinter->close( hinter->hints, | 2004 if ( hinter->close( hinter->hints, |
1979 builder->current->n_points ) ) | 2005 builder->current->n_points ) ) |
1980 goto Syntax_Error; | 2006 goto Syntax_Error; |
1981 | 2007 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2463 break; | 2489 break; |
2464 | 2490 |
2465 default: | 2491 default: |
2466 Unimplemented: | 2492 Unimplemented: |
2467 FT_ERROR(( "Unimplemented opcode: %d", ip[-1] )); | 2493 FT_ERROR(( "Unimplemented opcode: %d", ip[-1] )); |
2468 | 2494 |
2469 if ( ip[-1] == 12 ) | 2495 if ( ip[-1] == 12 ) |
2470 FT_ERROR(( " %d", ip[0] )); | 2496 FT_ERROR(( " %d", ip[0] )); |
2471 FT_ERROR(( "\n" )); | 2497 FT_ERROR(( "\n" )); |
2472 | 2498 |
2473 return CFF_Err_Unimplemented_Feature; | 2499 return FT_THROW( Unimplemented_Feature ); |
2474 } | 2500 } |
2475 | 2501 |
2476 decoder->top = args; | 2502 decoder->top = args; |
2477 | 2503 |
2478 if ( decoder->top - stack >= CFF_MAX_OPERANDS ) | 2504 if ( decoder->top - stack >= CFF_MAX_OPERANDS ) |
2479 goto Stack_Overflow; | 2505 goto Stack_Overflow; |
2480 | 2506 |
2481 } /* general operator processing */ | 2507 } /* general operator processing */ |
2482 | 2508 |
2483 } /* while ip < limit */ | 2509 } /* while ip < limit */ |
2484 | 2510 |
2485 FT_TRACE4(( "..end..\n\n" )); | 2511 FT_TRACE4(( "..end..\n\n" )); |
2486 | 2512 |
2487 Fail: | 2513 Fail: |
2488 return error; | 2514 return error; |
2489 | 2515 |
2490 Syntax_Error: | 2516 Syntax_Error: |
2491 FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" )); | 2517 FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" )); |
2492 return CFF_Err_Invalid_File_Format; | 2518 return FT_THROW( Invalid_File_Format ); |
2493 | 2519 |
2494 Stack_Underflow: | 2520 Stack_Underflow: |
2495 FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" )); | 2521 FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" )); |
2496 return CFF_Err_Too_Few_Arguments; | 2522 return FT_THROW( Too_Few_Arguments ); |
2497 | 2523 |
2498 Stack_Overflow: | 2524 Stack_Overflow: |
2499 FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" )); | 2525 FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" )); |
2500 return CFF_Err_Stack_Overflow; | 2526 return FT_THROW( Stack_Overflow ); |
2501 } | 2527 } |
2502 | 2528 |
| 2529 #endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ |
| 2530 |
2503 | 2531 |
2504 /*************************************************************************/ | 2532 /*************************************************************************/ |
2505 /*************************************************************************/ | 2533 /*************************************************************************/ |
2506 /*************************************************************************/ | 2534 /*************************************************************************/ |
2507 /********** *********/ | 2535 /********** *********/ |
2508 /********** *********/ | 2536 /********** *********/ |
2509 /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/ | 2537 /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/ |
2510 /********** *********/ | 2538 /********** *********/ |
2511 /********** The following code is in charge of computing *********/ | 2539 /********** The following code is in charge of computing *********/ |
2512 /********** the maximum advance width of the font. It *********/ | 2540 /********** the maximum advance width of the font. It *********/ |
2513 /********** quickly processes each glyph charstring to *********/ | 2541 /********** quickly processes each glyph charstring to *********/ |
2514 /********** extract the value from either a `sbw' or `seac' *********/ | 2542 /********** extract the value from either a `sbw' or `seac' *********/ |
2515 /********** operator. *********/ | 2543 /********** operator. *********/ |
2516 /********** *********/ | 2544 /********** *********/ |
2517 /*************************************************************************/ | 2545 /*************************************************************************/ |
2518 /*************************************************************************/ | 2546 /*************************************************************************/ |
2519 /*************************************************************************/ | 2547 /*************************************************************************/ |
2520 | 2548 |
2521 | 2549 |
2522 #if 0 /* unused until we support pure CFF fonts */ | 2550 #if 0 /* unused until we support pure CFF fonts */ |
2523 | 2551 |
2524 | 2552 |
2525 FT_LOCAL_DEF( FT_Error ) | 2553 FT_LOCAL_DEF( FT_Error ) |
2526 cff_compute_max_advance( TT_Face face, | 2554 cff_compute_max_advance( TT_Face face, |
2527 FT_Int* max_advance ) | 2555 FT_Int* max_advance ) |
2528 { | 2556 { |
2529 FT_Error error = CFF_Err_Ok; | 2557 FT_Error error = FT_Err_Ok; |
2530 CFF_Decoder decoder; | 2558 CFF_Decoder decoder; |
2531 FT_Int glyph_index; | 2559 FT_Int glyph_index; |
2532 CFF_Font cff = (CFF_Font)face->other; | 2560 CFF_Font cff = (CFF_Font)face->other; |
2533 | 2561 |
2534 | 2562 |
2535 *max_advance = 0; | 2563 *max_advance = 0; |
2536 | 2564 |
2537 /* Initialize load decoder */ | 2565 /* Initialize load decoder */ |
2538 cff_decoder_init( &decoder, face, 0, 0, 0, 0 ); | 2566 cff_decoder_init( &decoder, face, 0, 0, 0, 0 ); |
2539 | 2567 |
(...skipping 17 matching lines...) Expand all Loading... |
2557 error = cff_decoder_prepare( &decoder, size, glyph_index ); | 2585 error = cff_decoder_prepare( &decoder, size, glyph_index ); |
2558 if ( !error ) | 2586 if ( !error ) |
2559 error = cff_decoder_parse_charstrings( &decoder, | 2587 error = cff_decoder_parse_charstrings( &decoder, |
2560 charstring, | 2588 charstring, |
2561 charstring_len ); | 2589 charstring_len ); |
2562 | 2590 |
2563 cff_free_glyph_data( face, &charstring, &charstring_len ); | 2591 cff_free_glyph_data( face, &charstring, &charstring_len ); |
2564 } | 2592 } |
2565 | 2593 |
2566 /* ignore the error if one has occurred -- skip to next glyph */ | 2594 /* ignore the error if one has occurred -- skip to next glyph */ |
2567 error = CFF_Err_Ok; | 2595 error = FT_Err_Ok; |
2568 } | 2596 } |
2569 | 2597 |
2570 *max_advance = decoder.builder.advance.x; | 2598 *max_advance = decoder.builder.advance.x; |
2571 | 2599 |
2572 return CFF_Err_Ok; | 2600 return FT_Err_Ok; |
2573 } | 2601 } |
2574 | 2602 |
2575 | 2603 |
2576 #endif /* 0 */ | 2604 #endif /* 0 */ |
2577 | 2605 |
2578 | 2606 |
2579 FT_LOCAL_DEF( FT_Error ) | 2607 FT_LOCAL_DEF( FT_Error ) |
2580 cff_slot_load( CFF_GlyphSlot glyph, | 2608 cff_slot_load( CFF_GlyphSlot glyph, |
2581 CFF_Size size, | 2609 CFF_Size size, |
2582 FT_UInt glyph_index, | 2610 FT_UInt glyph_index, |
2583 FT_Int32 load_flags ) | 2611 FT_Int32 load_flags ) |
2584 { | 2612 { |
2585 FT_Error error; | 2613 FT_Error error; |
2586 CFF_Decoder decoder; | 2614 CFF_Decoder decoder; |
2587 TT_Face face = (TT_Face)glyph->root.face; | 2615 TT_Face face = (TT_Face)glyph->root.face; |
2588 FT_Bool hinting, force_scaling; | 2616 FT_Bool hinting, scaled, force_scaling; |
2589 CFF_Font cff = (CFF_Font)face->extra.data; | 2617 CFF_Font cff = (CFF_Font)face->extra.data; |
2590 | 2618 |
2591 FT_Matrix font_matrix; | 2619 FT_Matrix font_matrix; |
2592 FT_Vector font_offset; | 2620 FT_Vector font_offset; |
2593 | 2621 |
2594 | 2622 |
2595 force_scaling = FALSE; | 2623 force_scaling = FALSE; |
2596 | 2624 |
2597 /* in a CID-keyed font, consider `glyph_index' as a CID and map */ | 2625 /* in a CID-keyed font, consider `glyph_index' as a CID and map */ |
2598 /* it immediately to the real glyph_index -- if it isn't a */ | 2626 /* it immediately to the real glyph_index -- if it isn't a */ |
2599 /* subsetted font, glyph_indices and CIDs are identical, though */ | 2627 /* subsetted font, glyph_indices and CIDs are identical, though */ |
2600 if ( cff->top_font.font_dict.cid_registry != 0xFFFFU && | 2628 if ( cff->top_font.font_dict.cid_registry != 0xFFFFU && |
2601 cff->charset.cids ) | 2629 cff->charset.cids ) |
2602 { | 2630 { |
2603 /* don't handle CID 0 (.notdef) which is directly mapped to GID 0 */ | 2631 /* don't handle CID 0 (.notdef) which is directly mapped to GID 0 */ |
2604 if ( glyph_index != 0 ) | 2632 if ( glyph_index != 0 ) |
2605 { | 2633 { |
2606 glyph_index = cff_charset_cid_to_gindex( &cff->charset, | 2634 glyph_index = cff_charset_cid_to_gindex( &cff->charset, |
2607 glyph_index ); | 2635 glyph_index ); |
2608 if ( glyph_index == 0 ) | 2636 if ( glyph_index == 0 ) |
2609 return CFF_Err_Invalid_Argument; | 2637 return FT_THROW( Invalid_Argument ); |
2610 } | 2638 } |
2611 } | 2639 } |
2612 else if ( glyph_index >= cff->num_glyphs ) | 2640 else if ( glyph_index >= cff->num_glyphs ) |
2613 return CFF_Err_Invalid_Argument; | 2641 return FT_THROW( Invalid_Argument ); |
2614 | 2642 |
2615 if ( load_flags & FT_LOAD_NO_RECURSE ) | 2643 if ( load_flags & FT_LOAD_NO_RECURSE ) |
2616 load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; | 2644 load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; |
2617 | 2645 |
2618 glyph->x_scale = 0x10000L; | 2646 glyph->x_scale = 0x10000L; |
2619 glyph->y_scale = 0x10000L; | 2647 glyph->y_scale = 0x10000L; |
2620 if ( size ) | 2648 if ( size ) |
2621 { | 2649 { |
2622 glyph->x_scale = size->root.metrics.x_scale; | 2650 glyph->x_scale = size->root.metrics.x_scale; |
2623 glyph->y_scale = size->root.metrics.y_scale; | 2651 glyph->y_scale = size->root.metrics.y_scale; |
(...skipping 22 matching lines...) Expand all Loading... |
2646 error = sfnt->load_sbit_image( face, | 2674 error = sfnt->load_sbit_image( face, |
2647 size->strike_index, | 2675 size->strike_index, |
2648 glyph_index, | 2676 glyph_index, |
2649 (FT_Int)load_flags, | 2677 (FT_Int)load_flags, |
2650 stream, | 2678 stream, |
2651 &glyph->root.bitmap, | 2679 &glyph->root.bitmap, |
2652 &metrics ); | 2680 &metrics ); |
2653 | 2681 |
2654 if ( !error ) | 2682 if ( !error ) |
2655 { | 2683 { |
| 2684 FT_Bool has_vertical_info; |
| 2685 FT_UShort advance; |
| 2686 FT_Short dummy; |
| 2687 |
| 2688 |
2656 glyph->root.outline.n_points = 0; | 2689 glyph->root.outline.n_points = 0; |
2657 glyph->root.outline.n_contours = 0; | 2690 glyph->root.outline.n_contours = 0; |
2658 | 2691 |
2659 glyph->root.metrics.width = (FT_Pos)metrics.width << 6; | 2692 glyph->root.metrics.width = (FT_Pos)metrics.width << 6; |
2660 glyph->root.metrics.height = (FT_Pos)metrics.height << 6; | 2693 glyph->root.metrics.height = (FT_Pos)metrics.height << 6; |
2661 | 2694 |
2662 glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6; | 2695 glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6; |
2663 glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6; | 2696 glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6; |
2664 glyph->root.metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6; | 2697 glyph->root.metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6; |
2665 | 2698 |
2666 glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6; | 2699 glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6; |
2667 glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6; | 2700 glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6; |
2668 glyph->root.metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6; | 2701 glyph->root.metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6; |
2669 | 2702 |
2670 glyph->root.format = FT_GLYPH_FORMAT_BITMAP; | 2703 glyph->root.format = FT_GLYPH_FORMAT_BITMAP; |
2671 | 2704 |
2672 if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) | 2705 if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) |
2673 { | 2706 { |
2674 glyph->root.bitmap_left = metrics.vertBearingX; | 2707 glyph->root.bitmap_left = metrics.vertBearingX; |
2675 glyph->root.bitmap_top = metrics.vertBearingY; | 2708 glyph->root.bitmap_top = metrics.vertBearingY; |
2676 } | 2709 } |
2677 else | 2710 else |
2678 { | 2711 { |
2679 glyph->root.bitmap_left = metrics.horiBearingX; | 2712 glyph->root.bitmap_left = metrics.horiBearingX; |
2680 glyph->root.bitmap_top = metrics.horiBearingY; | 2713 glyph->root.bitmap_top = metrics.horiBearingY; |
2681 } | 2714 } |
| 2715 |
| 2716 /* compute linear advance widths */ |
| 2717 |
| 2718 ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, |
| 2719 glyph_index, |
| 2720 &dummy, |
| 2721 &advance ); |
| 2722 glyph->root.linearHoriAdvance = advance; |
| 2723 |
| 2724 has_vertical_info = FT_BOOL( |
| 2725 face->vertical_info && |
| 2726 face->vertical.number_Of_VMetrics > 0 ); |
| 2727 |
| 2728 /* get the vertical metrics from the vtmx table if we have one */ |
| 2729 if ( has_vertical_info ) |
| 2730 { |
| 2731 ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, |
| 2732 glyph_index, |
| 2733 &dummy, |
| 2734 &advance ); |
| 2735 glyph->root.linearVertAdvance = advance; |
| 2736 } |
| 2737 else |
| 2738 { |
| 2739 /* make up vertical ones */ |
| 2740 if ( face->os2.version != 0xFFFFU ) |
| 2741 glyph->root.linearVertAdvance = (FT_Pos) |
| 2742 ( face->os2.sTypoAscender - face->os2.sTypoDescender ); |
| 2743 else |
| 2744 glyph->root.linearVertAdvance = (FT_Pos) |
| 2745 ( face->horizontal.Ascender - face->horizontal.Descender ); |
| 2746 } |
| 2747 |
2682 return error; | 2748 return error; |
2683 } | 2749 } |
2684 } | 2750 } |
2685 } | 2751 } |
2686 | 2752 |
2687 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ | 2753 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ |
2688 | 2754 |
2689 /* return immediately if we only want the embedded bitmaps */ | 2755 /* return immediately if we only want the embedded bitmaps */ |
2690 if ( load_flags & FT_LOAD_SBITS_ONLY ) | 2756 if ( load_flags & FT_LOAD_SBITS_ONLY ) |
2691 return CFF_Err_Invalid_Argument; | 2757 return FT_THROW( Invalid_Argument ); |
2692 | 2758 |
2693 /* if we have a CID subfont, use its matrix (which has already */ | 2759 /* if we have a CID subfont, use its matrix (which has already */ |
2694 /* been multiplied with the root matrix) */ | 2760 /* been multiplied with the root matrix) */ |
2695 | 2761 |
2696 /* this scaling is only relevant if the PS hinter isn't active */ | 2762 /* this scaling is only relevant if the PS hinter isn't active */ |
2697 if ( cff->num_subfonts ) | 2763 if ( cff->num_subfonts ) |
2698 { | 2764 { |
2699 FT_ULong top_upm, sub_upm; | 2765 FT_ULong top_upm, sub_upm; |
2700 FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, | 2766 FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, |
2701 glyph_index ); | 2767 glyph_index ); |
2702 | 2768 |
| 2769 |
2703 if ( fd_index >= cff->num_subfonts ) | 2770 if ( fd_index >= cff->num_subfonts ) |
2704 fd_index = (FT_Byte)( cff->num_subfonts - 1 ); | 2771 fd_index = (FT_Byte)( cff->num_subfonts - 1 ); |
2705 | 2772 |
2706 top_upm = cff->top_font.font_dict.units_per_em; | 2773 top_upm = cff->top_font.font_dict.units_per_em; |
2707 sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em; | 2774 sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em; |
2708 | 2775 |
2709 | 2776 |
2710 font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix; | 2777 font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix; |
2711 font_offset = cff->subfonts[fd_index]->font_dict.font_offset; | 2778 font_offset = cff->subfonts[fd_index]->font_dict.font_offset; |
2712 | 2779 |
2713 if ( top_upm != sub_upm ) | 2780 if ( top_upm != sub_upm ) |
2714 { | 2781 { |
2715 glyph->x_scale = FT_MulDiv( glyph->x_scale, top_upm, sub_upm ); | 2782 glyph->x_scale = FT_MulDiv( glyph->x_scale, top_upm, sub_upm ); |
2716 glyph->y_scale = FT_MulDiv( glyph->y_scale, top_upm, sub_upm ); | 2783 glyph->y_scale = FT_MulDiv( glyph->y_scale, top_upm, sub_upm ); |
2717 | 2784 |
2718 force_scaling = TRUE; | 2785 force_scaling = TRUE; |
2719 } | 2786 } |
2720 } | 2787 } |
2721 else | 2788 else |
2722 { | 2789 { |
2723 font_matrix = cff->top_font.font_dict.font_matrix; | 2790 font_matrix = cff->top_font.font_dict.font_matrix; |
2724 font_offset = cff->top_font.font_dict.font_offset; | 2791 font_offset = cff->top_font.font_dict.font_offset; |
2725 } | 2792 } |
2726 | 2793 |
2727 glyph->root.outline.n_points = 0; | 2794 glyph->root.outline.n_points = 0; |
2728 glyph->root.outline.n_contours = 0; | 2795 glyph->root.outline.n_contours = 0; |
2729 | 2796 |
2730 hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 && | 2797 /* top-level code ensures that FT_LOAD_NO_HINTING is set */ |
2731 ( load_flags & FT_LOAD_NO_HINTING ) == 0 ); | 2798 /* if FT_LOAD_NO_SCALE is active */ |
| 2799 hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_HINTING ) == 0 ); |
| 2800 scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ); |
2732 | 2801 |
| 2802 glyph->hint = hinting; |
| 2803 glyph->scaled = scaled; |
2733 glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; /* by default */ | 2804 glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; /* by default */ |
2734 | 2805 |
2735 { | 2806 { |
| 2807 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE |
| 2808 CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( face ); |
| 2809 #endif |
| 2810 |
| 2811 |
2736 FT_Byte* charstring; | 2812 FT_Byte* charstring; |
2737 FT_ULong charstring_len; | 2813 FT_ULong charstring_len; |
2738 | 2814 |
2739 | 2815 |
2740 cff_decoder_init( &decoder, face, size, glyph, hinting, | 2816 cff_decoder_init( &decoder, face, size, glyph, hinting, |
2741 FT_LOAD_TARGET_MODE( load_flags ) ); | 2817 FT_LOAD_TARGET_MODE( load_flags ) ); |
2742 | 2818 |
2743 if ( load_flags & FT_LOAD_ADVANCE_ONLY ) | 2819 if ( load_flags & FT_LOAD_ADVANCE_ONLY ) |
2744 decoder.width_only = TRUE; | 2820 decoder.width_only = TRUE; |
2745 | 2821 |
2746 decoder.builder.no_recurse = | 2822 decoder.builder.no_recurse = |
2747 (FT_Bool)( load_flags & FT_LOAD_NO_RECURSE ); | 2823 (FT_Bool)( load_flags & FT_LOAD_NO_RECURSE ); |
2748 | 2824 |
2749 /* now load the unscaled outline */ | 2825 /* now load the unscaled outline */ |
2750 error = cff_get_glyph_data( face, glyph_index, | 2826 error = cff_get_glyph_data( face, glyph_index, |
2751 &charstring, &charstring_len ); | 2827 &charstring, &charstring_len ); |
2752 if ( error ) | 2828 if ( error ) |
2753 goto Glyph_Build_Finished; | 2829 goto Glyph_Build_Finished; |
2754 | 2830 |
2755 error = cff_decoder_prepare( &decoder, size, glyph_index ); | 2831 error = cff_decoder_prepare( &decoder, size, glyph_index ); |
2756 if ( error ) | 2832 if ( error ) |
2757 goto Glyph_Build_Finished; | 2833 goto Glyph_Build_Finished; |
2758 | 2834 |
2759 error = cff_decoder_parse_charstrings( &decoder, | 2835 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE |
2760 charstring, | 2836 /* choose which CFF renderer to use */ |
2761 charstring_len ); | 2837 if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE ) |
| 2838 error = cff_decoder_parse_charstrings( &decoder, |
| 2839 charstring, |
| 2840 charstring_len ); |
| 2841 else |
| 2842 #endif |
| 2843 { |
| 2844 error = cf2_decoder_parse_charstrings( &decoder, |
| 2845 charstring, |
| 2846 charstring_len ); |
| 2847 |
| 2848 /* Adobe's engine uses 16.16 numbers everywhere; */ |
| 2849 /* as a consequence, glyphs larger than 2000ppem get rejected */ |
| 2850 if ( FT_ERR_EQ( error, Glyph_Too_Big ) ) |
| 2851 { |
| 2852 /* XXX to be implemented */ |
| 2853 } |
| 2854 } |
2762 | 2855 |
2763 cff_free_glyph_data( face, &charstring, charstring_len ); | 2856 cff_free_glyph_data( face, &charstring, charstring_len ); |
2764 | 2857 |
2765 if ( error ) | 2858 if ( error ) |
2766 goto Glyph_Build_Finished; | 2859 goto Glyph_Build_Finished; |
2767 | 2860 |
2768 #ifdef FT_CONFIG_OPTION_INCREMENTAL | 2861 #ifdef FT_CONFIG_OPTION_INCREMENTAL |
2769 /* Control data and length may not be available for incremental */ | 2862 /* Control data and length may not be available for incremental */ |
2770 /* fonts. */ | 2863 /* fonts. */ |
2771 if ( face->root.internal->incremental_interface ) | 2864 if ( face->root.internal->incremental_interface ) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2849 FT_Glyph_Metrics* metrics = &glyph->root.metrics; | 2942 FT_Glyph_Metrics* metrics = &glyph->root.metrics; |
2850 FT_Vector advance; | 2943 FT_Vector advance; |
2851 FT_Bool has_vertical_info; | 2944 FT_Bool has_vertical_info; |
2852 | 2945 |
2853 | 2946 |
2854 /* copy the _unscaled_ advance width */ | 2947 /* copy the _unscaled_ advance width */ |
2855 metrics->horiAdvance = decoder.glyph_width; | 2948 metrics->horiAdvance = decoder.glyph_width; |
2856 glyph->root.linearHoriAdvance = decoder.glyph_width; | 2949 glyph->root.linearHoriAdvance = decoder.glyph_width; |
2857 glyph->root.internal->glyph_transformed = 0; | 2950 glyph->root.internal->glyph_transformed = 0; |
2858 | 2951 |
2859 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS | |
2860 has_vertical_info = FT_BOOL( face->vertical_info && | |
2861 face->vertical.number_Of_VMetrics > 0 && | |
2862 face->vertical.long_metrics ); | |
2863 #else | |
2864 has_vertical_info = FT_BOOL( face->vertical_info && | 2952 has_vertical_info = FT_BOOL( face->vertical_info && |
2865 face->vertical.number_Of_VMetrics > 0 ); | 2953 face->vertical.number_Of_VMetrics > 0 ); |
2866 #endif | |
2867 | 2954 |
2868 /* get the vertical metrics from the vtmx table if we have one */ | 2955 /* get the vertical metrics from the vtmx table if we have one */ |
2869 if ( has_vertical_info ) | 2956 if ( has_vertical_info ) |
2870 { | 2957 { |
2871 FT_Short vertBearingY = 0; | 2958 FT_Short vertBearingY = 0; |
2872 FT_UShort vertAdvance = 0; | 2959 FT_UShort vertAdvance = 0; |
2873 | 2960 |
2874 | 2961 |
2875 ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, | 2962 ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, |
2876 glyph_index, | 2963 glyph_index, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2963 metrics->vertAdvance ); | 3050 metrics->vertAdvance ); |
2964 } | 3051 } |
2965 } | 3052 } |
2966 } | 3053 } |
2967 | 3054 |
2968 return error; | 3055 return error; |
2969 } | 3056 } |
2970 | 3057 |
2971 | 3058 |
2972 /* END */ | 3059 /* END */ |
OLD | NEW |