Commit bcae657482ca038dc2b7c4ddd737a110c85e052a

Dave Arnold 2016-12-05T22:08:15

Add `FT_Get_Var_Design_Coordinates' function. Note that the low-level functions aren't implemented yet. * include/freetype/ftmm.h: Declare. * include/freetype/internal/services/svmm.h (FT_Get_Var_Design_Func): New typedef. (MultiMasters): New MM service function `get_var_design'. (FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated. Update all callers. * src/base/ftmm.c (FT_Get_Var_Design_Coordinates): Implement. * src/truetype/ttdriver.c: Updated. * src/truetype/ttgxvar.c (TT_Get_Var_Design): New dummy function to handle `get_var_design' service. * src/truetype/ttgxvar.h: Updated. * src/type1/t1driver.c: Updated. * src/type1/t1load.c (T1_Get_Var_Design): New dummp function to handle `get_var_design' service. * src/type1/t1load.h: Updated.

diff --git a/ChangeLog b/ChangeLog
index d54467a..70268d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2016-12-06  Dave Arnold  <darnold@adobe.com>
+
+	Add `FT_Get_Var_Design_Coordinates' function.
+
+	Note that the low-level functions aren't implemented yet.
+
+	* include/freetype/ftmm.h: Declare.
+
+	* include/freetype/internal/services/svmm.h
+	(FT_Get_Var_Design_Func): New typedef.
+	(MultiMasters): New MM service function `get_var_design'.
+	(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
+	Update all callers.
+
+	* src/base/ftmm.c (FT_Get_Var_Design_Coordinates): Implement.
+
+	* src/truetype/ttdriver.c: Updated.
+
+	* src/truetype/ttgxvar.c (TT_Get_Var_Design): New dummy function to
+	handle `get_var_design' service.
+	* src/truetype/ttgxvar.h: Updated.
+
+	* src/type1/t1driver.c: Updated.
+
+	* src/type1/t1load.c (T1_Get_Var_Design): New dummp function to
+	handle `get_var_design' service.
+	* src/type1/t1load.h: Updated.
+
 2016-12-06  Werner Lemberg  <wl@gnu.org>
 
 	* src/type1/t1load.c (parse_subrs): Fix memory leak.
diff --git a/include/freetype/ftmm.h b/include/freetype/ftmm.h
index c05d3b6..882bdbb 100644
--- a/include/freetype/ftmm.h
+++ b/include/freetype/ftmm.h
@@ -337,6 +337,34 @@ FT_BEGIN_HEADER
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
+  /*    FT_Get_Var_Design_Coordinates                                      */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    For Multiple Master and GX Var fonts, get the design coordinates   */
+  /*    of the currently selected interpolated font.                       */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    face       :: A handle to the source face.                         */
+  /*                                                                       */
+  /*    num_coords :: The number of design coordinates to retrieve.  If it */
+  /*                  is larger than the number of axes, set the excess    */
+  /*                  values to~0.                                         */
+  /*                                                                       */
+  /* <Output>                                                              */
+  /*    coords     :: The design coordinates array.                        */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    FreeType error code.  0~means success.                             */
+  /*                                                                       */
+  FT_EXPORT( FT_Error )
+  FT_Get_Var_Design_Coordinates( FT_Face    face,
+                                 FT_UInt    num_coords,
+                                 FT_Fixed*  coords );
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
   /*    FT_Set_MM_Blend_Coordinates                                        */
   /*                                                                       */
   /* <Description>                                                         */
@@ -374,16 +402,16 @@ FT_BEGIN_HEADER
   /*    For Multiple Masters and GX var fonts, get the normalized blend    */
   /*    coordinates of the currently selected interpolated font.           */
   /*                                                                       */
-  /* <InOut>                                                               */
+  /* <Input>                                                               */
   /*    face       :: A handle to the source face.                         */
   /*                                                                       */
-  /* <Input>                                                               */
-  /*    num_coords :: The number of design coordinates to retrieve.  If it */
-  /*                  is larger than the number of axes, set the excess    */
-  /*                  values to 0.5 for MM fonts, and to 0 for GX var      */
-  /*                  fonts.                                               */
+  /*    num_coords :: The number of normalized blend coordinates to        */
+  /*                  retrieve.  If it is larger than the number of axes,  */
+  /*                  set the excess values to~0.5 for MM fonts, and to~0  */
+  /*                  for GX var fonts.                                    */
   /*                                                                       */
-  /*    coords     :: The design coordinates array.                        */
+  /* <Output>                                                              */
+  /*    coords     :: The normalized blend coordinates array.              */
   /*                                                                       */
   /* <Return>                                                              */
   /*    FreeType error code.  0~means success.                             */
diff --git a/include/freetype/internal/services/svmm.h b/include/freetype/internal/services/svmm.h
index 8092358..e4d34ba 100644
--- a/include/freetype/internal/services/svmm.h
+++ b/include/freetype/internal/services/svmm.h
@@ -59,6 +59,11 @@ FT_BEGIN_HEADER
                            FT_Long*  coords );
 
   typedef FT_Error
+  (*FT_Get_Var_Design_Func)( FT_Face    face,
+                             FT_UInt    num_coords,
+                             FT_Fixed*  coords );
+
+  typedef FT_Error
   (*FT_Get_MM_Blend_Func)( FT_Face   face,
                            FT_UInt   num_coords,
                            FT_Long*  coords );
@@ -72,6 +77,7 @@ FT_BEGIN_HEADER
     FT_Get_MM_Blend_Func    get_mm_blend;
     FT_Get_MM_Var_Func      get_mm_var;
     FT_Set_Var_Design_Func  set_var_design;
+    FT_Get_Var_Design_Func  get_var_design;
   };
 
 
@@ -83,7 +89,8 @@ FT_BEGIN_HEADER
                                            set_mm_blend_,    \
                                            get_mm_blend_,    \
                                            get_mm_var_,      \
-                                           set_var_design_ ) \
+                                           set_var_design_,  \
+                                           get_var_design_ ) \
   static const FT_Service_MultiMastersRec  class_ =          \
   {                                                          \
     get_mm_,                                                 \
@@ -91,7 +98,8 @@ FT_BEGIN_HEADER
     set_mm_blend_,                                           \
     get_mm_blend_,                                           \
     get_mm_var_,                                             \
-    set_var_design_                                          \
+    set_var_design_,                                         \
+    get_var_design_                                          \
   };
 
 #else /* FT_CONFIG_OPTION_PIC */
@@ -102,7 +110,8 @@ FT_BEGIN_HEADER
                                            set_mm_blend_,        \
                                            get_mm_blend_,        \
                                            get_mm_var_,          \
-                                           set_var_design_ )     \
+                                           set_var_design_,      \
+                                           get_var_design_ )     \
   void                                                           \
   FT_Init_Class_ ## class_( FT_Service_MultiMastersRec*  clazz ) \
   {                                                              \
@@ -112,6 +121,7 @@ FT_BEGIN_HEADER
     clazz->get_mm_blend   = get_mm_blend_;                       \
     clazz->get_mm_var     = get_mm_var_;                         \
     clazz->set_var_design = set_var_design_;                     \
+    clazz->get_var_design = get_var_design_;                     \
   }
 
 #endif /* FT_CONFIG_OPTION_PIC */
diff --git a/src/base/ftmm.c b/src/base/ftmm.c
index 138515e..c352803 100644
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -175,6 +175,34 @@
   /* documentation is in ftmm.h */
 
   FT_EXPORT_DEF( FT_Error )
+  FT_Get_Var_Design_Coordinates( FT_Face    face,
+                                 FT_UInt    num_coords,
+                                 FT_Fixed*  coords )
+  {
+    FT_Error                 error;
+    FT_Service_MultiMasters  service;
+
+
+    /* check of `face' delayed to `ft_face_get_mm_service' */
+
+    if ( !coords )
+      return FT_THROW( Invalid_Argument );
+
+    error = ft_face_get_mm_service( face, &service );
+    if ( !error )
+    {
+      error = FT_ERR( Invalid_Argument );
+      if ( service->get_var_design )
+        error = service->get_var_design( face, num_coords, coords );
+    }
+
+    return error;
+  }
+
+
+  /* documentation is in ftmm.h */
+
+  FT_EXPORT_DEF( FT_Error )
   FT_Set_MM_Blend_Coordinates( FT_Face    face,
                                FT_UInt    num_coords,
                                FT_Fixed*  coords )
