Added function get_cff_glyph_name() in order to facilitate getting a glyph name for glyph index via FT_Get_Glyph_Name(). In function cff_get_interface(), added support for getting a glyph name via the "glyph_name" module interface (used in the function FT_Get_Glyph_Name()). We use the new function get_cff_glyph_name().
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index a66a852..e701f3f 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -26,7 +26,7 @@
#include FT_SOURCE_FILE(cff,cffdrivr.h)
#include FT_SOURCE_FILE(cff,cffgload.h)
-
+#include FT_SOURCE_FILE(cff,cffload.h)
/*************************************************************************/
/* */
@@ -219,6 +219,56 @@
/*************************************************************************/
/*************************************************************************/
+ static
+ FT_Error get_cff_glyph_name( CFF_Face face,
+ FT_UInt glyph_index,
+ FT_Pointer buffer,
+ FT_UInt buffer_max )
+ {
+ CFF_Font* font = (CFF_Font*)face->extra.data;
+ FT_Memory memory = FT_FACE_MEMORY(face);
+ FT_String* gname;
+ FT_UShort sid;
+ PSNames_Interface* psnames;
+ FT_Error error;
+
+ psnames = (PSNames_Interface*)FT_Get_Module_Interface( face->root.driver->root.library, "psnames" );
+
+ if ( !psnames )
+ {
+ FT_ERROR(( "CFF_Init_Face:" ));
+ FT_ERROR(( " cannot open CFF & CEF fonts\n" ));
+ FT_ERROR(( " " ));
+ FT_ERROR(( " without the `PSNames' module\n" ));
+ error = FT_Err_Unknown_File_Format;
+ goto Exit;
+ }
+
+ /* first, locate the sid in the charset table */
+ sid = font->charset.sids[glyph_index];
+
+ /* now, lookup the name itself */
+ gname = CFF_Get_String( &font->string_index, sid, psnames );
+
+ if ( buffer_max > 0 )
+ {
+ FT_UInt len = strlen( gname );
+
+
+ if (len >= buffer_max)
+ len = buffer_max - 1;
+
+ MEM_Copy( buffer, gname, len );
+ ((FT_Byte*)buffer)[len] = 0;
+ }
+
+ FREE ( gname );
+ error = CFF_Err_Ok;
+
+ Exit:
+ return error;
+ }
+
/*************************************************************************/
/* */
/* <Function> */
@@ -275,13 +325,16 @@
/*************************************************************************/
/*************************************************************************/
-
static
FT_Module_Interface cff_get_interface( CFF_Driver driver,
const char* interface )
{
FT_Module sfnt;
+#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
+ if ( strcmp( (const char*)interface, "glyph_name" ) == 0 )
+ return (FT_Module_Interface)get_cff_glyph_name;
+#endif
/* we simply pass our request to the `sfnt' module */
sfnt = FT_Get_Module( driver->root.root.library, "sfnt" );