📄 pshglob.c
字号:
/* parameter to the raw bluescale value. Here is why: */ /* */ /* We need to suppress overshoots for all pointsizes. */ /* At 300dpi that satisfies: */ /* */ /* pointsize < 240*bluescale + 0.49 */ /* */ /* This corresponds to: */ /* */ /* pixelsize < 1000*bluescale + 49/24 */ /* */ /* scale*EM_Size < 1000*bluescale + 49/24 */ /* */ /* However, for normal Type 1 fonts, EM_Size is 1000! */ /* We thus only check: */ /* */ /* scale < bluescale + 49/24000 */ /* */ /* which we shorten to */ /* */ /* "scale < bluescale" */ /* */ /* Note that `blue_scale' is stored 1000 times its real */ /* value, and that `scale' converts from font units to */ /* fractional pixels. */ /* */ /* 1000 / 64 = 125 / 8 */ if ( scale >= 0x20C49BAL ) blues->no_overshoots = FT_BOOL( scale < blues->blue_scale * 8 / 125 ); else blues->no_overshoots = FT_BOOL( scale * 125 < blues->blue_scale * 8 ); /* */ /* The blue threshold is the font units distance under */ /* which overshoots are suppressed due to the BlueShift */ /* even if the scale is greater than BlueScale. */ /* */ /* It is the smallest distance such that */ /* */ /* dist <= BlueShift && dist*scale <= 0.5 pixels */ /* */ { FT_Int threshold = blues->blue_shift; while ( threshold > 0 && FT_MulFix( threshold, scale ) > 32 ) threshold--; blues->blue_threshold = threshold; } for ( num = 0; num < 4; num++ ) { PSH_Blue_Zone zone; switch ( num ) { case 0: table = &blues->normal_top; break; case 1: table = &blues->normal_bottom; break; case 2: table = &blues->family_top; break; default: table = &blues->family_bottom; break; } zone = table->zones; count = table->count; for ( ; count > 0; count--, zone++ ) { zone->cur_top = FT_MulFix( zone->org_top, scale ) + delta; zone->cur_bottom = FT_MulFix( zone->org_bottom, scale ) + delta; zone->cur_ref = FT_MulFix( zone->org_ref, scale ) + delta; zone->cur_delta = FT_MulFix( zone->org_delta, scale ); /* round scaled reference position */ zone->cur_ref = FT_PIX_ROUND( zone->cur_ref );#if 0 if ( zone->cur_ref > zone->cur_top ) zone->cur_ref -= 64; else if ( zone->cur_ref < zone->cur_bottom ) zone->cur_ref += 64;#endif } } /* process the families now */ for ( num = 0; num < 2; num++ ) { PSH_Blue_Zone zone1, zone2; FT_UInt count1, count2; PSH_Blue_Table normal, family; switch ( num ) { case 0: normal = &blues->normal_top; family = &blues->family_top; break; default: normal = &blues->normal_bottom; family = &blues->family_bottom; } zone1 = normal->zones; count1 = normal->count; for ( ; count1 > 0; count1--, zone1++ ) { /* try to find a family zone whose reference position is less */ /* than 1 pixel far from the current zone */ zone2 = family->zones; count2 = family->count; for ( ; count2 > 0; count2--, zone2++ ) { FT_Pos Delta; Delta = zone1->org_ref - zone2->org_ref; if ( Delta < 0 ) Delta = -Delta; if ( FT_MulFix( Delta, scale ) < 64 ) { zone1->cur_top = zone2->cur_top; zone1->cur_bottom = zone2->cur_bottom; zone1->cur_ref = zone2->cur_ref; zone1->cur_delta = zone2->cur_delta; break; } } } } } FT_LOCAL_DEF( void ) psh_blues_snap_stem( PSH_Blues blues, FT_Int stem_top, FT_Int stem_bot, PSH_Alignment alignment ) { PSH_Blue_Table table; FT_UInt count; FT_Pos delta; PSH_Blue_Zone zone; FT_Int no_shoots; alignment->align = PSH_BLUE_ALIGN_NONE; no_shoots = blues->no_overshoots; /* look up stem top in top zones table */ table = &blues->normal_top; count = table->count; zone = table->zones; for ( ; count > 0; count--, zone++ ) { delta = stem_top - zone->org_bottom; if ( delta < -blues->blue_fuzz ) break; if ( stem_top <= zone->org_top + blues->blue_fuzz ) { if ( no_shoots || delta <= blues->blue_threshold ) { alignment->align |= PSH_BLUE_ALIGN_TOP; alignment->align_top = zone->cur_ref; } break; } } /* look up stem bottom in bottom zones table */ table = &blues->normal_bottom; count = table->count; zone = table->zones + count-1; for ( ; count > 0; count--, zone-- ) { delta = zone->org_top - stem_bot; if ( delta < -blues->blue_fuzz ) break; if ( stem_bot >= zone->org_bottom - blues->blue_fuzz ) { if ( no_shoots || delta < blues->blue_threshold ) { alignment->align |= PSH_BLUE_ALIGN_BOT; alignment->align_bot = zone->cur_ref; } break; } } } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GLOBAL HINTS *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ static void psh_globals_destroy( PSH_Globals globals ) { if ( globals ) { FT_Memory memory; memory = globals->memory; globals->dimension[0].stdw.count = 0; globals->dimension[1].stdw.count = 0; globals->blues.normal_top.count = 0; globals->blues.normal_bottom.count = 0; globals->blues.family_top.count = 0; globals->blues.family_bottom.count = 0; FT_FREE( globals );#ifdef DEBUG_HINTER ps_debug_globals = 0;#endif } } static FT_Error psh_globals_new( FT_Memory memory, T1_Private* priv, PSH_Globals *aglobals ) { PSH_Globals globals; FT_Error error; if ( !FT_NEW( globals ) ) { FT_UInt count; FT_Short* read; globals->memory = memory; /* copy standard widths */ { PSH_Dimension dim = &globals->dimension[1]; PSH_Width write = dim->stdw.widths; write->org = priv->standard_width[0]; write++; read = priv->snap_widths; for ( count = priv->num_snap_widths; count > 0; count-- ) { write->org = *read; write++; read++; } dim->stdw.count = priv->num_snap_widths + 1; } /* copy standard heights */ { PSH_Dimension dim = &globals->dimension[0]; PSH_Width write = dim->stdw.widths; write->org = priv->standard_height[0]; write++; read = priv->snap_heights; for ( count = priv->num_snap_heights; count > 0; count-- ) { write->org = *read; write++; read++; } dim->stdw.count = priv->num_snap_heights + 1; } /* copy blue zones */ psh_blues_set_zones( &globals->blues, priv->num_blue_values, priv->blue_values, priv->num_other_blues, priv->other_blues, priv->blue_fuzz, 0 ); psh_blues_set_zones( &globals->blues, priv->num_family_blues, priv->family_blues, priv->num_family_other_blues, priv->family_other_blues, priv->blue_fuzz, 1 ); globals->blues.blue_scale = priv->blue_scale; globals->blues.blue_shift = priv->blue_shift; globals->blues.blue_fuzz = priv->blue_fuzz; globals->dimension[0].scale_mult = 0; globals->dimension[0].scale_delta = 0; globals->dimension[1].scale_mult = 0; globals->dimension[1].scale_delta = 0;#ifdef DEBUG_HINTER ps_debug_globals = globals;#endif } *aglobals = globals; return error; } FT_LOCAL_DEF( FT_Error ) psh_globals_set_scale( PSH_Globals globals, FT_Fixed x_scale, FT_Fixed y_scale, FT_Fixed x_delta, FT_Fixed y_delta ) { PSH_Dimension dim = &globals->dimension[0]; dim = &globals->dimension[0]; if ( x_scale != dim->scale_mult || x_delta != dim->scale_delta ) { dim->scale_mult = x_scale; dim->scale_delta = x_delta; psh_globals_scale_widths( globals, 0 ); } dim = &globals->dimension[1]; if ( y_scale != dim->scale_mult || y_delta != dim->scale_delta ) { dim->scale_mult = y_scale; dim->scale_delta = y_delta; psh_globals_scale_widths( globals, 1 ); psh_blues_scale_zones( &globals->blues, y_scale, y_delta ); } return 0; } FT_LOCAL_DEF( void ) psh_globals_funcs_init( PSH_Globals_FuncsRec* funcs ) { funcs->create = psh_globals_new; funcs->set_scale = psh_globals_set_scale; funcs->destroy = psh_globals_destroy; }/* END */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -