@ -97,11 +97,13 @@
AF_FaceGlobals globals = loader - > globals ;
AF_WritingSystemClass writing_system_class ;
FT_Size_Metrics * size_metrics = & face - > size - > internal - > autohint_metrics ;
FT_Pos stdVW = 0 ;
FT_Pos stdHW = 0 ;
FT_Bool size_changed = face - > size - > metrics . x_ppem
! = globals - > stem_darkening_for_ppem ;
FT_Bool size_changed = size_metrics - > x_ppem ! =
globals - > stem_darkening_for_ppem ;
FT_Fixed em_size = af_intToFixed ( face - > units_per_EM ) ;
FT_Fixed em_ratio = FT_DivFix ( af_intToFixed ( 1000 ) , em_size ) ;
@ -145,11 +147,11 @@
face ,
stdVW ) ) ;
darken_x = FT_DivFix ( FT_MulFix ( darken_by_font_units_x ,
face - > size - > metrics . x_scale ) ,
size_metrics - > x_scale ) ,
em_ratio ) ;
globals - > standard_vertical_width = stdVW ;
globals - > stem_darkening_for_ppem = face - > size - > metrics . x_ppem ;
globals - > stem_darkening_for_ppem = size_metrics - > x_ppem ;
globals - > darken_x = af_fixedToInt ( darken_x ) ;
}
@ -164,11 +166,11 @@
face ,
stdHW ) ) ;
darken_y = FT_DivFix ( FT_MulFix ( darken_by_font_units_y ,
face - > size - > metrics . y_scale ) ,
size_metrics - > y_scale ) ,
em_ratio ) ;
globals - > standard_horizontal_width = stdHW ;
globals - > stem_darkening_for_ppem = face - > size - > metrics . x_ppem ;
globals - > stem_darkening_for_ppem = size_metrics - > x_ppem ;
globals - > darken_y = af_fixedToInt ( darken_y ) ;
/*
@ -217,10 +219,11 @@
{
FT_Error error ;
FT_Size size = face - > size ;
FT_GlyphSlot slot = face - > glyph ;
FT_Slot_Internal internal = slot - > internal ;
FT_GlyphLoader gloader = internal - > loader ;
FT_Size size = face - > size ;
FT_Size_Internal size_internal = size - > internal ;
FT_GlyphSlot slot = face - > glyph ;
FT_Slot_Internal slot_internal = slot - > internal ;
FT_GlyphLoader gloader = slot_internal - > loader ;
AF_GlyphHints hints = loader - > hints ;
AF_ScalerRec scaler ;
@ -239,6 +242,44 @@
FT_ZERO ( & scaler ) ;
if ( ! size_internal - > autohint_metrics . x_scale | |
size_internal - > autohint_mode ! = FT_LOAD_TARGET_MODE ( load_flags ) )
{
/* switching between LIGHT and SLIGHT (and vice versa) usually means */
/* different scaling values; this later on enforces recomputation of */
/* everything related to the current size */
size_internal - > autohint_mode = FT_LOAD_TARGET_MODE ( load_flags ) ;
size_internal - > autohint_metrics = size - > metrics ;
if ( size_internal - > autohint_mode ! = FT_RENDER_MODE_SLIGHT )
{
FT_Size_Metrics * size_metrics = & size_internal - > autohint_metrics ;
/* set metrics to integer values and adjust scaling accordingly; */
/* this is the same setup as with TrueType fonts, cf. function */
/* `tt_size_reset' in file `ttobjs.c' */
size_metrics - > ascender = FT_PIX_ROUND (
FT_MulFix ( face - > ascender ,
size_metrics - > y_scale ) ) ;
size_metrics - > descender = FT_PIX_ROUND (
FT_MulFix ( face - > descender ,
size_metrics - > y_scale ) ) ;
size_metrics - > height = FT_PIX_ROUND (
FT_MulFix ( face - > height ,
size_metrics - > y_scale ) ) ;
size_metrics - > x_scale = FT_DivFix ( size_metrics - > x_ppem < < 6 ,
face - > units_per_EM ) ;
size_metrics - > y_scale = FT_DivFix ( size_metrics - > y_ppem < < 6 ,
face - > units_per_EM ) ;
size_metrics - > max_advance = FT_PIX_ROUND (
FT_MulFix ( face - > max_advance_width ,
size_metrics - > x_scale ) ) ;
}
}
/*
* TODO : This code currently doesn ' t support fractional advance widths ,
* i . e . , placing hinted glyphs at anything other than integer
@ -249,9 +290,9 @@
* values of the scaler would need to be adjusted .
*/
scaler . face = face ;
scaler . x_scale = size - > metrics . x_scale ;
scaler . x_scale = size_internal - > autohint_ metrics. x_scale ;
scaler . x_delta = 0 ;
scaler . y_scale = size - > metrics . y_scale ;
scaler . y_scale = size_internal - > autohint_ metrics. y_scale ;
scaler . y_delta = 0 ;
scaler . render_mode = FT_LOAD_TARGET_MODE ( load_flags ) ;
@ -339,21 +380,22 @@
*
*/
/* stem darkening only works well in `light' mode */
if ( scaler . render_mode = = FT_RENDER_MODE_LIGHT & &
/* stem darkening only works well in `light' and `slight' modes */
if ( ( scaler . render_mode = = FT_RENDER_MODE_LIGHT | |
scaler . render_mode = = FT_RENDER_MODE_SLIGHT ) & &
( ! face - > internal - > no_stem_darkening | |
( face - > internal - > no_stem_darkening < 0 & &
! module - > no_stem_darkening ) ) )
! module - > no_stem_darkening ) ) )
af_loader_embolden_glyph_in_slot ( loader , face , style_metrics ) ;
loader - > transformed = internal - > glyph_transformed ;
loader - > transformed = slot_ internal- > glyph_transformed ;
if ( loader - > transformed )
{
FT_Matrix inverse ;
loader - > trans_matrix = internal - > glyph_matrix ;
loader - > trans_delta = internal - > glyph_delta ;
loader - > trans_matrix = slot_ internal- > glyph_matrix ;
loader - > trans_delta = slot_ internal- > glyph_delta ;
inverse = loader - > trans_matrix ;
if ( ! FT_Matrix_Invert ( & inverse ) )
@ -391,7 +433,8 @@
/* we now need to adjust the metrics according to the change in */
/* width/positioning that occurred during the hinting process */
if ( scaler . render_mode ! = FT_RENDER_MODE_LIGHT )
if ( scaler . render_mode ! = FT_RENDER_MODE_LIGHT & &
scaler . render_mode ! = FT_RENDER_MODE_SLIGHT )
{
FT_Pos old_rsb , old_lsb , new_lsb ;
FT_Pos pp1x_uh , pp2x_uh ;
@ -448,7 +491,10 @@
slot - > rsb_delta = loader - > pp2 . x - pp2x ;
}
}
else
/* `light' mode uses integer advance widths */
/* (but sets `lsb_delta' and `rsb_delta'), */
/* `slight' mode uses fractional values */
else if ( scaler . render_mode = = FT_RENDER_MODE_LIGHT )
{
FT_Pos pp1x = loader - > pp1 . x ;
FT_Pos pp2x = loader - > pp2 . x ;
@ -460,6 +506,11 @@
slot - > lsb_delta = loader - > pp1 . x - pp1x ;
slot - > rsb_delta = loader - > pp2 . x - pp2x ;
}
else
{
slot - > lsb_delta = 0 ;
slot - > rsb_delta = 0 ;
}
break ;
@ -510,6 +561,7 @@
/* to keep the original rounded advance width; ditto for */
/* digits if all have the same advance width */
if ( scaler . render_mode ! = FT_RENDER_MODE_LIGHT & &
scaler . render_mode ! = FT_RENDER_MODE_SLIGHT & &
( FT_IS_FIXED_WIDTH ( slot - > face ) | |
( af_face_globals_is_digit ( loader - > globals , glyph_index ) & &
style_metrics - > digits_have_same_width ) ) )
@ -533,7 +585,8 @@
slot - > metrics . vertAdvance = FT_MulFix ( slot - > metrics . vertAdvance ,
style_metrics - > scaler . y_scale ) ;
slot - > metrics . horiAdvance = FT_PIX_ROUND ( slot - > metrics . horiAdvance ) ;
if ( scaler . render_mode ! = FT_RENDER_MODE_SLIGHT )
slot - > metrics . horiAdvance = FT_PIX_ROUND ( slot - > metrics . horiAdvance ) ;
slot - > metrics . vertAdvance = FT_PIX_ROUND ( slot - > metrics . vertAdvance ) ;
slot - > format = FT_GLYPH_FORMAT_OUTLINE ;