diff --git a/ChangeLog b/ChangeLog index 540887076..5a1b3ac3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,25 @@ +2016-12-15 Werner Lemberg + Dave Arnold + + [truetype] Provide HVAR advance width variation as a service. + + Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT. + + * src/truetype/ttdriver.c (tt_service_metrics_variations): Updated. + + * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Prevent + double adjustment of advance width. + + * src/sfnt/ttmtx.c: Include FT_SERVICE_METRICS_VARIATIONS_H. + (tt_face_get_metrics): Apply metrics variations. + 2016-12-15 Dave Arnold Werner Lemberg [truetype] Provide function to apply `HVAR' advance width variation. + Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT. + * src/truetype/ttgxvar.c (tt_hadvance_adjust): New function. * src/truetype/ttgxvar.h: Updated. @@ -16,6 +33,8 @@ Activation of the code follows in another commit. + Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT. + * include/freetype/ftmm.h (FT_Var_Named_Style): Add `psid' member. * src/truetype/ttgxvar.h (GX_HVarData, GX_AxisCoords, GX_HVarRegion, diff --git a/src/sfnt/ttmtx.c b/src/sfnt/ttmtx.c index 186f873da..117a1c8ea 100644 --- a/src/sfnt/ttmtx.c +++ b/src/sfnt/ttmtx.c @@ -20,6 +20,11 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TAGS_H + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include FT_SERVICE_METRICS_VARIATIONS_H +#endif + #include "ttmtx.h" #include "sferrors.h" @@ -214,6 +219,11 @@ FT_ULong table_pos, table_size, table_end; FT_UShort k; +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Service_MetricsVariations var = + (FT_Service_MetricsVariations)face->var; +#endif + if ( vertical ) { @@ -274,6 +284,34 @@ *abearing = 0; *aadvance = 0; } + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + if ( var ) + { + FT_Face f = FT_FACE( face ); + FT_Int a = (FT_Int)*aadvance; + FT_Int b = (FT_Int)*abearing; + + + if ( vertical ) + { + if ( var->vadvance_adjust ) + var->vadvance_adjust( f, gindex, &a ); + if ( var->tsb_adjust ) + var->tsb_adjust( f, gindex, &b ); + } + else + { + if ( var->hadvance_adjust ) + var->hadvance_adjust( f, gindex, &a ); + if ( var->lsb_adjust ) + var->lsb_adjust( f, gindex, &b ); + } + + *aadvance = (FT_Short)a; + *abearing = (FT_UShort)b; + } +#endif } diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index 2a5319e97..93385a533 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -484,7 +484,7 @@ FT_DEFINE_SERVICE_METRICSVARIATIONSREC( tt_service_metrics_variations, - (FT_HAdvance_Adjust_Func)NULL, /* hadvance_adjust */ + (FT_HAdvance_Adjust_Func)tt_hadvance_adjust, /* hadvance_adjust */ (FT_LSB_Adjust_Func) NULL, /* lsb_adjust */ (FT_RSB_Adjust_Func) NULL, /* rsb_adjust */ diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c index c4eb125f9..affa6199e 100644 --- a/src/truetype/ttgxvar.c +++ b/src/truetype/ttgxvar.c @@ -2629,7 +2629,13 @@ FT_Pos delta_y = FT_MulFix( deltas_y[j], apply ); - outline->points[j].x += delta_x; + /* Experimental fix for double adjustment of advance width: */ + /* adjust phantom point 2 only if there's no HVAR. */ + /* */ + /* TODO: handle LSB (pp1) and VVAR (pp3, pp4) too */ + if ( j != ( n_points - 3 ) || blend->hvar_checked == FALSE ) + outline->points[j].x += delta_x; + outline->points[j].y += delta_y; #ifdef FT_DEBUG_LEVEL_TRACE