shithub: freetype+ttf2subf

Download patch

ref: cfcec824eb91458956496f5fe37b153d86642fdc
parent: 2eaadd5ad8b2dd17a5f3d67f190e546c954351bc
author: Tom Kacvinsky <[email protected]>
date: Wed Aug 8 21:06:33 EDT 2001

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.

git/fs: mount .git/fs: mount/attach disallowed
--- 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,7 +70,41 @@
     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;
+  }
+
+
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -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 )