[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.
This commit is contained in:
Werner Lemberg 2017-01-11 14:21:26 +01:00
parent d718ac4ead
commit 723aafb5e3
3 changed files with 83 additions and 15 deletions

View File

@ -1,3 +1,16 @@
2017-01-11 Werner Lemberg <wl@gnu.org>
[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 <wl@gnu.org>
[truetype] Provide metrics variation service.

View File

@ -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 */

View File

@ -664,6 +664,8 @@
named_style->coords );
if ( error )
goto Exit;
tt_apply_mvar( face );
}
}
}