Commit 8b174b4b9690de3149bdeb41d3bff93ad896960c

Werner Lemberg 2016-12-11T09:16:52

[truetype, type1] Add `get_var_blend' to MM service. For internal use; we want to share code between the forthcoming CFF2 support and TrueType. * include/freetype/internal/services/svmm.h (FT_Get_Var_Blend_Func): New typedef. (MultiMasters): Add `get_var_blend'. (FT_Service_MultiMasters): Updated. * src/truetype/ttgxvar.c (tt_get_var_blend): New function. * src/truetype/ttgxvar.h: Updated. * src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated. * src/type1/t1driver.c (t1_service_multi_masters): Updated.

diff --git a/ChangeLog b/ChangeLog
index 37478d6..2a5a1bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2016-12-10  Werner Lemberg  <wl@gnu.org>
 
+	[truetype, type1] Add `get_var_blend' to MM service.
+
+	For internal use; we want to share code between the forthcoming CFF2
+	support and TrueType.
+
+	* include/freetype/internal/services/svmm.h (FT_Get_Var_Blend_Func):
+	New typedef.
+	(MultiMasters): Add `get_var_blend'.
+	(FT_Service_MultiMasters): Updated.
+
+	* src/truetype/ttgxvar.c (tt_get_var_blend): New function.
+	* src/truetype/ttgxvar.h: Updated.
+
+	* src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated.
+	* src/type1/t1driver.c (t1_service_multi_masters): Updated.
+
+2016-12-10  Werner Lemberg  <wl@gnu.org>
+
 	[truetype, type1] Add `done_blend' to MM service.
 
 	For internal use; we want to share code between the forthcoming CFF2
diff --git a/include/freetype/internal/services/svmm.h b/include/freetype/internal/services/svmm.h
index 51bce40..21dbd87 100644
--- a/include/freetype/internal/services/svmm.h
+++ b/include/freetype/internal/services/svmm.h
@@ -68,6 +68,11 @@ FT_BEGIN_HEADER
                            FT_UInt   num_coords,
                            FT_Long*  coords );
 
+  typedef FT_Error
+  (*FT_Get_Var_Blend_Func)( FT_Face     face,
+                            FT_UInt    *num_coords,
+                            FT_Fixed*  *coords );
+
   typedef void
   (*FT_Done_Blend_Func)( FT_Face );
 
@@ -83,6 +88,7 @@ FT_BEGIN_HEADER
     FT_Get_Var_Design_Func  get_var_design;
 
     /* for internal use; only needed for code sharing between modules */
+    FT_Get_Var_Blend_Func   get_var_blend;
     FT_Done_Blend_Func      done_blend;
   };
 
@@ -97,6 +103,7 @@ FT_BEGIN_HEADER
                                            get_mm_var_,      \
                                            set_var_design_,  \
                                            get_var_design_,  \
+                                           get_var_blend_,   \
                                            done_blend_     ) \
   static const FT_Service_MultiMastersRec  class_ =          \
   {                                                          \
@@ -107,6 +114,7 @@ FT_BEGIN_HEADER
     get_mm_var_,                                             \
     set_var_design_,                                         \
     get_var_design_,                                         \
+    get_var_blend_,                                          \
     done_blend_                                              \
   };
 
@@ -120,6 +128,7 @@ FT_BEGIN_HEADER
                                            get_mm_var_,          \
                                            set_var_design_,      \
                                            get_var_design_,      \
+                                           get_var_blend_,       \
                                            done_blend_ )         \
   void                                                           \
   FT_Init_Class_ ## class_( FT_Service_MultiMastersRec*  clazz ) \
@@ -131,6 +140,7 @@ FT_BEGIN_HEADER
     clazz->get_mm_var     = get_mm_var_;                         \
     clazz->set_var_design = set_var_design_;                     \
     clazz->get_var_design = get_var_design_;                     \
+    clazz->get_var_blend  = get_var_blend_;                      \
     clazz->done_blend     = done_blend_;                         \
   }
 
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index b7713d0..6ab8d3f 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -475,6 +475,7 @@
     (FT_Set_Var_Design_Func)TT_Set_Var_Design,      /* set_var_design */
     (FT_Get_Var_Design_Func)TT_Get_Var_Design,      /* get_var_design */
 
+    (FT_Get_Var_Blend_Func) tt_get_var_blend,       /* get_var_blend  */
     (FT_Done_Blend_Func)    tt_done_blend           /* done_blend     */
   )
 #endif
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 212358c..06b1200 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -2236,6 +2236,39 @@
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
+  /*    tt_get_var_blend                                                   */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    An internal version of `TT_Get_MM_Blend' that just returns         */
+  /*    pointers instead of copying data, without any initialization of    */
+  /*    the MM machinery in case it isn't loaded yet.                      */
+  /*                                                                       */
+  FT_LOCAL_DEF( FT_Error )
+  tt_get_var_blend( TT_Face     face,
+                    FT_UInt    *num_coords,
+                    FT_Fixed*  *coords )
+  {
+    FT_Error  error = FT_Err_Ok;
+
+
+    if ( face->blend )
+    {
+      *num_coords = face->blend->num_axis;
+      *coords     = face->blend->normalizedcoords;
+    }
+    else
+    {
+      *num_coords = 0;
+      *coords     = NULL;
+    }
+
+    return FT_Err_Ok;
+  }
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
   /*    tt_done_blend                                                      */
   /*                                                                       */
   /* <Description>                                                         */
diff --git a/src/truetype/ttgxvar.h b/src/truetype/ttgxvar.h
index f3fcfc7..9e4d749 100644
--- a/src/truetype/ttgxvar.h
+++ b/src/truetype/ttgxvar.h
@@ -179,6 +179,11 @@ FT_BEGIN_HEADER
                               FT_UInt      n_points );
 
 
+  FT_LOCAL( FT_Error )
+  tt_get_var_blend( TT_Face     face,
+                    FT_UInt    *num_coords,
+                    FT_Fixed*  *coords );
+
   FT_LOCAL( void )
   tt_done_blend( TT_Face  face );
 
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index ad46371..fd9e13e 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -127,6 +127,7 @@
     (FT_Set_Var_Design_Func)T1_Set_Var_Design,     /* set_var_design */
     (FT_Get_Var_Design_Func)T1_Get_Var_Design,     /* get_var_design */
 
+    (FT_Get_Var_Blend_Func) NULL,                  /* get_var_blend  */
     (FT_Done_Blend_Func)    T1_Done_Blend          /* done_blend     */
   };
 #endif