shithub: freetype+ttf2subf

Download patch

ref: 29aa9577677e6d2e211b00cb92ca04ce17cb862b
parent: ffd8f6223607e9d61de33467fcd113f2a15dae36
author: Werner Lemberg <[email protected]>
date: Thu Dec 8 03:59:34 EST 2016

[sfnt] Add `get_glyph_name' and `get_name_index' to SFNT interface.

CFF2 fonts will need access to those two functions.

* include/freetype/internal/sfnt.h: Include FT_SERVICE_GLYPH_DICT_H.
(SFNT_Interface): Add `get_glyph_name' and `get_name_index' members.
(FT_DEFINE_SFNT_INTERFACE): Updated.

* src/sfnt/sfdriver.c (sfnt_get_glyph_name, sfnt_get_name_index):
Fix signatures to exactly correspond to the glyph dict service
function typedefs.
(sfnt_interface): Updated.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2016-12-08  Werner Lemberg  <[email protected]>
+
+	[sfnt] Add `get_glyph_name' and `get_name_index' to SFNT interface.
+
+	CFF2 fonts will need access to those two functions.
+
+	* include/freetype/internal/sfnt.h: Include FT_SERVICE_GLYPH_DICT_H.
+	(SFNT_Interface): Add `get_glyph_name' and `get_name_index' members.
+	(FT_DEFINE_SFNT_INTERFACE): Updated.
+
+	* src/sfnt/sfdriver.c (sfnt_get_glyph_name, sfnt_get_name_index):
+	Fix signatures to exactly correspond to the glyph dict service
+	function typedefs.
+	(sfnt_interface): Updated.
+
 2016-12-06  Dave Arnold  <[email protected]>
 
 	Add `FT_Get_Var_Design_Coordinates' function.
--- a/include/freetype/internal/sfnt.h
+++ b/include/freetype/internal/sfnt.h
@@ -24,7 +24,9 @@
 #include FT_INTERNAL_DRIVER_H
 #include FT_INTERNAL_TRUETYPE_TYPES_H
 
+#include FT_SERVICE_GLYPH_DICT_H
 
+
 FT_BEGIN_HEADER
 
 
@@ -589,6 +591,11 @@
 
     TT_Get_Name_Func             get_name;
 
+    /* since 2.7.1;                                             */
+    /* this is the SFNT specific part of the glyph dict service */
+    FT_GlyphDict_GetNameFunc     get_glyph_name;
+    FT_GlyphDict_NameIndexFunc   get_name_index;
+
   } SFNT_Interface;
 
 
@@ -628,7 +635,9 @@
           set_sbit_strike_,              \
           load_strike_metrics_,          \
           get_metrics_,                  \
-          get_name_ )                    \
+          get_name_,                     \
+          get_glyph_name_,               \
+          get_name_index_ )              \
   static const SFNT_Interface  class_ =  \
   {                                      \
     goto_table_,                         \
@@ -661,6 +670,8 @@
     load_strike_metrics_,                \
     get_metrics_,                        \
     get_name_,                           \
+    get_glyph_name_,                     \
+    get_name_index_                      \
   };
 
 #else /* FT_CONFIG_OPTION_PIC */
@@ -699,7 +710,9 @@
           set_sbit_strike_,                             \
           load_strike_metrics_,                         \
           get_metrics_,                                 \
-          get_name_ )                                   \
+          get_name_,                                    \
+          get_glyph_name_,                              \
+          get_name_index_ )                             \
   void                                                  \
   FT_Init_Class_ ## class_( FT_Library       library,   \
                             SFNT_Interface*  clazz )    \
@@ -736,6 +749,8 @@
     clazz->load_strike_metrics = load_strike_metrics_;  \
     clazz->get_metrics         = get_metrics_;          \
     clazz->get_name            = get_name_;             \
+    clazz->get_glyph_name      = get_glyph_name;        \
+    clazz->get_name_index      = get_name_index_;       \
   }
 
 #endif /* FT_CONFIG_OPTION_PIC */
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -154,7 +154,7 @@
    */
 
   static FT_Error
-  sfnt_get_glyph_name( TT_Face     face,
+  sfnt_get_glyph_name( FT_Face     face,
                        FT_UInt     glyph_index,
                        FT_Pointer  buffer,
                        FT_UInt     buffer_max )
@@ -163,7 +163,7 @@
     FT_Error    error;
 
 
-    error = tt_face_get_ps_name( face, glyph_index, &gname );
+    error = tt_face_get_ps_name( (TT_Face)face, glyph_index, &gname );
     if ( !error )
       FT_STRCPYN( buffer, gname, buffer_max );
 
@@ -172,26 +172,26 @@
 
 
   static FT_UInt
-  sfnt_get_name_index( TT_Face     face,
+  sfnt_get_name_index( FT_Face     face,
                        FT_String*  glyph_name )
   {
-    FT_Face  root = &face->root;
+    TT_Face  ttface = (TT_Face)face;
 
     FT_UInt  i, max_gid = FT_UINT_MAX;
 
 
-    if ( root->num_glyphs < 0 )
+    if ( face->num_glyphs < 0 )
       return 0;
-    else if ( (FT_ULong)root->num_glyphs < FT_UINT_MAX )
-      max_gid = (FT_UInt)root->num_glyphs;
+    else if ( (FT_ULong)face->num_glyphs < FT_UINT_MAX )
+      max_gid = (FT_UInt)face->num_glyphs;
     else
       FT_TRACE0(( "Ignore glyph names for invalid GID 0x%08x - 0x%08x\n",
-                  FT_UINT_MAX, root->num_glyphs ));
+                  FT_UINT_MAX, face->num_glyphs ));
 
     for ( i = 0; i < max_gid; i++ )
     {
       FT_String*  gname;
-      FT_Error    error = tt_face_get_ps_name( face, i, &gname );
+      FT_Error    error = tt_face_get_ps_name( ttface, i, &gname );
 
 
       if ( error )
@@ -528,7 +528,12 @@
 
     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        */
+
+    PUT_PS_NAMES( sfnt_get_glyph_name ),
+                        /* FT_GlyphDict_GetNameFunc     get_glyph_name */
+    PUT_PS_NAMES( sfnt_get_name_index )
+                        /* FT_GlyphDict_NameIndexFunc   get_name_index */
   )