shithub: freetype+ttf2subf

Download patch

ref: bcae657482ca038dc2b7c4ddd737a110c85e052a
parent: c0fae7da5a6503c6d38ec133483aba57b42c0ddb
author: Dave Arnold <[email protected]>
date: Mon Dec 5 17:08:15 EST 2016

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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2016-12-06  Dave Arnold  <[email protected]>
+
+	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  <[email protected]>
 
 	* src/type1/t1load.c (parse_subrs): Fix memory leak.
--- a/include/freetype/ftmm.h
+++ b/include/freetype/ftmm.h
@@ -337,6 +337,34 @@
   /*************************************************************************/
   /*                                                                       */
   /* <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 @@
   /*    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.                             */
--- a/include/freetype/internal/services/svmm.h
+++ b/include/freetype/internal/services/svmm.h
@@ -59,6 +59,11 @@
                            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_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 @@
                                            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 @@
     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 @@
                                            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 @@
     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 */
--- 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;
--- 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
 
--- 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 );
+  }
+
+
   /*************************************************************************/
   /*************************************************************************/
   /*****                                                               *****/
--- a/src/truetype/ttgxvar.h
+++ b/src/truetype/ttgxvar.h
@@ -162,6 +162,10 @@
   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,
--- 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
 
--- 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 )
   {
--- a/src/type1/t1load.h
+++ b/src/type1/t1load.h
@@ -70,7 +70,7 @@
   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_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 );