/* fuzz-expands the zones as well. */ static void psh_blues_set_zones( PSH_Blues target, FT_UInt count, FT_Short* blues, FT_UInt count_others, FT_Short* other_blues, FT_Int fuzz, FT_Int family ) { PSH_Blue_Table top_table, bot_table; FT_Int count_top, count_bot; if ( family ) { top_table = &target->family_top; bot_table = &target->family_bottom; } else { top_table = &target->normal_top; bot_table = &target->normal_bottom; } /* read the input blue zones, and build two sorted tables */ /* (one for the top zones, the other for the bottom zones) */ top_table->count = 0; bot_table->count = 0; /* first, the blues */ psh_blues_set_zones_0( target, 0, count, blues, top_table, bot_table ); psh_blues_set_zones_0( target, 1, count_others, other_blues, top_table, bot_table ); count_top = top_table->count; count_bot = bot_table->count; /* sanitize top table */ if ( count_top > 0 ) { PSH_Blue_Zone zone = top_table->zones; for ( count = count_top; count > 0; count--, zone++ ) { FT_Int delta; if ( count > 1 ) { delta = zone[1].org_ref - zone[0].org_ref; if ( zone->org_delta > delta ) zone->org_delta = delta; } zone->org_bottom = zone->org_ref; zone->org_top = zone->org_delta + zone->org_ref; } } /* sanitize bottom table */ if ( count_bot > 0 ) { PSH_Blue_Zone zone = bot_table->zones; for ( count = count_bot; count > 0; count--, zone++ ) { FT_Int delta; if ( count > 1 ) { delta = zone[0].org_ref - zone[1].org_ref; if ( zone->org_delta < delta ) zone->org_delta = delta; } zone->org_top = zone->org_ref; zone->org_bottom = zone->org_delta + zone->org_ref; } } /* expand top and bottom tables with blue fuzz */ { FT_Int dim, top, bot, delta; PSH_Blue_Zone zone; zone = top_table->zones; count = count_top; for ( dim = 1; dim >= 0; dim-- ) { if ( count > 0 ) { /* expand the bottom of the lowest zone normally */ zone->org_bottom -= fuzz; /* expand the top and bottom of intermediate zones; */ /* checking that the interval is smaller than the fuzz */ top = zone->org_top; for ( count--; count > 0; count-- ) { bot = zone[1].org_bottom; delta = bot - top; if ( delta < 2 * fuzz ) zone[0].org_top = zone[1].org_bottom = top + delta / 2; else { zone[0].org_top = top + fuzz; zone[1].org_bottom = bot - fuzz; } zone++; top = zone->org_top; } /* expand the top of the highest zone normally */ zone->org_top = top + fuzz; } zone = bot_table->zones; count = count_bot; } } }
/* fuzz-expands the zones as well. */ static void psh_blues_set_zones( PSH_Blues target, FT_UInt count, FT_Short* blues, FT_UInt count_others, FT_Short* other_blues, FT_Int fuzz, FT_Int family ) { PSH_Blue_Table top_table, bot_table; FT_Int count_top, count_bot; if ( family ) { top_table = &target->family_top; bot_table = &target->family_bottom; } else { top_table = &target->normal_top; bot_table = &target->normal_bottom; } /* read the input blue zones, and build two sorted tables */ /* (one for the top zones, the other for the bottom zones) */ top_table->count = 0; bot_table->count = 0; /* first, the blues */ psh_blues_set_zones_0( target, 0, count, blues, top_table, bot_table ); psh_blues_set_zones_0( target, 1, count_others, other_blues, top_table, bot_table ); count_top = top_table->count; count_bot = bot_table->count; /* sanitize top table */ if ( count_top > 0 ) { PSH_Blue_Zone zone = top_table->zones; for ( count = count_top; count > 0; count--, zone++ ) { FT_Int delta; if ( count > 1 ) { delta = zone[1].org_ref - zone[0].org_ref; if ( zone->org_delta > delta ) zone->org_delta = delta; } zone->org_bottom = zone->org_ref; zone->org_top = zone->org_delta + zone->org_ref; } } /* sanitize bottom table */ if ( count_bot > 0 ) { PSH_Blue_Zone zone = bot_table->zones; for ( count = count_bot; count > 0; count--, zone++ ) { FT_Int delta; if ( count > 1 ) { delta = zone[0].org_ref - zone[1].org_ref; if ( zone->org_delta < delta ) zone->org_delta = delta; } zone->org_top = zone->org_ref; zone->org_bottom = zone->org_delta + zone->org_ref; // XYQ 2006-3-11: FT PS hinter doesn't process wide zone well (all points shrinked to one horizontal line) // therefore, we have to do some nasty thing here, because some fonts do give wide bottom zones. // Our principle is to preserve the bottom line // TEST DOC: bug#395 csl.pdf letters "y", "j", etc. if (zone->org_top - zone->org_bottom > 10) { zone->org_top = zone->org_bottom; zone->org_delta = 0; } } } /* expand top and bottom tables with blue fuzz */ { FT_Int dim, top, bot, delta; PSH_Blue_Zone zone; zone = top_table->zones; count = count_top; for ( dim = 1; dim >= 0; dim-- ) { if ( count > 0 ) { /* expand the bottom of the lowest zone normally */ zone->org_bottom -= fuzz; /* expand the top and bottom of intermediate zones; */ /* checking that the interval is smaller than the fuzz */ top = zone->org_top; for ( count--; count > 0; count-- ) { bot = zone[1].org_bottom; delta = bot - top; if ( delta < 2 * fuzz ) zone[0].org_top = zone[1].org_bottom = top + delta / 2; else { zone[0].org_top = top + fuzz; zone[1].org_bottom = bot - fuzz; } zone++; top = zone->org_top; } /* expand the top of the highest zone normally */ zone->org_top = top + fuzz; } zone = bot_table->zones; count = count_bot; } } }