OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ttobjs.c */ | 3 /* ttobjs.c */ |
4 /* */ | 4 /* */ |
5 /* Objects manager (body). */ | 5 /* Objects manager (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 1996-2011 */ | 7 /* Copyright 1996-2013 */ |
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_TRUETYPE_TAGS_H | 22 #include FT_TRUETYPE_TAGS_H |
23 #include FT_INTERNAL_SFNT_H | 23 #include FT_INTERNAL_SFNT_H |
| 24 #include FT_TRUETYPE_DRIVER_H |
24 | 25 |
25 #include "ttgload.h" | 26 #include "ttgload.h" |
26 #include "ttpload.h" | 27 #include "ttpload.h" |
27 | 28 |
28 #include "tterrors.h" | 29 #include "tterrors.h" |
29 | 30 |
30 #ifdef TT_USE_BYTECODE_INTERPRETER | 31 #ifdef TT_USE_BYTECODE_INTERPRETER |
31 #include "ttinterp.h" | 32 #include "ttinterp.h" |
32 #endif | 33 #endif |
33 | 34 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 FT_ULong CheckSum; | 238 FT_ULong CheckSum; |
238 FT_ULong Length; | 239 FT_ULong Length; |
239 | 240 |
240 } tt_sfnt_id_rec; | 241 } tt_sfnt_id_rec; |
241 | 242 |
242 | 243 |
243 static FT_Bool | 244 static FT_Bool |
244 tt_check_trickyness_sfnt_ids( TT_Face face ) | 245 tt_check_trickyness_sfnt_ids( TT_Face face ) |
245 { | 246 { |
246 #define TRICK_SFNT_IDS_PER_FACE 3 | 247 #define TRICK_SFNT_IDS_PER_FACE 3 |
247 #define TRICK_SFNT_IDS_NUM_FACES 13 | 248 #define TRICK_SFNT_IDS_NUM_FACES 17 |
248 | 249 |
249 static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES] | 250 static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES] |
250 [TRICK_SFNT_IDS_PER_FACE] = { | 251 [TRICK_SFNT_IDS_PER_FACE] = { |
251 | 252 |
252 #define TRICK_SFNT_ID_cvt 0 | 253 #define TRICK_SFNT_ID_cvt 0 |
253 #define TRICK_SFNT_ID_fpgm 1 | 254 #define TRICK_SFNT_ID_fpgm 1 |
254 #define TRICK_SFNT_ID_prep 2 | 255 #define TRICK_SFNT_ID_prep 2 |
255 | 256 |
256 { /* MingLiU 1995 */ | 257 { /* MingLiU 1995 */ |
257 { 0x05bcf058, 0x000002e4 }, /* cvt */ | 258 { 0x05bcf058, 0x000002e4 }, /* cvt */ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 }, | 311 }, |
311 { /* NEC fangot5.ttc */ | 312 { /* NEC fangot5.ttc */ |
312 { 0x00000000, 0x00000000 }, /* cvt */ | 313 { 0x00000000, 0x00000000 }, /* cvt */ |
313 { 0x40aa774c, 0x000001cb }, /* fpgm */ | 314 { 0x40aa774c, 0x000001cb }, /* fpgm */ |
314 { 0x9b5caa96, 0x00001f9a } /* prep */ | 315 { 0x9b5caa96, 0x00001f9a } /* prep */ |
315 }, | 316 }, |
316 { /* NEC fanmin3.ttc */ | 317 { /* NEC fanmin3.ttc */ |
317 { 0x00000000, 0x00000000 }, /* cvt */ | 318 { 0x00000000, 0x00000000 }, /* cvt */ |
318 { 0x0d3de9cb, 0x00000141 }, /* fpgm */ | 319 { 0x0d3de9cb, 0x00000141 }, /* fpgm */ |
319 { 0xd4127766, 0x00002280 } /* prep */ | 320 { 0xd4127766, 0x00002280 } /* prep */ |
| 321 }, |
| 322 { /* NEC FA-Gothic, 1996 */ |
| 323 { 0x00000000, 0x00000000 }, /* cvt */ |
| 324 { 0x4a692698, 0x000001f0 }, /* fpgm */ |
| 325 { 0x340d4346, 0x00001fca } /* prep */ |
| 326 }, |
| 327 { /* NEC FA-Minchou, 1996 */ |
| 328 { 0x00000000, 0x00000000 }, /* cvt */ |
| 329 { 0xcd34c604, 0x00000166 }, /* fpgm */ |
| 330 { 0x6cf31046, 0x000022b0 } /* prep */ |
| 331 }, |
| 332 { /* NEC FA-RoundGothicB, 1996 */ |
| 333 { 0x00000000, 0x00000000 }, /* cvt */ |
| 334 { 0x5da75315, 0x0000019d }, /* fpgm */ |
| 335 { 0x40745a5f, 0x000022e0 } /* prep */ |
| 336 }, |
| 337 { /* NEC FA-RoundGothicM, 1996 */ |
| 338 { 0x00000000, 0x00000000 }, /* cvt */ |
| 339 { 0xf055fc48, 0x000001c2 }, /* fpgm */ |
| 340 { 0x3900ded3, 0x00001e18 } /* prep */ |
320 } | 341 } |
321 }; | 342 }; |
322 | 343 |
323 FT_ULong checksum; | 344 FT_ULong checksum; |
324 int num_matched_ids[TRICK_SFNT_IDS_NUM_FACES]; | 345 int num_matched_ids[TRICK_SFNT_IDS_NUM_FACES]; |
325 FT_Bool has_cvt, has_fpgm, has_prep; | 346 FT_Bool has_cvt, has_fpgm, has_prep; |
326 FT_UShort i; | 347 FT_UShort i; |
327 int j, k; | 348 int j, k; |
328 | 349 |
329 | 350 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 | 515 |
495 | 516 |
496 FT_TRACE2(( "TTF driver\n" )); | 517 FT_TRACE2(( "TTF driver\n" )); |
497 | 518 |
498 library = ttface->driver->root.library; | 519 library = ttface->driver->root.library; |
499 | 520 |
500 sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); | 521 sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); |
501 if ( !sfnt ) | 522 if ( !sfnt ) |
502 { | 523 { |
503 FT_ERROR(( "tt_face_init: cannot access `sfnt' module\n" )); | 524 FT_ERROR(( "tt_face_init: cannot access `sfnt' module\n" )); |
504 error = TT_Err_Missing_Module; | 525 error = FT_THROW( Missing_Module ); |
505 goto Exit; | 526 goto Exit; |
506 } | 527 } |
507 | 528 |
508 /* create input stream from resource */ | 529 /* create input stream from resource */ |
509 if ( FT_STREAM_SEEK( 0 ) ) | 530 if ( FT_STREAM_SEEK( 0 ) ) |
510 goto Exit; | 531 goto Exit; |
511 | 532 |
512 /* check that we have a valid TrueType file */ | 533 /* check that we have a valid TrueType file */ |
513 error = sfnt->init_face( stream, face, face_index, num_params, params ); | 534 error = sfnt->init_face( stream, face, face_index, num_params, params ); |
514 if ( error ) | 535 if ( error ) |
515 goto Exit; | 536 goto Exit; |
516 | 537 |
517 /* We must also be able to accept Mac/GX fonts, as well as OT ones. */ | 538 /* We must also be able to accept Mac/GX fonts, as well as OT ones. */ |
518 /* The 0x00020000 tag is completely undocumented; some fonts from */ | 539 /* The 0x00020000 tag is completely undocumented; some fonts from */ |
519 /* Arphic made for Chinese Windows 3.1 have this. */ | 540 /* Arphic made for Chinese Windows 3.1 have this. */ |
520 if ( face->format_tag != 0x00010000L && /* MS fonts */ | 541 if ( face->format_tag != 0x00010000L && /* MS fonts */ |
521 face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */ | 542 face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */ |
522 face->format_tag != TTAG_true ) /* Mac fonts */ | 543 face->format_tag != TTAG_true ) /* Mac fonts */ |
523 { | 544 { |
524 FT_TRACE2(( " not a TTF font\n" )); | 545 FT_TRACE2(( " not a TTF font\n" )); |
525 goto Bad_Format; | 546 goto Bad_Format; |
526 } | 547 } |
527 | 548 |
528 #ifdef TT_USE_BYTECODE_INTERPRETER | 549 #ifdef TT_USE_BYTECODE_INTERPRETER |
529 ttface->face_flags |= FT_FACE_FLAG_HINTER; | 550 ttface->face_flags |= FT_FACE_FLAG_HINTER; |
530 #endif | 551 #endif |
531 | 552 |
532 /* If we are performing a simple font format check, exit immediately. */ | 553 /* If we are performing a simple font format check, exit immediately. */ |
533 if ( face_index < 0 ) | 554 if ( face_index < 0 ) |
534 return TT_Err_Ok; | 555 return FT_Err_Ok; |
535 | 556 |
536 /* Load font directory */ | 557 /* Load font directory */ |
537 error = sfnt->load_face( stream, face, face_index, num_params, params ); | 558 error = sfnt->load_face( stream, face, face_index, num_params, params ); |
538 if ( error ) | 559 if ( error ) |
539 goto Exit; | 560 goto Exit; |
540 | 561 |
541 if ( tt_check_trickyness( ttface ) ) | 562 if ( tt_check_trickyness( ttface ) ) |
542 ttface->face_flags |= FT_FACE_FLAG_TRICKY; | 563 ttface->face_flags |= FT_FACE_FLAG_TRICKY; |
543 | 564 |
544 error = tt_face_load_hdmx( face, stream ); | 565 error = tt_face_load_hdmx( face, stream ); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 #endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING && | 645 #endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING && |
625 !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ | 646 !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ |
626 | 647 |
627 /* initialize standard glyph loading routines */ | 648 /* initialize standard glyph loading routines */ |
628 TT_Init_Glyph_Loading( face ); | 649 TT_Init_Glyph_Loading( face ); |
629 | 650 |
630 Exit: | 651 Exit: |
631 return error; | 652 return error; |
632 | 653 |
633 Bad_Format: | 654 Bad_Format: |
634 error = TT_Err_Unknown_File_Format; | 655 error = FT_THROW( Unknown_File_Format ); |
635 goto Exit; | 656 goto Exit; |
636 } | 657 } |
637 | 658 |
638 | 659 |
639 /*************************************************************************/ | 660 /*************************************************************************/ |
640 /* */ | 661 /* */ |
641 /* <Function> */ | 662 /* <Function> */ |
642 /* tt_face_done */ | 663 /* tt_face_done */ |
643 /* */ | 664 /* */ |
644 /* <Description> */ | 665 /* <Description> */ |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 FT_Error error; | 746 FT_Error error; |
726 | 747 |
727 | 748 |
728 /* debugging instances have their own context */ | 749 /* debugging instances have their own context */ |
729 if ( size->debug ) | 750 if ( size->debug ) |
730 exec = size->context; | 751 exec = size->context; |
731 else | 752 else |
732 exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context; | 753 exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context; |
733 | 754 |
734 if ( !exec ) | 755 if ( !exec ) |
735 return TT_Err_Could_Not_Find_Context; | 756 return FT_THROW( Could_Not_Find_Context ); |
736 | 757 |
737 TT_Load_Context( exec, face, size ); | 758 TT_Load_Context( exec, face, size ); |
738 | 759 |
739 exec->callTop = 0; | 760 exec->callTop = 0; |
740 exec->top = 0; | 761 exec->top = 0; |
741 | 762 |
742 exec->period = 64; | 763 exec->period = 64; |
743 exec->phase = 0; | 764 exec->phase = 0; |
744 exec->threshold = 0; | 765 exec->threshold = 0; |
745 | 766 |
746 exec->instruction_trap = FALSE; | 767 exec->instruction_trap = FALSE; |
747 exec->F_dot_P = 0x10000L; | 768 exec->F_dot_P = 0x4000L; |
748 | 769 |
749 exec->pedantic_hinting = pedantic; | 770 exec->pedantic_hinting = pedantic; |
750 | 771 |
751 { | 772 { |
752 FT_Size_Metrics* metrics = &exec->metrics; | 773 FT_Size_Metrics* metrics = &exec->metrics; |
753 TT_Size_Metrics* tt_metrics = &exec->tt_metrics; | 774 TT_Size_Metrics* tt_metrics = &exec->tt_metrics; |
754 | 775 |
755 | 776 |
756 metrics->x_ppem = 0; | 777 metrics->x_ppem = 0; |
757 metrics->y_ppem = 0; | 778 metrics->y_ppem = 0; |
(...skipping 20 matching lines...) Expand all Loading... |
778 error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 ); | 799 error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 ); |
779 | 800 |
780 if ( !error ) | 801 if ( !error ) |
781 { | 802 { |
782 FT_TRACE4(( "Executing `fpgm' table.\n" )); | 803 FT_TRACE4(( "Executing `fpgm' table.\n" )); |
783 | 804 |
784 error = face->interpreter( exec ); | 805 error = face->interpreter( exec ); |
785 } | 806 } |
786 } | 807 } |
787 else | 808 else |
788 error = TT_Err_Ok; | 809 error = FT_Err_Ok; |
789 | 810 |
790 if ( !error ) | 811 if ( !error ) |
791 TT_Save_Context( exec, size ); | 812 TT_Save_Context( exec, size ); |
792 | 813 |
793 return error; | 814 return error; |
794 } | 815 } |
795 | 816 |
796 | 817 |
797 /*************************************************************************/ | 818 /*************************************************************************/ |
798 /* */ | 819 /* */ |
(...skipping 20 matching lines...) Expand all Loading... |
819 FT_Error error; | 840 FT_Error error; |
820 | 841 |
821 | 842 |
822 /* debugging instances have their own context */ | 843 /* debugging instances have their own context */ |
823 if ( size->debug ) | 844 if ( size->debug ) |
824 exec = size->context; | 845 exec = size->context; |
825 else | 846 else |
826 exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context; | 847 exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context; |
827 | 848 |
828 if ( !exec ) | 849 if ( !exec ) |
829 return TT_Err_Could_Not_Find_Context; | 850 return FT_THROW( Could_Not_Find_Context ); |
830 | 851 |
831 TT_Load_Context( exec, face, size ); | 852 TT_Load_Context( exec, face, size ); |
832 | 853 |
833 exec->callTop = 0; | 854 exec->callTop = 0; |
834 exec->top = 0; | 855 exec->top = 0; |
835 | 856 |
836 exec->instruction_trap = FALSE; | 857 exec->instruction_trap = FALSE; |
837 | 858 |
838 exec->pedantic_hinting = pedantic; | 859 exec->pedantic_hinting = pedantic; |
839 | 860 |
840 TT_Set_CodeRange( exec, | 861 TT_Set_CodeRange( exec, |
841 tt_coderange_cvt, | 862 tt_coderange_cvt, |
842 face->cvt_program, | 863 face->cvt_program, |
843 face->cvt_program_size ); | 864 face->cvt_program_size ); |
844 | 865 |
845 TT_Clear_CodeRange( exec, tt_coderange_glyph ); | 866 TT_Clear_CodeRange( exec, tt_coderange_glyph ); |
846 | 867 |
847 if ( face->cvt_program_size > 0 ) | 868 if ( face->cvt_program_size > 0 ) |
848 { | 869 { |
849 error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); | 870 error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); |
850 | 871 |
851 if ( !error && !size->debug ) | 872 if ( !error && !size->debug ) |
852 { | 873 { |
853 FT_TRACE4(( "Executing `prep' table.\n" )); | 874 FT_TRACE4(( "Executing `prep' table.\n" )); |
854 | 875 |
855 error = face->interpreter( exec ); | 876 error = face->interpreter( exec ); |
856 } | 877 } |
857 } | 878 } |
858 else | 879 else |
859 error = TT_Err_Ok; | 880 error = FT_Err_Ok; |
| 881 |
| 882 /* UNDOCUMENTED! The MS rasterizer doesn't allow the following */ |
| 883 /* graphics state variables to be modified by the CVT program. */ |
| 884 |
| 885 exec->GS.dualVector.x = 0x4000; |
| 886 exec->GS.dualVector.y = 0; |
| 887 exec->GS.projVector.x = 0x4000; |
| 888 exec->GS.projVector.y = 0x0; |
| 889 exec->GS.freeVector.x = 0x4000; |
| 890 exec->GS.freeVector.y = 0x0; |
| 891 |
| 892 exec->GS.rp0 = 0; |
| 893 exec->GS.rp1 = 0; |
| 894 exec->GS.rp2 = 0; |
| 895 |
| 896 exec->GS.gep0 = 1; |
| 897 exec->GS.gep1 = 1; |
| 898 exec->GS.gep2 = 1; |
| 899 |
| 900 exec->GS.loop = 1; |
860 | 901 |
861 /* save as default graphics state */ | 902 /* save as default graphics state */ |
862 size->GS = exec->GS; | 903 size->GS = exec->GS; |
863 | 904 |
864 TT_Save_Context( exec, size ); | 905 TT_Save_Context( exec, size ); |
865 | 906 |
866 return error; | 907 return error; |
867 } | 908 } |
868 | 909 |
869 #endif /* TT_USE_BYTECODE_INTERPRETER */ | 910 #endif /* TT_USE_BYTECODE_INTERPRETER */ |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 tt_size_done_bytecode( ftsize ); | 1037 tt_size_done_bytecode( ftsize ); |
997 | 1038 |
998 return error; | 1039 return error; |
999 } | 1040 } |
1000 | 1041 |
1001 | 1042 |
1002 FT_LOCAL_DEF( FT_Error ) | 1043 FT_LOCAL_DEF( FT_Error ) |
1003 tt_size_ready_bytecode( TT_Size size, | 1044 tt_size_ready_bytecode( TT_Size size, |
1004 FT_Bool pedantic ) | 1045 FT_Bool pedantic ) |
1005 { | 1046 { |
1006 FT_Error error = TT_Err_Ok; | 1047 FT_Error error = FT_Err_Ok; |
1007 | 1048 |
1008 | 1049 |
1009 if ( !size->bytecode_ready ) | 1050 if ( !size->bytecode_ready ) |
1010 { | 1051 { |
1011 error = tt_size_init_bytecode( (FT_Size)size, pedantic ); | 1052 error = tt_size_init_bytecode( (FT_Size)size, pedantic ); |
1012 if ( error ) | 1053 if ( error ) |
1013 goto Exit; | 1054 goto Exit; |
1014 } | 1055 } |
1015 | 1056 |
1016 /* rescale CVT when needed */ | 1057 /* rescale CVT when needed */ |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 /* <InOut> */ | 1104 /* <InOut> */ |
1064 /* size :: A handle to the size object. */ | 1105 /* size :: A handle to the size object. */ |
1065 /* */ | 1106 /* */ |
1066 /* <Return> */ | 1107 /* <Return> */ |
1067 /* FreeType error code. 0 means success. */ | 1108 /* FreeType error code. 0 means success. */ |
1068 /* */ | 1109 /* */ |
1069 FT_LOCAL_DEF( FT_Error ) | 1110 FT_LOCAL_DEF( FT_Error ) |
1070 tt_size_init( FT_Size ttsize ) /* TT_Size */ | 1111 tt_size_init( FT_Size ttsize ) /* TT_Size */ |
1071 { | 1112 { |
1072 TT_Size size = (TT_Size)ttsize; | 1113 TT_Size size = (TT_Size)ttsize; |
1073 FT_Error error = TT_Err_Ok; | 1114 FT_Error error = FT_Err_Ok; |
1074 | 1115 |
1075 #ifdef TT_USE_BYTECODE_INTERPRETER | 1116 #ifdef TT_USE_BYTECODE_INTERPRETER |
1076 size->bytecode_ready = 0; | 1117 size->bytecode_ready = 0; |
1077 size->cvt_ready = 0; | 1118 size->cvt_ready = 0; |
1078 #endif | 1119 #endif |
1079 | 1120 |
1080 size->ttmetrics.valid = FALSE; | 1121 size->ttmetrics.valid = FALSE; |
1081 size->strike_index = 0xFFFFFFFFUL; | 1122 size->strike_index = 0xFFFFFFFFUL; |
1082 | 1123 |
1083 return error; | 1124 return error; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 /* Reset a TrueType size when resolutions and character dimensions */ | 1160 /* Reset a TrueType size when resolutions and character dimensions */ |
1120 /* have been changed. */ | 1161 /* have been changed. */ |
1121 /* */ | 1162 /* */ |
1122 /* <Input> */ | 1163 /* <Input> */ |
1123 /* size :: A handle to the target size object. */ | 1164 /* size :: A handle to the target size object. */ |
1124 /* */ | 1165 /* */ |
1125 FT_LOCAL_DEF( FT_Error ) | 1166 FT_LOCAL_DEF( FT_Error ) |
1126 tt_size_reset( TT_Size size ) | 1167 tt_size_reset( TT_Size size ) |
1127 { | 1168 { |
1128 TT_Face face; | 1169 TT_Face face; |
1129 FT_Error error = TT_Err_Ok; | 1170 FT_Error error = FT_Err_Ok; |
1130 FT_Size_Metrics* metrics; | 1171 FT_Size_Metrics* metrics; |
1131 | 1172 |
1132 | 1173 |
1133 size->ttmetrics.valid = FALSE; | 1174 size->ttmetrics.valid = FALSE; |
1134 | 1175 |
1135 face = (TT_Face)size->root.face; | 1176 face = (TT_Face)size->root.face; |
1136 | 1177 |
1137 metrics = &size->metrics; | 1178 metrics = &size->metrics; |
1138 | 1179 |
1139 /* copy the result from base layer */ | 1180 /* copy the result from base layer */ |
1140 *metrics = size->root.metrics; | 1181 *metrics = size->root.metrics; |
1141 | 1182 |
1142 if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 ) | 1183 if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 ) |
1143 return TT_Err_Invalid_PPem; | 1184 return FT_THROW( Invalid_PPem ); |
1144 | 1185 |
1145 /* This bit flag, if set, indicates that the ppems must be */ | 1186 /* This bit flag, if set, indicates that the ppems must be */ |
1146 /* rounded to integers. Nearly all TrueType fonts have this bit */ | 1187 /* rounded to integers. Nearly all TrueType fonts have this bit */ |
1147 /* set, as hinting won't work really well otherwise. */ | 1188 /* set, as hinting won't work really well otherwise. */ |
1148 /* */ | 1189 /* */ |
1149 if ( face->header.Flags & 8 ) | 1190 if ( face->header.Flags & 8 ) |
1150 { | 1191 { |
1151 metrics->x_scale = FT_DivFix( metrics->x_ppem << 6, | 1192 metrics->x_scale = FT_DivFix( metrics->x_ppem << 6, |
1152 face->root.units_per_EM ); | 1193 face->root.units_per_EM ); |
1153 metrics->y_scale = FT_DivFix( metrics->y_ppem << 6, | 1194 metrics->y_scale = FT_DivFix( metrics->y_ppem << 6, |
1154 face->root.units_per_EM ); | 1195 face->root.units_per_EM ); |
1155 | 1196 |
1156 metrics->ascender = | 1197 metrics->ascender = |
1157 FT_PIX_ROUND( FT_MulFix( face->root.ascender, metrics->y_scale ) ); | 1198 FT_PIX_ROUND( FT_MulFix( face->root.ascender, metrics->y_scale ) ); |
1158 metrics->descender = | 1199 metrics->descender = |
1159 FT_PIX_ROUND( FT_MulFix( face->root.descender, metrics->y_scale ) ); | 1200 FT_PIX_ROUND( FT_MulFix( face->root.descender, metrics->y_scale ) ); |
1160 metrics->height = | 1201 metrics->height = |
1161 FT_PIX_ROUND( FT_MulFix( face->root.height, metrics->y_scale ) ); | 1202 FT_PIX_ROUND( FT_MulFix( face->root.height, metrics->y_scale ) ); |
1162 metrics->max_advance = | 1203 metrics->max_advance = |
1163 FT_PIX_ROUND( FT_MulFix( face->root.max_advance_width, | 1204 FT_PIX_ROUND( FT_MulFix( face->root.max_advance_width, |
1164 metrics->x_scale ) ); | 1205 metrics->x_scale ) ); |
1165 } | 1206 } |
1166 | 1207 |
1167 /* compute new transformation */ | 1208 /* compute new transformation */ |
1168 if ( metrics->x_ppem >= metrics->y_ppem ) | 1209 if ( metrics->x_ppem >= metrics->y_ppem ) |
1169 { | 1210 { |
1170 size->ttmetrics.scale = metrics->x_scale; | 1211 size->ttmetrics.scale = metrics->x_scale; |
1171 size->ttmetrics.ppem = metrics->x_ppem; | 1212 size->ttmetrics.ppem = metrics->x_ppem; |
1172 size->ttmetrics.x_ratio = 0x10000L; | 1213 size->ttmetrics.x_ratio = 0x10000L; |
1173 size->ttmetrics.y_ratio = FT_MulDiv( metrics->y_ppem, | 1214 size->ttmetrics.y_ratio = FT_DivFix( metrics->y_ppem, |
1174 0x10000L, | |
1175 metrics->x_ppem ); | 1215 metrics->x_ppem ); |
1176 } | 1216 } |
1177 else | 1217 else |
1178 { | 1218 { |
1179 size->ttmetrics.scale = metrics->y_scale; | 1219 size->ttmetrics.scale = metrics->y_scale; |
1180 size->ttmetrics.ppem = metrics->y_ppem; | 1220 size->ttmetrics.ppem = metrics->y_ppem; |
1181 size->ttmetrics.x_ratio = FT_MulDiv( metrics->x_ppem, | 1221 size->ttmetrics.x_ratio = FT_DivFix( metrics->x_ppem, |
1182 0x10000L, | |
1183 metrics->y_ppem ); | 1222 metrics->y_ppem ); |
1184 size->ttmetrics.y_ratio = 0x10000L; | 1223 size->ttmetrics.y_ratio = 0x10000L; |
1185 } | 1224 } |
1186 | 1225 |
1187 #ifdef TT_USE_BYTECODE_INTERPRETER | 1226 #ifdef TT_USE_BYTECODE_INTERPRETER |
1188 size->cvt_ready = 0; | 1227 size->cvt_ready = 0; |
1189 #endif /* TT_USE_BYTECODE_INTERPRETER */ | 1228 #endif /* TT_USE_BYTECODE_INTERPRETER */ |
1190 | 1229 |
1191 if ( !error ) | 1230 if ( !error ) |
1192 size->ttmetrics.valid = TRUE; | 1231 size->ttmetrics.valid = TRUE; |
(...skipping 19 matching lines...) Expand all Loading... |
1212 FT_LOCAL_DEF( FT_Error ) | 1251 FT_LOCAL_DEF( FT_Error ) |
1213 tt_driver_init( FT_Module ttdriver ) /* TT_Driver */ | 1252 tt_driver_init( FT_Module ttdriver ) /* TT_Driver */ |
1214 { | 1253 { |
1215 | 1254 |
1216 #ifdef TT_USE_BYTECODE_INTERPRETER | 1255 #ifdef TT_USE_BYTECODE_INTERPRETER |
1217 | 1256 |
1218 TT_Driver driver = (TT_Driver)ttdriver; | 1257 TT_Driver driver = (TT_Driver)ttdriver; |
1219 | 1258 |
1220 | 1259 |
1221 if ( !TT_New_Context( driver ) ) | 1260 if ( !TT_New_Context( driver ) ) |
1222 return TT_Err_Could_Not_Find_Context; | 1261 return FT_THROW( Could_Not_Find_Context ); |
1223 | 1262 |
| 1263 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING |
| 1264 driver->interpreter_version = TT_INTERPRETER_VERSION_38; |
1224 #else | 1265 #else |
| 1266 driver->interpreter_version = TT_INTERPRETER_VERSION_35; |
| 1267 #endif |
| 1268 |
| 1269 #else /* !TT_USE_BYTECODE_INTERPRETER */ |
1225 | 1270 |
1226 FT_UNUSED( ttdriver ); | 1271 FT_UNUSED( ttdriver ); |
1227 | 1272 |
1228 #endif | 1273 #endif /* !TT_USE_BYTECODE_INTERPRETER */ |
1229 | 1274 |
1230 return TT_Err_Ok; | 1275 return FT_Err_Ok; |
1231 } | 1276 } |
1232 | 1277 |
1233 | 1278 |
1234 /*************************************************************************/ | 1279 /*************************************************************************/ |
1235 /* */ | 1280 /* */ |
1236 /* <Function> */ | 1281 /* <Function> */ |
1237 /* tt_driver_done */ | 1282 /* tt_driver_done */ |
1238 /* */ | 1283 /* */ |
1239 /* <Description> */ | 1284 /* <Description> */ |
1240 /* Finalize a given TrueType driver. */ | 1285 /* Finalize a given TrueType driver. */ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 /* FreeType error code. 0 means success. */ | 1322 /* FreeType error code. 0 means success. */ |
1278 /* */ | 1323 /* */ |
1279 FT_LOCAL_DEF( FT_Error ) | 1324 FT_LOCAL_DEF( FT_Error ) |
1280 tt_slot_init( FT_GlyphSlot slot ) | 1325 tt_slot_init( FT_GlyphSlot slot ) |
1281 { | 1326 { |
1282 return FT_GlyphLoader_CreateExtra( slot->internal->loader ); | 1327 return FT_GlyphLoader_CreateExtra( slot->internal->loader ); |
1283 } | 1328 } |
1284 | 1329 |
1285 | 1330 |
1286 /* END */ | 1331 /* END */ |
OLD | NEW |