From 723aafb5e35f4cd2410064285cdc591bd62b7b04 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Wed, 11 Jan 2017 14:21:26 +0100 Subject: [PATCH] [truetype] Actually use metrics variation service. * src/base/ftmm.c: Include FT_SERVICE_METRICS_VARIATIONS_H. (ft_face_get_mvar_service): New auxiliary function to look up metrics variation service. (FT_Set_Var_Design_Coordinates, FT_Set_MM_Blend_Coordinates, FT_Set_Var_Blend_Coordinates): Call metrics variation service. * src/truetype/ttobjs.c (tt_face_init): Use metrics variations for named instances. --- ChangeLog | 13 +++++++ src/base/ftmm.c | 83 +++++++++++++++++++++++++++++++++++-------- src/truetype/ttobjs.c | 2 ++ 3 files changed, 83 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index b196b5a57..1a96831e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2017-01-11 Werner Lemberg + + [truetype] Actually use metrics variation service. + + * src/base/ftmm.c: Include FT_SERVICE_METRICS_VARIATIONS_H. + (ft_face_get_mvar_service): New auxiliary function to look up + metrics variation service. + (FT_Set_Var_Design_Coordinates, FT_Set_MM_Blend_Coordinates, + FT_Set_Var_Blend_Coordinates): Call metrics variation service. + + * src/truetype/ttobjs.c (tt_face_init): Use metrics variations for + named instances. + 2017-01-11 Werner Lemberg [truetype] Provide metrics variation service. diff --git a/src/base/ftmm.c b/src/base/ftmm.c index 6eda8edad..b8db3c566 100644 --- a/src/base/ftmm.c +++ b/src/base/ftmm.c @@ -22,6 +22,7 @@ #include FT_MULTIPLE_MASTERS_H #include FT_INTERNAL_OBJECTS_H #include FT_SERVICE_MULTIPLE_MASTERS_H +#include FT_SERVICE_METRICS_VARIATIONS_H /*************************************************************************/ @@ -62,6 +63,34 @@ } + static FT_Error + ft_face_get_mvar_service( FT_Face face, + FT_Service_MetricsVariations *aservice ) + { + FT_Error error; + + + *aservice = NULL; + + if ( !face ) + return FT_THROW( Invalid_Face_Handle ); + + error = FT_ERR( Invalid_Argument ); + + if ( FT_HAS_MULTIPLE_MASTERS( face ) ) + { + FT_FACE_LOOKUP_SERVICE( face, + *aservice, + METRICS_VARIATIONS ); + + if ( *aservice ) + error = FT_Err_Ok; + } + + return error; + } + + /* documentation is in ftmm.h */ FT_EXPORT_DEF( FT_Error ) @@ -158,8 +187,9 @@ FT_UInt num_coords, FT_Fixed* coords ) { - FT_Error error; - FT_Service_MultiMasters service; + FT_Error error; + FT_Service_MultiMasters service_mm; + FT_Service_MetricsVariations service_mvar; /* check of `face' delayed to `ft_face_get_mm_service' */ @@ -167,12 +197,19 @@ if ( !coords ) return FT_THROW( Invalid_Argument ); - error = ft_face_get_mm_service( face, &service ); + error = ft_face_get_mm_service( face, &service_mm ); if ( !error ) { error = FT_ERR( Invalid_Argument ); - if ( service->set_var_design ) - error = service->set_var_design( face, num_coords, coords ); + if ( service_mm->set_var_design ) + error = service_mm->set_var_design( face, num_coords, coords ); + } + + error = ft_face_get_mvar_service( face, &service_mvar ); + if ( !error ) + { + if ( service_mvar->metrics_adjust ) + service_mvar->metrics_adjust( face ); } /* enforce recomputation of auto-hinting data */ @@ -221,8 +258,9 @@ FT_UInt num_coords, FT_Fixed* coords ) { - FT_Error error; - FT_Service_MultiMasters service; + FT_Error error; + FT_Service_MultiMasters service_mm; + FT_Service_MetricsVariations service_mvar; /* check of `face' delayed to `ft_face_get_mm_service' */ @@ -230,12 +268,19 @@ if ( !coords ) return FT_THROW( Invalid_Argument ); - error = ft_face_get_mm_service( face, &service ); + error = ft_face_get_mm_service( face, &service_mm ); if ( !error ) { error = FT_ERR( Invalid_Argument ); - if ( service->set_mm_blend ) - error = service->set_mm_blend( face, num_coords, coords ); + if ( service_mm->set_mm_blend ) + error = service_mm->set_mm_blend( face, num_coords, coords ); + } + + error = ft_face_get_mvar_service( face, &service_mvar ); + if ( !error ) + { + if ( service_mvar->metrics_adjust ) + service_mvar->metrics_adjust( face ); } /* enforce recomputation of auto-hinting data */ @@ -259,8 +304,9 @@ FT_UInt num_coords, FT_Fixed* coords ) { - FT_Error error; - FT_Service_MultiMasters service; + FT_Error error; + FT_Service_MultiMasters service_mm; + FT_Service_MetricsVariations service_mvar; /* check of `face' delayed to `ft_face_get_mm_service' */ @@ -268,12 +314,19 @@ if ( !coords ) return FT_THROW( Invalid_Argument ); - error = ft_face_get_mm_service( face, &service ); + error = ft_face_get_mm_service( face, &service_mm ); if ( !error ) { error = FT_ERR( Invalid_Argument ); - if ( service->set_mm_blend ) - error = service->set_mm_blend( face, num_coords, coords ); + if ( service_mm->set_mm_blend ) + error = service_mm->set_mm_blend( face, num_coords, coords ); + } + + error = ft_face_get_mvar_service( face, &service_mvar ); + if ( !error ) + { + if ( service_mvar->metrics_adjust ) + service_mvar->metrics_adjust( face ); } /* enforce recomputation of auto-hinting data */ diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index c907ecdcc..18aa48a93 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -664,6 +664,8 @@ named_style->coords ); if ( error ) goto Exit; + + tt_apply_mvar( face ); } } }