OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* pshglob.c */ | 3 /* pshglob.c */ |
4 /* */ | 4 /* */ |
5 /* PostScript hinter global hinting management (body). */ | 5 /* PostScript hinter global hinting management (body). */ |
6 /* Inspired by the new auto-hinter module. */ | 6 /* Inspired by the new auto-hinter module. */ |
7 /* */ | 7 /* */ |
8 /* Copyright 2001, 2002, 2003, 2004, 2006, 2010 by */ | 8 /* Copyright 2001-2004, 2006, 2010, 2012 by */ |
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
10 /* */ | 10 /* */ |
11 /* This file is part of the FreeType project, and may only be used */ | 11 /* This file is part of the FreeType project, and may only be used */ |
12 /* modified and distributed under the terms of the FreeType project */ | 12 /* modified and distributed under the terms of the FreeType project */ |
13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
14 /* this file you indicate that you have read the license and */ | 14 /* this file you indicate that you have read the license and */ |
15 /* understand and accept it fully. */ | 15 /* understand and accept it fully. */ |
16 /* */ | 16 /* */ |
17 /***************************************************************************/ | 17 /***************************************************************************/ |
18 | 18 |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 zone1->cur_ref = zone2->cur_ref; | 515 zone1->cur_ref = zone2->cur_ref; |
516 zone1->cur_delta = zone2->cur_delta; | 516 zone1->cur_delta = zone2->cur_delta; |
517 break; | 517 break; |
518 } | 518 } |
519 } | 519 } |
520 } | 520 } |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 | 524 |
| 525 /* calculate the maximum height of given blue zones */ |
| 526 static FT_Short |
| 527 psh_calc_max_height( FT_UInt num, |
| 528 const FT_Short* values, |
| 529 FT_Short cur_max ) |
| 530 { |
| 531 FT_UInt count; |
| 532 |
| 533 |
| 534 for ( count = 0; count < num; count += 2 ) |
| 535 { |
| 536 FT_Short cur_height = values[count + 1] - values[count]; |
| 537 |
| 538 |
| 539 if ( cur_height > cur_max ) |
| 540 cur_max = cur_height; |
| 541 } |
| 542 |
| 543 return cur_max; |
| 544 } |
| 545 |
| 546 |
525 FT_LOCAL_DEF( void ) | 547 FT_LOCAL_DEF( void ) |
526 psh_blues_snap_stem( PSH_Blues blues, | 548 psh_blues_snap_stem( PSH_Blues blues, |
527 FT_Int stem_top, | 549 FT_Int stem_top, |
528 FT_Int stem_bot, | 550 FT_Int stem_bot, |
529 PSH_Alignment alignment ) | 551 PSH_Alignment alignment ) |
530 { | 552 { |
531 PSH_Blue_Table table; | 553 PSH_Blue_Table table; |
532 FT_UInt count; | 554 FT_UInt count; |
533 FT_Pos delta; | 555 FT_Pos delta; |
534 PSH_Blue_Zone zone; | 556 PSH_Blue_Zone zone; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 | 699 |
678 /* copy blue zones */ | 700 /* copy blue zones */ |
679 psh_blues_set_zones( &globals->blues, priv->num_blue_values, | 701 psh_blues_set_zones( &globals->blues, priv->num_blue_values, |
680 priv->blue_values, priv->num_other_blues, | 702 priv->blue_values, priv->num_other_blues, |
681 priv->other_blues, priv->blue_fuzz, 0 ); | 703 priv->other_blues, priv->blue_fuzz, 0 ); |
682 | 704 |
683 psh_blues_set_zones( &globals->blues, priv->num_family_blues, | 705 psh_blues_set_zones( &globals->blues, priv->num_family_blues, |
684 priv->family_blues, priv->num_family_other_blues, | 706 priv->family_blues, priv->num_family_other_blues, |
685 priv->family_other_blues, priv->blue_fuzz, 1 ); | 707 priv->family_other_blues, priv->blue_fuzz, 1 ); |
686 | 708 |
687 globals->blues.blue_scale = priv->blue_scale; | 709 /* limit the BlueScale value to `1 / max_of_blue_zone_heights' */ |
| 710 { |
| 711 FT_Fixed max_scale; |
| 712 FT_Short max_height = 1; |
| 713 |
| 714 |
| 715 max_height = psh_calc_max_height( priv->num_blue_values, |
| 716 priv->blue_values, |
| 717 max_height ); |
| 718 max_height = psh_calc_max_height( priv->num_other_blues, |
| 719 priv->other_blues, |
| 720 max_height ); |
| 721 max_height = psh_calc_max_height( priv->num_family_blues, |
| 722 priv->family_blues, |
| 723 max_height ); |
| 724 max_height = psh_calc_max_height( priv->num_family_other_blues, |
| 725 priv->family_other_blues, |
| 726 max_height ); |
| 727 |
| 728 /* BlueScale is scaled 1000 times */ |
| 729 max_scale = FT_DivFix( 1000, max_height ); |
| 730 globals->blues.blue_scale = priv->blue_scale < max_scale |
| 731 ? priv->blue_scale |
| 732 : max_scale; |
| 733 } |
| 734 |
688 globals->blues.blue_shift = priv->blue_shift; | 735 globals->blues.blue_shift = priv->blue_shift; |
689 globals->blues.blue_fuzz = priv->blue_fuzz; | 736 globals->blues.blue_fuzz = priv->blue_fuzz; |
690 | 737 |
691 globals->dimension[0].scale_mult = 0; | 738 globals->dimension[0].scale_mult = 0; |
692 globals->dimension[0].scale_delta = 0; | 739 globals->dimension[0].scale_delta = 0; |
693 globals->dimension[1].scale_mult = 0; | 740 globals->dimension[1].scale_mult = 0; |
694 globals->dimension[1].scale_delta = 0; | 741 globals->dimension[1].scale_delta = 0; |
695 | 742 |
696 #ifdef DEBUG_HINTER | 743 #ifdef DEBUG_HINTER |
697 ps_debug_globals = globals; | 744 ps_debug_globals = globals; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 FT_LOCAL_DEF( void ) | 788 FT_LOCAL_DEF( void ) |
742 psh_globals_funcs_init( PSH_Globals_FuncsRec* funcs ) | 789 psh_globals_funcs_init( PSH_Globals_FuncsRec* funcs ) |
743 { | 790 { |
744 funcs->create = psh_globals_new; | 791 funcs->create = psh_globals_new; |
745 funcs->set_scale = psh_globals_set_scale; | 792 funcs->set_scale = psh_globals_set_scale; |
746 funcs->destroy = psh_globals_destroy; | 793 funcs->destroy = psh_globals_destroy; |
747 } | 794 } |
748 | 795 |
749 | 796 |
750 /* END */ | 797 /* END */ |
OLD | NEW |