@@ -193,7 +221,7 @@
     {
       error = FT_ERR( Invalid_Argument );
       if ( service->set_mm_blend )
-         error = service->set_mm_blend( face, num_coords, coords );
+        error = service->set_mm_blend( face, num_coords, coords );
     }
 
     return error;
@@ -224,7 +252,7 @@
     {
       error = FT_ERR( Invalid_Argument );
       if ( service->set_mm_blend )
-         error = service->set_mm_blend( face, num_coords, coords );
+        error = service->set_mm_blend( face, num_coords, coords );
     }
 
     return error;
@@ -252,7 +280,7 @@
     {
       error = FT_ERR( Invalid_Argument );
       if ( service->get_mm_blend )
-         error = service->get_mm_blend( face, num_coords, coords );
+        error = service->get_mm_blend( face, num_coords, coords );
     }
 
     return error;
@@ -283,7 +311,7 @@
     {
       error = FT_ERR( Invalid_Argument );
       if ( service->get_mm_blend )
-         error = service->get_mm_blend( face, num_coords, coords );
+        error = service->get_mm_blend( face, num_coords, coords );
     }
 
     return error;
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index 1c4b617..886f7a0 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -472,7 +472,8 @@
     (FT_Set_MM_Blend_Func)  TT_Set_MM_Blend,        /* set_mm_blend   */
     (FT_Get_MM_Blend_Func)  TT_Get_MM_Blend,        /* get_mm_blend   */
     (FT_Get_MM_Var_Func)    TT_Get_MM_Var,          /* get_mm_var     */
