Commit b17fb11f93c4d9df1051b89b0804a0cf905a02df

Werner Lemberg 2008-10-02T10:17:32

* src/cff/cffgload.c (cff_slot_load): Map CID 0 to GID 0. This fixes Savannah bug #24430.

diff --git a/ChangeLog b/ChangeLog
index d0f7961..4655391 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-02  Bram Tassyns  <bramt@enfocus.be>
+
+	* src/cff/cffgload.c (cff_slot_load): Map CID 0 to GID 0.  This
+	fixes Savannah bug #24430.
+
 2008-10-02  Werner Lemberg  <wl@gnu.org>
 
 	* builds/freetype.mk (BASE_H): Rename to...
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 22aded4..c64c6f4 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -2450,9 +2450,9 @@
   {
     FT_Error     error;
     CFF_Decoder  decoder;
-    TT_Face      face     = (TT_Face)glyph->root.face;
+    TT_Face      face = (TT_Face)glyph->root.face;
     FT_Bool      hinting, force_scaling;
-    CFF_Font     cff      = (CFF_Font)face->extra.data;
+    CFF_Font     cff  = (CFF_Font)face->extra.data;
 
     FT_Matrix    font_matrix;
     FT_Vector    font_offset;
@@ -2466,9 +2466,14 @@
     if ( cff->top_font.font_dict.cid_registry != 0xFFFFU &&
          cff->charset.cids                               )
     {
-      glyph_index = cff_charset_cid_to_gindex( &cff->charset, glyph_index );
-      if ( glyph_index == 0 )
-        return CFF_Err_Invalid_Argument;
+      /* don't handle CID 0 (.notdef) which is directly mapped to GID 0 */
+      if ( glyph_index != 0 )
+      {
+        glyph_index = cff_charset_cid_to_gindex( &cff->charset,
+                                                 glyph_index );
+        if ( glyph_index == 0 )
+          return CFF_Err_Invalid_Argument;
+      }
     }
     else if ( glyph_index >= cff->num_glyphs )
       return CFF_Err_Invalid_Argument;