shithub: freetype+ttf2subf

Download patch

ref: 0c7fb43d050056a216b94aa4e079cf5d20c140e6
parent: 99fb3c3ab84ae089d1ec92bd38e71e900d1e7513
author: Werner Lemberg <[email protected]>
date: Sun Mar 5 14:06:41 EST 2017

[sfnt] Add `get_name_id' service.

* include/freetype/internal/sfnt.h (TT_Get_Name_ID_Func): New
typedef.
(SFNT_Interface): Add `get_name_id' field.
(FT_DEFINE_SFNT_INTERFACE): Updated.

* src/sfnt/sfdriver.c (search_name_id): Rename to...
(sfnt_get_name_id): ... this.
(sfnt_get_ps_name, sfnt_interface): Udpated.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2017-03-04  Werner Lemberg  <[email protected]>
 
+	[sfnt] Add `get_name_id' service.
+
+	* include/freetype/internal/sfnt.h (TT_Get_Name_ID_Func): New
+	typedef.
+	(SFNT_Interface): Add `get_name_id' field.
+	(FT_DEFINE_SFNT_INTERFACE): Updated.
+
+	* src/sfnt/sfdriver.c (search_name_id): Rename to...
+	(sfnt_get_name_id): ... this.
+	(sfnt_get_ps_name, sfnt_interface): Udpated.
+
+2017-03-04  Werner Lemberg  <[email protected]>
+
 	[truetype] Make `TT_Set_MM_Blend' set named instance index.
 
 	* src/truetype/ttgxvar.h (GX_Blend): New array
--- a/include/freetype/internal/sfnt.h
+++ b/include/freetype/internal/sfnt.h
@@ -458,6 +458,37 @@
   /*************************************************************************/
   /*                                                                       */
   /* <FuncType>                                                            */
+  /*    TT_Get_Name_ID_Func                                                */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Search whether an ENGLISH version for a given name ID is in the    */
+  /*    `name' table.                                                      */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    face     :: A handle to the source face object.                    */
+  /*                                                                       */
+  /*    nameid   :: The name id of the name record to return.              */
+  /*                                                                       */
+  /* <Out>                                                                 */
+  /*    win      :: If non-negative, an index into the `name' table with   */
+  /*                the corresponding (3,1) or (3,0) Windows entry.        */
+  /*                                                                       */
+  /*    apple    :: If non-negative, an index into the `name' table with   */
+  /*                the corresponding (1,0) Apple entry.                   */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    1 if there is either a win or apple entry (or both), 0 otheriwse.  */
+  /*                                                                       */
+  typedef FT_Bool
+  (*TT_Get_Name_ID_Func)( TT_Face    face,
+                          FT_UShort  nameid,
+                          FT_Int    *win,
+                          FT_Int    *apple );
+
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <FuncType>                                                            */
   /*    TT_Load_Table_Func                                                 */
   /*                                                                       */
   /* <Description>                                                         */
@@ -588,6 +619,7 @@
     TT_Get_Metrics_Func          get_metrics;
 
     TT_Get_Name_Func             get_name;
+    TT_Get_Name_ID_Func          get_name_id;
 
   } SFNT_Interface;
 
@@ -628,7 +660,8 @@
           set_sbit_strike_,              \
           load_strike_metrics_,          \
           get_metrics_,                  \
-          get_name_ )                    \
+          get_name_,                     \
+          get_name_id_ )                 \
   static const SFNT_Interface  class_ =  \
   {                                      \
     goto_table_,                         \
@@ -661,6 +694,7 @@
     load_strike_metrics_,                \
     get_metrics_,                        \
     get_name_,                           \
+    get_name_id_                         \
   };
 
 #else /* FT_CONFIG_OPTION_PIC */
@@ -699,7 +733,8 @@
           set_sbit_strike_,                             \
           load_strike_metrics_,                         \
           get_metrics_,                                 \
-          get_name_ )                                   \
+          get_name_,                                    \
+          get_name_id_ )                                \
   void                                                  \
   FT_Init_Class_ ## class_( FT_Library       library,   \
                             SFNT_Interface*  clazz )    \
@@ -736,6 +771,7 @@
     clazz->load_strike_metrics = load_strike_metrics_;  \
     clazz->get_metrics         = get_metrics_;          \
     clazz->get_name            = get_name_;             \
+    clazz->get_name_id         = get_name_id_;          \
   }
 
 #endif /* FT_CONFIG_OPTION_PIC */
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -381,11 +381,11 @@
   }
 
 
-  static int
-  search_name_id( TT_Face  face,
-                  FT_Int   id,
-                  FT_Int  *win,
-                  FT_Int  *apple )
+  static FT_Bool
+  sfnt_get_name_id( TT_Face    face,
+                    FT_UShort  id,
+                    FT_Int    *win,
+                    FT_Int    *apple )
   {
     FT_Int  n;
 
@@ -424,7 +424,7 @@
 
     /* scan the name table to see whether we have a Postscript name here, */
     /* either in Macintosh or Windows platform encodings                  */
-    found = search_name_id( face, 6, &win, &apple );
+    found = sfnt_get_name_id( face, 6, &win, &apple );
 
     if ( found )
     {
@@ -646,7 +646,8 @@
 
     tt_face_get_metrics,    /* TT_Get_Metrics_Func     get_metrics     */
 
-    tt_face_get_name        /* TT_Get_Name_Func        get_name        */
+    tt_face_get_name,       /* TT_Get_Name_Func        get_name        */
+    sfnt_get_name_id        /* TT_Get_Name_ID_Func     get_name_id     */
   )