Commit d7cc8f499ac27c41c02cfaddd98ee226def63663

Bram Tassyns 2010-05-21T10:14:58

Fix Savannah bug #27987. * src/cff/cffobjs.c (remove_subset_prefix): New function. (cff_face_init): Use it to adjust `cffface->family_name'.

diff --git a/ChangeLog b/ChangeLog
index 5887202..f0bb07a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-21  Bram Tassyns  <bramt@enfocus.be>
+
+	Fix Savannah bug #27987.
+
+	* src/cff/cffobjs.c (remove_subset_prefix): New function.
+	(cff_face_init): Use it to adjust `cffface->family_name'.
+
 2010-05-20  Werner Lemberg  <wl@gnu.org>
 
 	TrueType: Make FreeType ignore maxSizeOfInstructions in `maxp'.
@@ -16,7 +23,7 @@
 
 2010-05-18  Hongbo Ni  <hongbo@njstar.com>
 
-	Apply patch #7196.
+	Apply Savannah patch #7196.
 
 	* src/cff/cffgload.c (cff_slot_load): Prevent crash if CFF subfont
 	index is out of range.
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 6a2b8c8..4dc78bc 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -394,6 +394,41 @@
   }
 
 
+  /* Strip all subset prefixes of the form `ABCDEF+'.  Usually, there */
+  /* is only one, but font names like `APCOOG+JFABTD+FuturaBQ-Bold'   */
+  /* have been seen in the wild.                                      */
+
+  static void
+  remove_subset_prefix( FT_String*  name )
+  {
+    FT_Int32  idx             = 0;
+    FT_Int32  length          = strlen( name ) + 1;
+    FT_Bool   continue_search = 1;
+ 
+
+    while ( continue_search )
+    {
+      if ( length >= 7 && name[6] == '+' )
+      {
+        for ( idx = 0; idx < 6; idx++ )
+        {
+          /* ASCII uppercase letters */
+          if ( !( 'A' <= name[idx] && name[idx] <= 'Z' ) )
+            continue_search = 0;
+        }
+
+        if ( continue_search )
+        {
+          for ( idx = 7; idx < length; idx++ )
+            name[idx - 7] = name[idx];
+        }
+      }
+      else
+        continue_search = 0;
+    }
+  }
+
+
   FT_LOCAL_DEF( FT_Error )
   cff_face_init( FT_Stream      stream,
                  FT_Face        cffface,        /* CFF_Face */
@@ -678,6 +713,8 @@
           char*  family_name = NULL;
 
 
+          remove_subset_prefix( cffface->family_name ); 
+
           if ( dict->family_name )
           {
             family_name = cff_index_get_sid_string( cff,