Commit 723aafb5e35f4cd2410064285cdc591bd62b7b04

Werner Lemberg 2017-01-11T14:21:26

[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.

diff --git a/ChangeLog b/ChangeLog
index b196b5a..1a96831 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 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.
 
 	* include/freetype/internal/services/svmetric.h
diff --git a/src/base/ftmm.c b/src/base/ftmm.c
index 6eda8ed..b8db3c5 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 c907ecd..18aa48a 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 );
         }
       }
     }