shithub: freetype+ttf2subf

Download patch

ref: 4f7ef401eadeae55328c7a064498446336e9d77e
parent: 59e2c8dd253638098ce853d067ff659771d2d6b6
author: Werner Lemberg <[email protected]>
date: Sun Jan 18 05:53:29 EST 2009

Implement FT_Get_Name_Index for SFNT driver.

* src/sfnt/sfdriver.c (sfnt_get_name_index): New function.
(sfnt_service_glyph_dict): Use it.

Problem reported by Truc Truong <[email protected]>.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2009-01-18  Werner Lemberg  <[email protected]>
 
+	Implement FT_Get_Name_Index for SFNT driver.
+
+	* src/sfnt/sfdriver.c (sfnt_get_name_index): New function.
+	(sfnt_service_glyph_dict): Use it.
+
+	Problem reported by Truc Truong <[email protected]>.
+
+2009-01-18  Werner Lemberg  <[email protected]>
+
 	* include/freetype/ftstroke.h (FT_Outline_GetInsideBorder): Fix
 	documentation.  Problem reported by Truc Truong <[email protected]>.
 
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    High-level SFNT driver interface (body).                             */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by             */
+/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by       */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -151,10 +151,35 @@
   }
 
 
+  static FT_UInt
+  sfnt_get_name_index( TT_Face     face,
+                       FT_String*  glyph_name )
+  {
+    FT_Face  root = &face->root;
+    FT_Long  i;
+
+
+    for ( i = 0; i < root->num_glyphs; i++ )
+    {
+      FT_String*  gname;
+      FT_Error    error = tt_face_get_ps_name( face, i, &gname );
+
+
+      if ( error )
+        continue;
+
+      if ( !ft_strcmp( glyph_name, gname ) )
+        return (FT_UInt)i;
+    }
+
+    return 0;
+  }
+
+
   static const FT_Service_GlyphDictRec  sfnt_service_glyph_dict =
   {
     (FT_GlyphDict_GetNameFunc)  sfnt_get_glyph_name,
-    (FT_GlyphDict_NameIndexFunc)NULL
+    (FT_GlyphDict_NameIndexFunc)sfnt_get_name_index
   };
 
 #endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */