OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* t1decode.c */ | 3 /* t1decode.c */ |
4 /* */ | 4 /* */ |
5 /* PostScript Type 1 decoding routines (body). */ | 5 /* PostScript Type 1 decoding routines (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 2000-2014 by */ | 7 /* Copyright 2000-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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 psnames->adobe_std_encoding[charcode]); | 143 psnames->adobe_std_encoding[charcode]); |
144 | 144 |
145 for ( n = 0; n < decoder->num_glyphs; n++ ) | 145 for ( n = 0; n < decoder->num_glyphs; n++ ) |
146 { | 146 { |
147 FT_String* name = (FT_String*)decoder->glyph_names[n]; | 147 FT_String* name = (FT_String*)decoder->glyph_names[n]; |
148 | 148 |
149 | 149 |
150 if ( name && | 150 if ( name && |
151 name[0] == glyph_name[0] && | 151 name[0] == glyph_name[0] && |
152 ft_strcmp( name, glyph_name ) == 0 ) | 152 ft_strcmp( name, glyph_name ) == 0 ) |
153 return n; | 153 return (FT_Int)n; |
154 } | 154 } |
155 | 155 |
156 return -1; | 156 return -1; |
157 } | 157 } |
158 | 158 |
159 | 159 |
160 /*************************************************************************/ | 160 /*************************************************************************/ |
161 /* */ | 161 /* */ |
162 /* <Function> */ | 162 /* <Function> */ |
163 /* t1operator_seac */ | 163 /* t1operator_seac */ |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 goto Exit; | 291 goto Exit; |
292 } | 292 } |
293 | 293 |
294 /* First load `bchar' in builder */ | 294 /* First load `bchar' in builder */ |
295 /* now load the unscaled outline */ | 295 /* now load the unscaled outline */ |
296 | 296 |
297 FT_GlyphLoader_Prepare( decoder->builder.loader ); /* prepare loader */ | 297 FT_GlyphLoader_Prepare( decoder->builder.loader ); /* prepare loader */ |
298 | 298 |
299 /* the seac operator must not be nested */ | 299 /* the seac operator must not be nested */ |
300 decoder->seac = TRUE; | 300 decoder->seac = TRUE; |
301 error = t1_decoder_parse_glyph( decoder, bchar_index ); | 301 error = t1_decoder_parse_glyph( decoder, (FT_UInt)bchar_index ); |
302 decoder->seac = FALSE; | 302 decoder->seac = FALSE; |
303 if ( error ) | 303 if ( error ) |
304 goto Exit; | 304 goto Exit; |
305 | 305 |
306 /* save the left bearing and width of the base character */ | 306 /* save the left bearing and width of the base character */ |
307 /* as they will be erased by the next load. */ | 307 /* as they will be erased by the next load. */ |
308 | 308 |
309 left_bearing = decoder->builder.left_bearing; | 309 left_bearing = decoder->builder.left_bearing; |
310 advance = decoder->builder.advance; | 310 advance = decoder->builder.advance; |
311 | 311 |
312 decoder->builder.left_bearing.x = 0; | 312 decoder->builder.left_bearing.x = 0; |
313 decoder->builder.left_bearing.y = 0; | 313 decoder->builder.left_bearing.y = 0; |
314 | 314 |
315 decoder->builder.pos_x = adx - asb; | 315 decoder->builder.pos_x = adx - asb; |
316 decoder->builder.pos_y = ady; | 316 decoder->builder.pos_y = ady; |
317 | 317 |
318 /* Now load `achar' on top of */ | 318 /* Now load `achar' on top of */ |
319 /* the base outline */ | 319 /* the base outline */ |
320 | 320 |
321 /* the seac operator must not be nested */ | 321 /* the seac operator must not be nested */ |
322 decoder->seac = TRUE; | 322 decoder->seac = TRUE; |
323 error = t1_decoder_parse_glyph( decoder, achar_index ); | 323 error = t1_decoder_parse_glyph( decoder, (FT_UInt)achar_index ); |
324 decoder->seac = FALSE; | 324 decoder->seac = FALSE; |
325 if ( error ) | 325 if ( error ) |
326 goto Exit; | 326 goto Exit; |
327 | 327 |
328 /* restore the left side bearing and */ | 328 /* restore the left side bearing and */ |
329 /* advance width of the base character */ | 329 /* advance width of the base character */ |
330 | 330 |
331 decoder->builder.left_bearing = left_bearing; | 331 decoder->builder.left_bearing = left_bearing; |
332 decoder->builder.advance = advance; | 332 decoder->builder.advance = advance; |
333 | 333 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 FT_Fixed seed; | 374 FT_Fixed seed; |
375 | 375 |
376 T1_Hints_Funcs hinter; | 376 T1_Hints_Funcs hinter; |
377 | 377 |
378 #ifdef FT_DEBUG_LEVEL_TRACE | 378 #ifdef FT_DEBUG_LEVEL_TRACE |
379 FT_Bool bol = TRUE; | 379 FT_Bool bol = TRUE; |
380 #endif | 380 #endif |
381 | 381 |
382 | 382 |
383 /* compute random seed from stack address of parameter */ | 383 /* compute random seed from stack address of parameter */ |
384 seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed ^ | 384 seed = (FT_Fixed)( ( (FT_Offset)(char*)&seed ^ |
385 (FT_PtrDist)(char*)&decoder ^ | 385 (FT_Offset)(char*)&decoder ^ |
386 (FT_PtrDist)(char*)&charstring_base ) & | 386 (FT_Offset)(char*)&charstring_base ) & |
387 FT_ULONG_MAX ) ; | 387 FT_ULONG_MAX ); |
388 seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL; | 388 seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL; |
389 if ( seed == 0 ) | 389 if ( seed == 0 ) |
390 seed = 0x7384; | 390 seed = 0x7384; |
391 | 391 |
392 /* First of all, initialize the decoder */ | 392 /* First of all, initialize the decoder */ |
393 decoder->top = decoder->stack; | 393 decoder->top = decoder->stack; |
394 decoder->zone = decoder->zones; | 394 decoder->zone = decoder->zones; |
395 zone = decoder->zones; | 395 zone = decoder->zones; |
396 | 396 |
397 builder->parse_state = T1_Parse_Start; | 397 builder->parse_state = T1_Parse_Start; |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 } | 789 } |
790 break; | 790 break; |
791 | 791 |
792 case 3: /* change hints */ | 792 case 3: /* change hints */ |
793 if ( arg_cnt != 1 ) | 793 if ( arg_cnt != 1 ) |
794 goto Unexpected_OtherSubr; | 794 goto Unexpected_OtherSubr; |
795 | 795 |
796 known_othersubr_result_cnt = 1; | 796 known_othersubr_result_cnt = 1; |
797 | 797 |
798 if ( hinter ) | 798 if ( hinter ) |
799 hinter->reset( hinter->hints, builder->current->n_points ); | 799 hinter->reset( hinter->hints, |
| 800 (FT_UInt)builder->current->n_points ); |
800 break; | 801 break; |
801 | 802 |
802 case 12: | 803 case 12: |
803 case 13: | 804 case 13: |
804 /* counter control hints, clear stack */ | 805 /* counter control hints, clear stack */ |
805 top = decoder->stack; | 806 top = decoder->stack; |
806 break; | 807 break; |
807 | 808 |
808 case 14: | 809 case 14: |
809 case 15: | 810 case 15: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 { | 855 { |
855 FT_Long tmp = values[0]; | 856 FT_Long tmp = values[0]; |
856 | 857 |
857 | 858 |
858 for ( mm = 1; mm < blend->num_designs; mm++ ) | 859 for ( mm = 1; mm < blend->num_designs; mm++ ) |
859 tmp += FT_MulFix( *delta++, blend->weight_vector[mm] ); | 860 tmp += FT_MulFix( *delta++, blend->weight_vector[mm] ); |
860 | 861 |
861 *values++ = tmp; | 862 *values++ = tmp; |
862 } | 863 } |
863 | 864 |
864 known_othersubr_result_cnt = num_points; | 865 known_othersubr_result_cnt = (FT_Int)num_points; |
865 break; | 866 break; |
866 } | 867 } |
867 | 868 |
868 case 19: | 869 case 19: |
869 /* <idx> 1 19 callothersubr */ | 870 /* <idx> 1 19 callothersubr */ |
870 /* => replace elements starting from index cvi( <idx> ) */ | 871 /* => replace elements starting from index cvi( <idx> ) */ |
871 /* of BuildCharArray with WeightVector */ | 872 /* of BuildCharArray with WeightVector */ |
872 { | 873 { |
873 FT_Int idx; | 874 FT_Int idx; |
874 PS_Blend blend = decoder->blend; | 875 PS_Blend blend = decoder->blend; |
875 | 876 |
876 | 877 |
877 if ( arg_cnt != 1 || blend == NULL ) | 878 if ( arg_cnt != 1 || blend == NULL ) |
878 goto Unexpected_OtherSubr; | 879 goto Unexpected_OtherSubr; |
879 | 880 |
880 idx = Fix2Int( top[0] ); | 881 idx = Fix2Int( top[0] ); |
881 | 882 |
882 if ( idx < 0 || | 883 if ( idx < 0 || |
883 idx + blend->num_designs > decoder->len_buildchar ) | 884 (FT_UInt)idx + blend->num_designs > decoder->len_buildchar ) |
884 goto Unexpected_OtherSubr; | 885 goto Unexpected_OtherSubr; |
885 | 886 |
886 ft_memcpy( &decoder->buildchar[idx], | 887 ft_memcpy( &decoder->buildchar[idx], |
887 blend->weight_vector, | 888 blend->weight_vector, |
888 blend->num_designs * | 889 blend->num_designs * |
889 sizeof ( blend->weight_vector[0] ) ); | 890 sizeof ( blend->weight_vector[0] ) ); |
890 } | 891 } |
891 break; | 892 break; |
892 | 893 |
893 case 20: | 894 case 20: |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 switch ( op ) | 1088 switch ( op ) |
1088 { | 1089 { |
1089 case op_endchar: | 1090 case op_endchar: |
1090 FT_TRACE4(( " endchar\n" )); | 1091 FT_TRACE4(( " endchar\n" )); |
1091 | 1092 |
1092 t1_builder_close_contour( builder ); | 1093 t1_builder_close_contour( builder ); |
1093 | 1094 |
1094 /* close hints recording session */ | 1095 /* close hints recording session */ |
1095 if ( hinter ) | 1096 if ( hinter ) |
1096 { | 1097 { |
1097 if ( hinter->close( hinter->hints, builder->current->n_points ) ) | 1098 if ( hinter->close( hinter->hints, |
| 1099 (FT_UInt)builder->current->n_points ) ) |
1098 goto Syntax_Error; | 1100 goto Syntax_Error; |
1099 | 1101 |
1100 /* apply hints to the loaded glyph outline now */ | 1102 /* apply hints to the loaded glyph outline now */ |
1101 error = hinter->apply( hinter->hints, | 1103 error = hinter->apply( hinter->hints, |
1102 builder->current, | 1104 builder->current, |
1103 (PSH_Globals)builder->hints_globals, | 1105 (PSH_Globals)builder->hints_globals, |
1104 decoder->hint_mode ); | 1106 decoder->hint_mode ); |
1105 if ( error ) | 1107 if ( error ) |
1106 goto Fail; | 1108 goto Fail; |
1107 } | 1109 } |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 break; | 1341 break; |
1340 | 1342 |
1341 case op_callsubr: | 1343 case op_callsubr: |
1342 { | 1344 { |
1343 FT_Int idx; | 1345 FT_Int idx; |
1344 | 1346 |
1345 | 1347 |
1346 FT_TRACE4(( " callsubr" )); | 1348 FT_TRACE4(( " callsubr" )); |
1347 | 1349 |
1348 idx = Fix2Int( top[0] ); | 1350 idx = Fix2Int( top[0] ); |
1349 if ( idx < 0 || idx >= (FT_Int)decoder->num_subrs ) | 1351 if ( idx < 0 || idx >= decoder->num_subrs ) |
1350 { | 1352 { |
1351 FT_ERROR(( "t1_decoder_parse_charstrings:" | 1353 FT_ERROR(( "t1_decoder_parse_charstrings:" |
1352 " invalid subrs index\n" )); | 1354 " invalid subrs index\n" )); |
1353 goto Syntax_Error; | 1355 goto Syntax_Error; |
1354 } | 1356 } |
1355 | 1357 |
1356 if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS ) | 1358 if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS ) |
1357 { | 1359 { |
1358 FT_ERROR(( "t1_decoder_parse_charstrings:" | 1360 FT_ERROR(( "t1_decoder_parse_charstrings:" |
1359 " too many nested subrs\n" )); | 1361 " too many nested subrs\n" )); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 FT_Byte** glyph_names, | 1574 FT_Byte** glyph_names, |
1573 PS_Blend blend, | 1575 PS_Blend blend, |
1574 FT_Bool hinting, | 1576 FT_Bool hinting, |
1575 FT_Render_Mode hint_mode, | 1577 FT_Render_Mode hint_mode, |
1576 T1_Decoder_Callback parse_callback ) | 1578 T1_Decoder_Callback parse_callback ) |
1577 { | 1579 { |
1578 FT_MEM_ZERO( decoder, sizeof ( *decoder ) ); | 1580 FT_MEM_ZERO( decoder, sizeof ( *decoder ) ); |
1579 | 1581 |
1580 /* retrieve PSNames interface from list of current modules */ | 1582 /* retrieve PSNames interface from list of current modules */ |
1581 { | 1583 { |
1582 FT_Service_PsCMaps psnames = 0; | 1584 FT_Service_PsCMaps psnames; |
1583 | 1585 |
1584 | 1586 |
1585 FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); | 1587 FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); |
1586 if ( !psnames ) | 1588 if ( !psnames ) |
1587 { | 1589 { |
1588 FT_ERROR(( "t1_decoder_init:" | 1590 FT_ERROR(( "t1_decoder_init:" |
1589 " the `psnames' module is not available\n" )); | 1591 " the `psnames' module is not available\n" )); |
1590 return FT_THROW( Unimplemented_Feature ); | 1592 return FT_THROW( Unimplemented_Feature ); |
1591 } | 1593 } |
1592 | 1594 |
(...skipping 20 matching lines...) Expand all Loading... |
1613 | 1615 |
1614 /* finalize T1 decoder */ | 1616 /* finalize T1 decoder */ |
1615 FT_LOCAL_DEF( void ) | 1617 FT_LOCAL_DEF( void ) |
1616 t1_decoder_done( T1_Decoder decoder ) | 1618 t1_decoder_done( T1_Decoder decoder ) |
1617 { | 1619 { |
1618 t1_builder_done( &decoder->builder ); | 1620 t1_builder_done( &decoder->builder ); |
1619 } | 1621 } |
1620 | 1622 |
1621 | 1623 |
1622 /* END */ | 1624 /* END */ |
OLD | NEW |