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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
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 )