| 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-2014 by */ | 7 /* Copyright 1996-2015 by */ |
| 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 9 /* */ | 9 /* */ |
| 10 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
| 11 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
| 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
| 14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
| 15 /* */ | 15 /* */ |
| 16 /***************************************************************************/ | 16 /***************************************************************************/ |
| 17 | 17 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 if ( glyph ) | 266 if ( glyph ) |
| 267 { | 267 { |
| 268 FT_GlyphLoader loader = glyph->root.internal->loader; | 268 FT_GlyphLoader loader = glyph->root.internal->loader; |
| 269 | 269 |
| 270 | 270 |
| 271 builder->loader = loader; | 271 builder->loader = loader; |
| 272 builder->base = &loader->base.outline; | 272 builder->base = &loader->base.outline; |
| 273 builder->current = &loader->current.outline; | 273 builder->current = &loader->current.outline; |
| 274 FT_GlyphLoader_Rewind( loader ); | 274 FT_GlyphLoader_Rewind( loader ); |
| 275 | 275 |
| 276 builder->hints_globals = 0; | 276 builder->hints_globals = NULL; |
| 277 builder->hints_funcs = 0; | 277 builder->hints_funcs = NULL; |
| 278 | 278 |
| 279 if ( hinting && size ) | 279 if ( hinting && size ) |
| 280 { | 280 { |
| 281 CFF_Internal internal = (CFF_Internal)size->root.internal; | 281 CFF_Internal internal = (CFF_Internal)size->root.internal; |
| 282 | 282 |
| 283 | 283 |
| 284 builder->hints_globals = (void *)internal->topfont; | 284 builder->hints_globals = (void *)internal->topfont; |
| 285 builder->hints_funcs = glyph->root.internal->glyph_hints; | 285 builder->hints_funcs = glyph->root.internal->glyph_hints; |
| 286 } | 286 } |
| 287 } | 287 } |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 /* check range of standard char code */ | 639 /* check range of standard char code */ |
| 640 if ( charcode < 0 || charcode > 255 ) | 640 if ( charcode < 0 || charcode > 255 ) |
| 641 return -1; | 641 return -1; |
| 642 | 642 |
| 643 /* Get code to SID mapping from `cff_standard_encoding'. */ | 643 /* Get code to SID mapping from `cff_standard_encoding'. */ |
| 644 glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode ); | 644 glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode ); |
| 645 | 645 |
| 646 for ( n = 0; n < cff->num_glyphs; n++ ) | 646 for ( n = 0; n < cff->num_glyphs; n++ ) |
| 647 { | 647 { |
| 648 if ( cff->charset.sids[n] == glyph_sid ) | 648 if ( cff->charset.sids[n] == glyph_sid ) |
| 649 return n; | 649 return (FT_Int)n; |
| 650 } | 650 } |
| 651 | 651 |
| 652 return -1; | 652 return -1; |
| 653 } | 653 } |
| 654 | 654 |
| 655 | 655 |
| 656 FT_LOCAL_DEF( FT_Error ) | 656 FT_LOCAL_DEF( FT_Error ) |
| 657 cff_get_glyph_data( TT_Face face, | 657 cff_get_glyph_data( TT_Face face, |
| 658 FT_UInt glyph_index, | 658 FT_UInt glyph_index, |
| 659 FT_Byte** pointer, | 659 FT_Byte** pointer, |
| 660 FT_ULong* length ) | 660 FT_ULong* length ) |
| 661 { | 661 { |
| 662 #ifdef FT_CONFIG_OPTION_INCREMENTAL | 662 #ifdef FT_CONFIG_OPTION_INCREMENTAL |
| 663 /* For incremental fonts get the character data using the */ | 663 /* For incremental fonts get the character data using the */ |
| 664 /* callback function. */ | 664 /* callback function. */ |
| 665 if ( face->root.internal->incremental_interface ) | 665 if ( face->root.internal->incremental_interface ) |
| 666 { | 666 { |
| 667 FT_Data data; | 667 FT_Data data; |
| 668 FT_Error error = | 668 FT_Error error = |
| 669 face->root.internal->incremental_interface->funcs->get_glyph_d
ata( | 669 face->root.internal->incremental_interface->funcs->get_glyph_d
ata( |
| 670 face->root.internal->incremental_interface->object, | 670 face->root.internal->incremental_interface->object, |
| 671 glyph_index, &data ); | 671 glyph_index, &data ); |
| 672 | 672 |
| 673 | 673 |
| 674 *pointer = (FT_Byte*)data.pointer; | 674 *pointer = (FT_Byte*)data.pointer; |
| 675 *length = data.length; | 675 *length = (FT_ULong)data.length; |
| 676 | 676 |
| 677 return error; | 677 return error; |
| 678 } | 678 } |
| 679 else | 679 else |
| 680 #endif /* FT_CONFIG_OPTION_INCREMENTAL */ | 680 #endif /* FT_CONFIG_OPTION_INCREMENTAL */ |
| 681 | 681 |
| 682 { | 682 { |
| 683 CFF_Font cff = (CFF_Font)(face->extra.data); | 683 CFF_Font cff = (CFF_Font)(face->extra.data); |
| 684 | 684 |
| 685 | 685 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 700 | 700 |
| 701 #ifdef FT_CONFIG_OPTION_INCREMENTAL | 701 #ifdef FT_CONFIG_OPTION_INCREMENTAL |
| 702 /* For incremental fonts get the character data using the */ | 702 /* For incremental fonts get the character data using the */ |
| 703 /* callback function. */ | 703 /* callback function. */ |
| 704 if ( face->root.internal->incremental_interface ) | 704 if ( face->root.internal->incremental_interface ) |
| 705 { | 705 { |
| 706 FT_Data data; | 706 FT_Data data; |
| 707 | 707 |
| 708 | 708 |
| 709 data.pointer = *pointer; | 709 data.pointer = *pointer; |
| 710 data.length = length; | 710 data.length = (FT_Int)length; |
| 711 | 711 |
| 712 face->root.internal->incremental_interface->funcs->free_glyph_data( | 712 face->root.internal->incremental_interface->funcs->free_glyph_data( |
| 713 face->root.internal->incremental_interface->object, &data ); | 713 face->root.internal->incremental_interface->object, &data ); |
| 714 } | 714 } |
| 715 else | 715 else |
| 716 #endif /* FT_CONFIG_OPTION_INCREMENTAL */ | 716 #endif /* FT_CONFIG_OPTION_INCREMENTAL */ |
| 717 | 717 |
| 718 { | 718 { |
| 719 CFF_Font cff = (CFF_Font)(face->extra.data); | 719 CFF_Font cff = (CFF_Font)(face->extra.data); |
| 720 | 720 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 glyph->num_subglyphs = 2; | 812 glyph->num_subglyphs = 2; |
| 813 glyph->subglyphs = loader->base.subglyphs; | 813 glyph->subglyphs = loader->base.subglyphs; |
| 814 glyph->format = FT_GLYPH_FORMAT_COMPOSITE; | 814 glyph->format = FT_GLYPH_FORMAT_COMPOSITE; |
| 815 | 815 |
| 816 loader->current.num_subglyphs = 2; | 816 loader->current.num_subglyphs = 2; |
| 817 } | 817 } |
| 818 | 818 |
| 819 FT_GlyphLoader_Prepare( builder->loader ); | 819 FT_GlyphLoader_Prepare( builder->loader ); |
| 820 | 820 |
| 821 /* First load `bchar' in builder */ | 821 /* First load `bchar' in builder */ |
| 822 error = cff_get_glyph_data( face, bchar_index, | 822 error = cff_get_glyph_data( face, (FT_UInt)bchar_index, |
| 823 &charstring, &charstring_len ); | 823 &charstring, &charstring_len ); |
| 824 if ( !error ) | 824 if ( !error ) |
| 825 { | 825 { |
| 826 /* the seac operator must not be nested */ | 826 /* the seac operator must not be nested */ |
| 827 decoder->seac = TRUE; | 827 decoder->seac = TRUE; |
| 828 error = cff_decoder_parse_charstrings( decoder, charstring, | 828 error = cff_decoder_parse_charstrings( decoder, charstring, |
| 829 charstring_len ); | 829 charstring_len ); |
| 830 decoder->seac = FALSE; | 830 decoder->seac = FALSE; |
| 831 | 831 |
| 832 cff_free_glyph_data( face, &charstring, charstring_len ); | 832 cff_free_glyph_data( face, &charstring, charstring_len ); |
| 833 | 833 |
| 834 if ( error ) | 834 if ( error ) |
| 835 goto Exit; | 835 goto Exit; |
| 836 } | 836 } |
| 837 | 837 |
| 838 /* Save the left bearing, advance and glyph width of the base */ | 838 /* Save the left bearing, advance and glyph width of the base */ |
| 839 /* character as they will be erased by the next load. */ | 839 /* character as they will be erased by the next load. */ |
| 840 | 840 |
| 841 left_bearing = builder->left_bearing; | 841 left_bearing = builder->left_bearing; |
| 842 advance = builder->advance; | 842 advance = builder->advance; |
| 843 glyph_width = decoder->glyph_width; | 843 glyph_width = decoder->glyph_width; |
| 844 | 844 |
| 845 builder->left_bearing.x = 0; | 845 builder->left_bearing.x = 0; |
| 846 builder->left_bearing.y = 0; | 846 builder->left_bearing.y = 0; |
| 847 | 847 |
| 848 builder->pos_x = adx - asb; | 848 builder->pos_x = adx - asb; |
| 849 builder->pos_y = ady; | 849 builder->pos_y = ady; |
| 850 | 850 |
| 851 /* Now load `achar' on top of the base outline. */ | 851 /* Now load `achar' on top of the base outline. */ |
| 852 error = cff_get_glyph_data( face, achar_index, | 852 error = cff_get_glyph_data( face, (FT_UInt)achar_index, |
| 853 &charstring, &charstring_len ); | 853 &charstring, &charstring_len ); |
| 854 if ( !error ) | 854 if ( !error ) |
| 855 { | 855 { |
| 856 /* the seac operator must not be nested */ | 856 /* the seac operator must not be nested */ |
| 857 decoder->seac = TRUE; | 857 decoder->seac = TRUE; |
| 858 error = cff_decoder_parse_charstrings( decoder, charstring, | 858 error = cff_decoder_parse_charstrings( decoder, charstring, |
| 859 charstring_len ); | 859 charstring_len ); |
| 860 decoder->seac = FALSE; | 860 decoder->seac = FALSE; |
| 861 | 861 |
| 862 cff_free_glyph_data( face, &charstring, charstring_len ); | 862 cff_free_glyph_data( face, &charstring, charstring_len ); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 decoder->cff->top_font.font_dict.charstring_type; | 915 decoder->cff->top_font.font_dict.charstring_type; |
| 916 | 916 |
| 917 T2_Hints_Funcs hinter; | 917 T2_Hints_Funcs hinter; |
| 918 | 918 |
| 919 | 919 |
| 920 /* set default width */ | 920 /* set default width */ |
| 921 decoder->num_hints = 0; | 921 decoder->num_hints = 0; |
| 922 decoder->read_width = 1; | 922 decoder->read_width = 1; |
| 923 | 923 |
| 924 /* compute random seed from stack address of parameter */ | 924 /* compute random seed from stack address of parameter */ |
| 925 seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed ^ | 925 seed = (FT_Fixed)( ( (FT_Offset)(char*)&seed ^ |
| 926 (FT_PtrDist)(char*)&decoder ^ | 926 (FT_Offset)(char*)&decoder ^ |
| 927 (FT_PtrDist)(char*)&charstring_base ) & | 927 (FT_Offset)(char*)&charstring_base ) & |
| 928 FT_ULONG_MAX ) ; | 928 FT_ULONG_MAX ); |
| 929 seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL; | 929 seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL; |
| 930 if ( seed == 0 ) | 930 if ( seed == 0 ) |
| 931 seed = 0x7384; | 931 seed = 0x7384; |
| 932 | 932 |
| 933 /* initialize the decoder */ | 933 /* initialize the decoder */ |
| 934 decoder->top = decoder->stack; | 934 decoder->top = decoder->stack; |
| 935 decoder->zone = decoder->zones; | 935 decoder->zone = decoder->zones; |
| 936 zone = decoder->zones; | 936 zone = decoder->zones; |
| 937 stack = decoder->top; | 937 stack = decoder->top; |
| 938 | 938 |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 /* instruction). Additionally, there must be space for */ | 1366 /* instruction). Additionally, there must be space for */ |
| 1367 /* `num_hints' bits. */ | 1367 /* `num_hints' bits. */ |
| 1368 | 1368 |
| 1369 if ( ( ip + ( ( decoder->num_hints + 7 ) >> 3 ) ) >= limit ) | 1369 if ( ( ip + ( ( decoder->num_hints + 7 ) >> 3 ) ) >= limit ) |
| 1370 goto Syntax_Error; | 1370 goto Syntax_Error; |
| 1371 | 1371 |
| 1372 if ( hinter ) | 1372 if ( hinter ) |
| 1373 { | 1373 { |
| 1374 if ( op == cff_op_hintmask ) | 1374 if ( op == cff_op_hintmask ) |
| 1375 hinter->hintmask( hinter->hints, | 1375 hinter->hintmask( hinter->hints, |
| 1376 builder->current->n_points, | 1376 (FT_UInt)builder->current->n_points, |
| 1377 decoder->num_hints, | 1377 (FT_UInt)decoder->num_hints, |
| 1378 ip ); | 1378 ip ); |
| 1379 else | 1379 else |
| 1380 hinter->counter( hinter->hints, | 1380 hinter->counter( hinter->hints, |
| 1381 decoder->num_hints, | 1381 (FT_UInt)decoder->num_hints, |
| 1382 ip ); | 1382 ip ); |
| 1383 } | 1383 } |
| 1384 | 1384 |
| 1385 #ifdef FT_DEBUG_LEVEL_TRACE | 1385 #ifdef FT_DEBUG_LEVEL_TRACE |
| 1386 { | 1386 { |
| 1387 FT_UInt maskbyte; | 1387 FT_UInt maskbyte; |
| 1388 | 1388 |
| 1389 | 1389 |
| 1390 FT_TRACE4(( " (maskbytes:" )); | 1390 FT_TRACE4(( " (maskbytes:" )); |
| 1391 | 1391 |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 decoder->glyph_width = glyph_width; | 1988 decoder->glyph_width = glyph_width; |
| 1989 } | 1989 } |
| 1990 else | 1990 else |
| 1991 { | 1991 { |
| 1992 cff_builder_close_contour( builder ); | 1992 cff_builder_close_contour( builder ); |
| 1993 | 1993 |
| 1994 /* close hints recording session */ | 1994 /* close hints recording session */ |
| 1995 if ( hinter ) | 1995 if ( hinter ) |
| 1996 { | 1996 { |
| 1997 if ( hinter->close( hinter->hints, | 1997 if ( hinter->close( hinter->hints, |
| 1998 builder->current->n_points ) ) | 1998 (FT_UInt)builder->current->n_points ) ) |
| 1999 goto Syntax_Error; | 1999 goto Syntax_Error; |
| 2000 | 2000 |
| 2001 /* apply hints to the loaded glyph outline now */ | 2001 /* apply hints to the loaded glyph outline now */ |
| 2002 error = hinter->apply( hinter->hints, | 2002 error = hinter->apply( hinter->hints, |
| 2003 builder->current, | 2003 builder->current, |
| 2004 (PSH_Globals)builder->hints_globals, | 2004 (PSH_Globals)builder->hints_globals, |
| 2005 decoder->hint_mode ); | 2005 decoder->hint_mode ); |
| 2006 if ( error ) | 2006 if ( error ) |
| 2007 goto Fail; | 2007 goto Fail; |
| 2008 } | 2008 } |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2382 args++; | 2382 args++; |
| 2383 } | 2383 } |
| 2384 break; | 2384 break; |
| 2385 | 2385 |
| 2386 case cff_op_callsubr: | 2386 case cff_op_callsubr: |
| 2387 { | 2387 { |
| 2388 FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) + | 2388 FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) + |
| 2389 decoder->locals_bias ); | 2389 decoder->locals_bias ); |
| 2390 | 2390 |
| 2391 | 2391 |
| 2392 FT_TRACE4(( " callsubr(%d)\n", idx )); | 2392 FT_TRACE4(( " callsubr (idx %d, entering level %d)\n", |
| 2393 idx, |
| 2394 zone - decoder->zones + 1 )); |
| 2393 | 2395 |
| 2394 if ( idx >= decoder->num_locals ) | 2396 if ( idx >= decoder->num_locals ) |
| 2395 { | 2397 { |
| 2396 FT_ERROR(( "cff_decoder_parse_charstrings:" | 2398 FT_ERROR(( "cff_decoder_parse_charstrings:" |
| 2397 " invalid local subr index\n" )); | 2399 " invalid local subr index\n" )); |
| 2398 goto Syntax_Error; | 2400 goto Syntax_Error; |
| 2399 } | 2401 } |
| 2400 | 2402 |
| 2401 if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) | 2403 if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) |
| 2402 { | 2404 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2424 limit = zone->limit; | 2426 limit = zone->limit; |
| 2425 } | 2427 } |
| 2426 break; | 2428 break; |
| 2427 | 2429 |
| 2428 case cff_op_callgsubr: | 2430 case cff_op_callgsubr: |
| 2429 { | 2431 { |
| 2430 FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) + | 2432 FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) + |
| 2431 decoder->globals_bias ); | 2433 decoder->globals_bias ); |
| 2432 | 2434 |
| 2433 | 2435 |
| 2434 FT_TRACE4(( " callgsubr(%d)\n", idx )); | 2436 FT_TRACE4(( " callgsubr (idx %d, entering level %d)\n", |
| 2437 idx, |
| 2438 zone - decoder->zones + 1 )); |
| 2435 | 2439 |
| 2436 if ( idx >= decoder->num_globals ) | 2440 if ( idx >= decoder->num_globals ) |
| 2437 { | 2441 { |
| 2438 FT_ERROR(( "cff_decoder_parse_charstrings:" | 2442 FT_ERROR(( "cff_decoder_parse_charstrings:" |
| 2439 " invalid global subr index\n" )); | 2443 " invalid global subr index\n" )); |
| 2440 goto Syntax_Error; | 2444 goto Syntax_Error; |
| 2441 } | 2445 } |
| 2442 | 2446 |
| 2443 if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) | 2447 if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) |
| 2444 { | 2448 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2461 goto Syntax_Error; | 2465 goto Syntax_Error; |
| 2462 } | 2466 } |
| 2463 | 2467 |
| 2464 decoder->zone = zone; | 2468 decoder->zone = zone; |
| 2465 ip = zone->base; | 2469 ip = zone->base; |
| 2466 limit = zone->limit; | 2470 limit = zone->limit; |
| 2467 } | 2471 } |
| 2468 break; | 2472 break; |
| 2469 | 2473 |
| 2470 case cff_op_return: | 2474 case cff_op_return: |
| 2471 FT_TRACE4(( " return\n" )); | 2475 FT_TRACE4(( " return (leaving level %d)\n", |
| 2476 decoder->zone - decoder->zones )); |
| 2472 | 2477 |
| 2473 if ( decoder->zone <= decoder->zones ) | 2478 if ( decoder->zone <= decoder->zones ) |
| 2474 { | 2479 { |
| 2475 FT_ERROR(( "cff_decoder_parse_charstrings:" | 2480 FT_ERROR(( "cff_decoder_parse_charstrings:" |
| 2476 " unexpected return\n" )); | 2481 " unexpected return\n" )); |
| 2477 goto Syntax_Error; | 2482 goto Syntax_Error; |
| 2478 } | 2483 } |
| 2479 | 2484 |
| 2480 decoder->zone--; | 2485 decoder->zone--; |
| 2481 zone = decoder->zone; | 2486 zone = decoder->zone; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2662 if ( size->strike_index != 0xFFFFFFFFUL && | 2667 if ( size->strike_index != 0xFFFFFFFFUL && |
| 2663 sfnt->load_eblc && | 2668 sfnt->load_eblc && |
| 2664 ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) | 2669 ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) |
| 2665 { | 2670 { |
| 2666 TT_SBit_MetricsRec metrics; | 2671 TT_SBit_MetricsRec metrics; |
| 2667 | 2672 |
| 2668 | 2673 |
| 2669 error = sfnt->load_sbit_image( face, | 2674 error = sfnt->load_sbit_image( face, |
| 2670 size->strike_index, | 2675 size->strike_index, |
| 2671 glyph_index, | 2676 glyph_index, |
| 2672 (FT_Int)load_flags, | 2677 (FT_UInt)load_flags, |
| 2673 stream, | 2678 stream, |
| 2674 &glyph->root.bitmap, | 2679 &glyph->root.bitmap, |
| 2675 &metrics ); | 2680 &metrics ); |
| 2676 | 2681 |
| 2677 if ( !error ) | 2682 if ( !error ) |
| 2678 { | 2683 { |
| 2679 FT_Bool has_vertical_info; | 2684 FT_Bool has_vertical_info; |
| 2680 FT_UShort advance; | 2685 FT_UShort advance; |
| 2681 FT_Short dummy; | 2686 FT_Short dummy; |
| 2682 | 2687 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2713 (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 0, | 2718 (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 0, |
| 2714 glyph_index, | 2719 glyph_index, |
| 2715 &dummy, | 2720 &dummy, |
| 2716 &advance ); | 2721 &advance ); |
| 2717 glyph->root.linearHoriAdvance = advance; | 2722 glyph->root.linearHoriAdvance = advance; |
| 2718 | 2723 |
| 2719 has_vertical_info = FT_BOOL( | 2724 has_vertical_info = FT_BOOL( |
| 2720 face->vertical_info && | 2725 face->vertical_info && |
| 2721 face->vertical.number_Of_VMetrics > 0 ); | 2726 face->vertical.number_Of_VMetrics > 0 ); |
| 2722 | 2727 |
| 2723 /* get the vertical metrics from the vtmx table if we have one */ | 2728 /* get the vertical metrics from the vmtx table if we have one */ |
| 2724 if ( has_vertical_info ) | 2729 if ( has_vertical_info ) |
| 2725 { | 2730 { |
| 2726 (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 1, | 2731 (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 1, |
| 2727 glyph_index, | 2732 glyph_index, |
| 2728 &dummy, | 2733 &dummy, |
| 2729 &advance ); | 2734 &advance ); |
| 2730 glyph->root.linearVertAdvance = advance; | 2735 glyph->root.linearVertAdvance = advance; |
| 2731 } | 2736 } |
| 2732 else | 2737 else |
| 2733 { | 2738 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2750 /* return immediately if we only want the embedded bitmaps */ | 2755 /* return immediately if we only want the embedded bitmaps */ |
| 2751 if ( load_flags & FT_LOAD_SBITS_ONLY ) | 2756 if ( load_flags & FT_LOAD_SBITS_ONLY ) |
| 2752 return FT_THROW( Invalid_Argument ); | 2757 return FT_THROW( Invalid_Argument ); |
| 2753 | 2758 |
| 2754 /* 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 */ |
| 2755 /* been multiplied with the root matrix) */ | 2760 /* been multiplied with the root matrix) */ |
| 2756 | 2761 |
| 2757 /* 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 */ |
| 2758 if ( cff->num_subfonts ) | 2763 if ( cff->num_subfonts ) |
| 2759 { | 2764 { |
| 2760 FT_ULong top_upm, sub_upm; | 2765 FT_Long top_upm, sub_upm; |
| 2761 FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, | 2766 FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, |
| 2762 glyph_index ); | 2767 glyph_index ); |
| 2763 | 2768 |
| 2764 | 2769 |
| 2765 if ( fd_index >= cff->num_subfonts ) | 2770 if ( fd_index >= cff->num_subfonts ) |
| 2766 fd_index = (FT_Byte)( cff->num_subfonts - 1 ); | 2771 fd_index = (FT_Byte)( cff->num_subfonts - 1 ); |
| 2767 | 2772 |
| 2768 top_upm = cff->top_font.font_dict.units_per_em; | 2773 top_upm = (FT_Long)cff->top_font.font_dict.units_per_em; |
| 2769 sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em; | 2774 sub_upm = (FT_Long)cff->subfonts[fd_index]->font_dict.units_per_em; |
| 2770 | 2775 |
| 2771 | 2776 |
| 2772 font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix; | 2777 font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix; |
| 2773 font_offset = cff->subfonts[fd_index]->font_dict.font_offset; | 2778 font_offset = cff->subfonts[fd_index]->font_dict.font_offset; |
| 2774 | 2779 |
| 2775 if ( top_upm != sub_upm ) | 2780 if ( top_upm != sub_upm ) |
| 2776 { | 2781 { |
| 2777 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 ); |
| 2778 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 ); |
| 2779 | 2784 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2860 cff_free_glyph_data( face, &charstring, charstring_len ); | 2865 cff_free_glyph_data( face, &charstring, charstring_len ); |
| 2861 | 2866 |
| 2862 if ( error ) | 2867 if ( error ) |
| 2863 goto Glyph_Build_Finished; | 2868 goto Glyph_Build_Finished; |
| 2864 | 2869 |
| 2865 #ifdef FT_CONFIG_OPTION_INCREMENTAL | 2870 #ifdef FT_CONFIG_OPTION_INCREMENTAL |
| 2866 /* Control data and length may not be available for incremental */ | 2871 /* Control data and length may not be available for incremental */ |
| 2867 /* fonts. */ | 2872 /* fonts. */ |
| 2868 if ( face->root.internal->incremental_interface ) | 2873 if ( face->root.internal->incremental_interface ) |
| 2869 { | 2874 { |
| 2870 glyph->root.control_data = 0; | 2875 glyph->root.control_data = NULL; |
| 2871 glyph->root.control_len = 0; | 2876 glyph->root.control_len = 0; |
| 2872 } | 2877 } |
| 2873 else | 2878 else |
| 2874 #endif /* FT_CONFIG_OPTION_INCREMENTAL */ | 2879 #endif /* FT_CONFIG_OPTION_INCREMENTAL */ |
| 2875 | 2880 |
| 2876 /* We set control_data and control_len if charstrings is loaded. */ | 2881 /* We set control_data and control_len if charstrings is loaded. */ |
| 2877 /* See how charstring loads at cff_index_access_element() in */ | 2882 /* See how charstring loads at cff_index_access_element() in */ |
| 2878 /* cffload.c. */ | 2883 /* cffload.c. */ |
| 2879 { | 2884 { |
| 2880 CFF_Index csindex = &cff->charstrings_index; | 2885 CFF_Index csindex = &cff->charstrings_index; |
| 2881 | 2886 |
| 2882 | 2887 |
| 2883 if ( csindex->offsets ) | 2888 if ( csindex->offsets ) |
| 2884 { | 2889 { |
| 2885 glyph->root.control_data = csindex->bytes + | 2890 glyph->root.control_data = csindex->bytes + |
| 2886 csindex->offsets[glyph_index] - 1; | 2891 csindex->offsets[glyph_index] - 1; |
| 2887 glyph->root.control_len = charstring_len; | 2892 glyph->root.control_len = (FT_Long)charstring_len; |
| 2888 } | 2893 } |
| 2889 } | 2894 } |
| 2890 | 2895 |
| 2891 Glyph_Build_Finished: | 2896 Glyph_Build_Finished: |
| 2892 /* save new glyph tables, if no error */ | 2897 /* save new glyph tables, if no error */ |
| 2893 if ( !error ) | 2898 if ( !error ) |
| 2894 cff_builder_done( &decoder.builder ); | 2899 cff_builder_done( &decoder.builder ); |
| 2895 /* XXX: anything to do for broken glyph entry? */ | 2900 /* XXX: anything to do for broken glyph entry? */ |
| 2896 } | 2901 } |
| 2897 | 2902 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2937 glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x; | 2942 glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x; |
| 2938 glyph->root.metrics.horiAdvance = decoder.glyph_width; | 2943 glyph->root.metrics.horiAdvance = decoder.glyph_width; |
| 2939 internal->glyph_matrix = font_matrix; | 2944 internal->glyph_matrix = font_matrix; |
| 2940 internal->glyph_delta = font_offset; | 2945 internal->glyph_delta = font_offset; |
| 2941 internal->glyph_transformed = 1; | 2946 internal->glyph_transformed = 1; |
| 2942 } | 2947 } |
| 2943 else | 2948 else |
| 2944 { | 2949 { |
| 2945 FT_BBox cbox; | 2950 FT_BBox cbox; |
| 2946 FT_Glyph_Metrics* metrics = &glyph->root.metrics; | 2951 FT_Glyph_Metrics* metrics = &glyph->root.metrics; |
| 2947 FT_Vector advance; | |
| 2948 FT_Bool has_vertical_info; | 2952 FT_Bool has_vertical_info; |
| 2949 | 2953 |
| 2950 | 2954 |
| 2951 /* copy the _unscaled_ advance width */ | 2955 if ( face->horizontal.number_Of_HMetrics ) |
| 2952 metrics->horiAdvance = decoder.glyph_width; | 2956 { |
| 2953 glyph->root.linearHoriAdvance = decoder.glyph_width; | 2957 FT_Short horiBearingX = 0; |
| 2958 FT_UShort horiAdvance = 0; |
| 2959 |
| 2960 |
| 2961 ( (SFNT_Service)face->sfnt )->get_metrics( face, 0, |
| 2962 glyph_index, |
| 2963 &horiBearingX, |
| 2964 &horiAdvance ); |
| 2965 metrics->horiAdvance = horiAdvance; |
| 2966 metrics->horiBearingX = horiBearingX; |
| 2967 glyph->root.linearHoriAdvance = horiAdvance; |
| 2968 } |
| 2969 else |
| 2970 { |
| 2971 /* copy the _unscaled_ advance width */ |
| 2972 metrics->horiAdvance = decoder.glyph_width; |
| 2973 glyph->root.linearHoriAdvance = decoder.glyph_width; |
| 2974 } |
| 2975 |
| 2954 glyph->root.internal->glyph_transformed = 0; | 2976 glyph->root.internal->glyph_transformed = 0; |
| 2955 | 2977 |
| 2956 has_vertical_info = FT_BOOL( face->vertical_info && | 2978 has_vertical_info = FT_BOOL( face->vertical_info && |
| 2957 face->vertical.number_Of_VMetrics > 0 ); | 2979 face->vertical.number_Of_VMetrics > 0 ); |
| 2958 | 2980 |
| 2959 /* get the vertical metrics from the vtmx table if we have one */ | 2981 /* get the vertical metrics from the vmtx table if we have one */ |
| 2960 if ( has_vertical_info ) | 2982 if ( has_vertical_info ) |
| 2961 { | 2983 { |
| 2962 FT_Short vertBearingY = 0; | 2984 FT_Short vertBearingY = 0; |
| 2963 FT_UShort vertAdvance = 0; | 2985 FT_UShort vertAdvance = 0; |
| 2964 | 2986 |
| 2965 | 2987 |
| 2966 (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 1, | 2988 ( (SFNT_Service)face->sfnt )->get_metrics( face, 1, |
| 2967 glyph_index, | 2989 glyph_index, |
| 2968 &vertBearingY, | 2990 &vertBearingY, |
| 2969 &vertAdvance ); | 2991 &vertAdvance ); |
| 2970 metrics->vertBearingY = vertBearingY; | 2992 metrics->vertBearingY = vertBearingY; |
| 2971 metrics->vertAdvance = vertAdvance; | 2993 metrics->vertAdvance = vertAdvance; |
| 2972 } | 2994 } |
| 2973 else | 2995 else |
| 2974 { | 2996 { |
| 2975 /* make up vertical ones */ | 2997 /* make up vertical ones */ |
| 2976 if ( face->os2.version != 0xFFFFU ) | 2998 if ( face->os2.version != 0xFFFFU ) |
| 2977 metrics->vertAdvance = (FT_Pos)( face->os2.sTypoAscender - | 2999 metrics->vertAdvance = (FT_Pos)( face->os2.sTypoAscender - |
| 2978 face->os2.sTypoDescender ); | 3000 face->os2.sTypoDescender ); |
| 2979 else | 3001 else |
| 2980 metrics->vertAdvance = (FT_Pos)( face->horizontal.Ascender - | 3002 metrics->vertAdvance = (FT_Pos)( face->horizontal.Ascender - |
| 2981 face->horizontal.Descender ); | 3003 face->horizontal.Descender ); |
| 2982 } | 3004 } |
| 2983 | 3005 |
| 2984 glyph->root.linearVertAdvance = metrics->vertAdvance; | 3006 glyph->root.linearVertAdvance = metrics->vertAdvance; |
| 2985 | 3007 |
| 2986 glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; | 3008 glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; |
| 2987 | 3009 |
| 2988 glyph->root.outline.flags = 0; | 3010 glyph->root.outline.flags = 0; |
| 2989 if ( size && size->root.metrics.y_ppem < 24 ) | 3011 if ( size && size->root.metrics.y_ppem < 24 ) |
| 2990 glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION; | 3012 glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION; |
| 2991 | 3013 |
| 2992 glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL; | 3014 glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL; |
| 2993 | 3015 |
| 2994 if ( !( font_matrix.xx == 0x10000L && | 3016 /* apply the font matrix, if any */ |
| 2995 font_matrix.yy == 0x10000L && | 3017 if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L || |
| 2996 font_matrix.xy == 0 && | 3018 font_matrix.xy != 0 || font_matrix.yx != 0 ) |
| 2997 font_matrix.yx == 0 ) ) | 3019 { |
| 2998 FT_Outline_Transform( &glyph->root.outline, &font_matrix ); | 3020 FT_Outline_Transform( &glyph->root.outline, &font_matrix ); |
| 2999 | 3021 |
| 3000 if ( !( font_offset.x == 0 && | 3022 metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, |
| 3001 font_offset.y == 0 ) ) | 3023 font_matrix.xx ); |
| 3024 metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, |
| 3025 font_matrix.yy ); |
| 3026 } |
| 3027 |
| 3028 if ( font_offset.x || font_offset.y ) |
| 3029 { |
| 3002 FT_Outline_Translate( &glyph->root.outline, | 3030 FT_Outline_Translate( &glyph->root.outline, |
| 3003 font_offset.x, font_offset.y ); | 3031 font_offset.x, |
| 3032 font_offset.y ); |
| 3004 | 3033 |
| 3005 advance.x = metrics->horiAdvance; | 3034 metrics->horiAdvance += font_offset.x; |
| 3006 advance.y = 0; | 3035 metrics->vertAdvance += font_offset.y; |
| 3007 FT_Vector_Transform( &advance, &font_matrix ); | 3036 } |
| 3008 metrics->horiAdvance = advance.x + font_offset.x; | |
| 3009 | |
| 3010 advance.x = 0; | |
| 3011 advance.y = metrics->vertAdvance; | |
| 3012 FT_Vector_Transform( &advance, &font_matrix ); | |
| 3013 metrics->vertAdvance = advance.y + font_offset.y; | |
| 3014 | 3037 |
| 3015 if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling ) | 3038 if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling ) |
| 3016 { | 3039 { |
| 3017 /* scale the outline and the metrics */ | 3040 /* scale the outline and the metrics */ |
| 3018 FT_Int n; | 3041 FT_Int n; |
| 3019 FT_Outline* cur = &glyph->root.outline; | 3042 FT_Outline* cur = &glyph->root.outline; |
| 3020 FT_Vector* vec = cur->points; | 3043 FT_Vector* vec = cur->points; |
| 3021 FT_Fixed x_scale = glyph->x_scale; | 3044 FT_Fixed x_scale = glyph->x_scale; |
| 3022 FT_Fixed y_scale = glyph->y_scale; | 3045 FT_Fixed y_scale = glyph->y_scale; |
| 3023 | 3046 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3054 metrics->vertAdvance ); | 3077 metrics->vertAdvance ); |
| 3055 } | 3078 } |
| 3056 } | 3079 } |
| 3057 } | 3080 } |
| 3058 | 3081 |
| 3059 return error; | 3082 return error; |
| 3060 } | 3083 } |
| 3061 | 3084 |
| 3062 | 3085 |
| 3063 /* END */ | 3086 /* END */ |
| OLD | NEW |