-    (FT_Set_Var_Design_Func)TT_Set_Var_Design       /* set_var_design */
+    (FT_Set_Var_Design_Func)TT_Set_Var_Design,      /* set_var_design */
+    (FT_Get_Var_Design_Func)TT_Get_Var_Design       /* get_var_design */
   )
 #endif
 
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 0b48c2c..461369f 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -1381,6 +1381,20 @@
   }
 
 
+  FT_LOCAL_DEF( FT_Error )
+  TT_Get_Var_Design( TT_Face    face,
+                     FT_UInt    num_coords,
+                     FT_Fixed*  coords )
+  {
+    FT_UNUSED( face );
+    FT_UNUSED( num_coords );
+    FT_UNUSED( coords );
+
+    /* TODO: Implement this function. */
+    return FT_THROW( Unimplemented_Feature );
+  }
+
+
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
diff --git a/src/truetype/ttgxvar.h b/src/truetype/ttgxvar.h
index 408de71..dd13bd8 100644
--- a/src/truetype/ttgxvar.h
+++ b/src/truetype/ttgxvar.h
@@ -162,6 +162,10 @@ FT_BEGIN_HEADER
   TT_Get_MM_Var( TT_Face      face,
                  FT_MM_Var*  *master );
 
+  FT_LOCAL( FT_Error )
+  TT_Get_Var_Design( TT_Face    face,
+                     FT_UInt    num_coords,
+                     FT_Fixed*  coords );
 
   FT_LOCAL( FT_Error )
   tt_face_vary_cvt( TT_Face    face,
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index e5fb701..639d7c0 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -124,7 +124,8 @@
     (FT_Set_MM_Blend_Func)  T1_Set_MM_Blend,       /* set_mm_blend   */
     (FT_Get_MM_Blend_Func)  T1_Get_MM_Blend,       /* get_mm_blend   */
     (FT_Get_MM_Var_Func)    T1_Get_MM_Var,         /* get_mm_var     */
-    (FT_Set_Var_Design_Func)T1_Set_Var_Design      /* set_var_design */
+    (FT_Set_Var_Design_Func)T1_Set_Var_Design,     /* set_var_design */
+    (FT_Get_Var_Design_Func)T1_Get_Var_Design      /* get_var_design */
   };
 #endif
 
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 396f8a5..2b64f85 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -546,6 +546,20 @@
   }
 
 
+  FT_LOCAL_DEF( FT_Error )
+  T1_Get_Var_Design( T1_Face    face,
+                     FT_UInt    num_coords,
+                     FT_Fixed*  coords )
+  {
+    FT_UNUSED( face );
+    FT_UNUSED( num_coords );
+    FT_UNUSED( coords );
+
+    /* TODO: Implement this function. */
+    return FT_THROW( Unimplemented_Feature );
+  }
+
+
   FT_LOCAL_DEF( void )
   T1_Done_Blend( T1_Face  face )
   {
diff --git a/src/type1/t1load.h b/src/type1/t1load.h
index 1fbd0b4..72445c5 100644
--- a/src/type1/t1load.h
+++ b/src/type1/t1load.h
@@ -70,7 +70,7 @@ FT_BEGIN_HEADER
   T1_Get_Multi_Master( T1_Face           face,
                        FT_Multi_Master*  master );
 
-  FT_LOCAL_DEF( FT_Error )
+  FT_LOCAL( FT_Error )
   T1_Get_MM_Var( T1_Face      face,
                  FT_MM_Var*  *master );
 
@@ -89,7 +89,12 @@ FT_BEGIN_HEADER
                     FT_UInt   num_coords,
                     FT_Long*  coords );
 
-  FT_LOCAL_DEF( FT_Error )
+  FT_LOCAL( FT_Error )
+  T1_Get_Var_Design( T1_Face    face,
+                     FT_UInt    num_coords,
+                     FT_Fixed*  coords );
+
+  FT_LOCAL( FT_Error )
   T1_Set_Var_Design( T1_Face    face,
                      FT_UInt    num_coords,
                      FT_Fixed*  coords );