Commit b8ca6de3653b5c3d50e9fadc6a1d7b606deffbdb

suzuki toshiya 2010-07-09T11:36:00

Fix Savannah bug #30373. Too serious check of errors by `FT_CMap_New' since 2010-07-04 is fixed. Reported by Tor Andersson. * include/freetype/fterrdef.h (PSnames_Err_No_Unicode_Glyph_Name): New error code to indicate the Unicode charmap synthesis failed because no Unicode glyph name is found. * src/psnames/psmodule.c (ps_unicodes_init): Return PSnames_Err_No_Unicode_Glyph_Name when no Unicode glyph name is found in the font. * src/cff/cffcmap.c (cff_cmap_unicode_init): Return CFF_Err_No_Unicode_Glyph_Name when no SID is available. * src/type1/t1objs.c (T1_Face_Init): Proceed if `FT_CMap_New' is failed by the lack of Unicode glyph name. * src/type42/t42objs.c (T42_Face_Init): Ditto. * src/cff/cffobjs.c (cff_face_init): Ditto.

diff --git a/ChangeLog b/ChangeLog
index 75c7f05..7e313a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2010-07-09  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+	Fix Savannah bug #30373.
+	Too serious check of errors by `FT_CMap_New' since 2010-07-04
+	is fixed. Reported by Tor Andersson.
+
+	* include/freetype/fterrdef.h
+	(PSnames_Err_No_Unicode_Glyph_Name): New error code to
+	indicate the Unicode charmap synthesis failed because
+	no Unicode glyph name is found.
+
+	* src/psnames/psmodule.c (ps_unicodes_init): Return
+	PSnames_Err_No_Unicode_Glyph_Name when no Unicode glyph name
+	is found in the font.
+	* src/cff/cffcmap.c (cff_cmap_unicode_init): Return
+	CFF_Err_No_Unicode_Glyph_Name when no SID is available.
+
+	* src/type1/t1objs.c (T1_Face_Init): Proceed if `FT_CMap_New'
+	is failed by the lack of Unicode glyph name.
+	* src/type42/t42objs.c (T42_Face_Init): Ditto.
+	* src/cff/cffobjs.c (cff_face_init): Ditto.
+
 2010-07-09  Ken Sharp  <ken.sharp@artifex.com>
 
 	Make ftraster.c compile in stand-alone mode with MSVC compiler.
diff --git a/include/freetype/fterrdef.h b/include/freetype/fterrdef.h
index ceda1a9..bf52220 100644
--- a/include/freetype/fterrdef.h
+++ b/include/freetype/fterrdef.h
@@ -211,6 +211,9 @@
                 "argument stack underflow" )
   FT_ERRORDEF_( Ignore,                                      0xA2, \
                 "ignore" )
+  FT_ERRORDEF_( No_Unicode_Glyph_Name,                       0xA3, \
+                "no Unicode glyph name found" )
+
 
   /* BDF errors */
 
diff --git a/src/cff/cffcmap.c b/src/cff/cffcmap.c
index 6a98907..1298371 100644
--- a/src/cff/cffcmap.c
+++ b/src/cff/cffcmap.c
@@ -143,8 +143,9 @@
 
 
     /* can't build Unicode map for CID-keyed font */
+    /* because we don't know glyph names.         */
     if ( !charset->sids )
-      return CFF_Err_Invalid_Argument;
+      return CFF_Err_No_Unicode_Glyph_Name;
 
     return psnames->unicodes_init( memory,
                                    unicodes,
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 3d50dde..334ec59 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -899,7 +899,7 @@
 
         error = FT_CMap_New( &FT_CFF_CMAP_UNICODE_CLASS_REC_GET, NULL,
                              &cmaprec, NULL );
-        if ( error )
+        if ( error && FT_Err_No_Unicode_Glyph_Name != error )
           goto Exit;
 
         /* if no Unicode charmap was previously selected, select this one */
diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c
index fb3b29c..7528696 100644
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -366,9 +366,10 @@
 
       if ( count == 0 )
       {
+        /* No unicode chars here! */
         FT_FREE( table->maps );
         if ( !error )
-          error = PSnames_Err_Invalid_Argument;  /* No unicode chars here! */
+          error = PSnames_Err_No_Unicode_Glyph_Name;
       }
       else
       {
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 1183b42..52df90c 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -499,7 +499,7 @@
         charmap.encoding    = FT_ENCODING_UNICODE;
 
         error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
-        if ( error )
+        if ( error && FT_Err_No_Unicode_Glyph_Name != error )
           goto Exit;
 
         /* now, generate an Adobe Standard encoding when appropriate */
diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c
index de88465..00b5c1a 100644
--- a/src/type42/t42objs.c
+++ b/src/type42/t42objs.c
@@ -335,7 +335,7 @@
         charmap.encoding    = FT_ENCODING_UNICODE;
 
         error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
-        if ( error )
+        if ( error && FT_Err_No_Unicode_Glyph_Name != error )
           goto Exit;
 
         /* now, generate an Adobe Standard encoding when appropriate */