freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 29aa957: [sfnt] Add `get_glyph_name' and `get_name_in


From: Werner LEMBERG
Subject: [freetype2] master 29aa957: [sfnt] Add `get_glyph_name' and `get_name_index' to SFNT interface.
Date: Thu, 8 Dec 2016 21:22:46 +0000 (UTC)

branch: master
commit 29aa9577677e6d2e211b00cb92ca04ce17cb862b
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [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.
---
 ChangeLog                        |   15 +++++++++++++++
 include/freetype/internal/sfnt.h |   19 +++++++++++++++++--
 src/sfnt/sfdriver.c              |   25 +++++++++++++++----------
 3 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 70268d2..012fabd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2016-12-08  Werner Lemberg  <address@hidden>
+
+       [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  <address@hidden>
 
        Add `FT_Get_Var_Design_Coordinates' function.
diff --git a/include/freetype/internal/sfnt.h b/include/freetype/internal/sfnt.h
index e139315..57d4ef0 100644
--- a/include/freetype/internal/sfnt.h
+++ b/include/freetype/internal/sfnt.h
@@ -24,6 +24,8 @@
 #include FT_INTERNAL_DRIVER_H
 #include FT_INTERNAL_TRUETYPE_TYPES_H
 
+#include FT_SERVICE_GLYPH_DICT_H
+
 
 FT_BEGIN_HEADER
 
@@ -589,6 +591,11 @@ FT_BEGIN_HEADER
 
     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 @@ FT_BEGIN_HEADER
           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 @@ FT_BEGIN_HEADER
     load_strike_metrics_,                \
     get_metrics_,                        \
     get_name_,                           \
+    get_glyph_name_,                     \
+    get_name_index_                      \
   };
 
 #else /* FT_CONFIG_OPTION_PIC */
@@ -699,7 +710,9 @@ FT_BEGIN_HEADER
           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 @@ FT_BEGIN_HEADER
     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 */
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index b838d77..9cf6973 100644
--- 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 */
   )
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]