Commit cfcec824eb91458956496f5fe37b153d86642fdc

Tom Kacvinsky 2001-08-09T01:06:33

Added function t1_get_name_index and changed Get_Interface to return this function when the "name_index" function is requested. Changed get_t1_glyph_name to t1_get_glyph_name for consistency.

diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index 931c13e..fbde5ec 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -45,7 +45,7 @@
 
 
   static FT_Error
-  get_t1_glyph_name( T1_Face     face,
+  t1_get_glyph_name( T1_Face     face,
                      FT_UInt     glyph_index,
                      FT_Pointer  buffer,
                      FT_UInt     buffer_max )
@@ -70,6 +70,40 @@
     return T1_Err_Ok;
   }
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    t1_get_name_index                                                  */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Uses the Type 1 font's `glyph_names' table to find a given glyph   */
+  /*    name's glyph index.                                                */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    face       :: A handle to the source face object.                  */
+  /*    glyph_name :: The glyph name.                                      */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    Glyph index.  0 means `undefined character code'.                  */
+  /*                                                                       */
+  static FT_UInt
+  t1_get_name_index( T1_Face     face,
+                     FT_String*  glyph_name )
+  {
+    FT_UInt     i;
+    FT_String*  gname;
+
+    for ( i = 0; i < face->type1.num_glyphs; i++ )
+    {
+      gname = face->type1.glyph_names[i];
+
+      if ( !strcmp( glyph_name, gname ) )
+        return i;
+    }
+
+    return 0;
+  }
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -106,7 +140,10 @@
     FT_UNUSED( interface );
 
     if ( strcmp( (const char*)interface, "glyph_name" ) == 0 )
-      return (FT_Module_Interface)get_t1_glyph_name;
+      return (FT_Module_Interface)t1_get_glyph_name;
+
+    if ( strcmp( (const char*)interface, "name_index" ) == 0 )
+      return (FT_Module_Interface)t1_get_name_index;
 
 #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
     if ( strcmp( (const char*)interface, "get_mm" ) == 0 )