Commit fed59b7cc2294cb4020993a9761d1abc9bfdd6f2

David Turner 2002-07-17T22:51:06

* src/sfnt/ttload.c (TT_Load_SFNT_Header): fixed a recent bug that prevented OpenType fonts to be recognized by FreeType

diff --git a/ChangeLog b/ChangeLog
index 964002b..484fe3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,8 +8,12 @@
     src/base/ftobjs.c, src/bdf/bdfdrivr.c, src/cff/cffobjs.c,
     src/pcf/pcfdrivr.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c,
     src/sfnt/ttcmap0.h, src/sfnt/ttload.c, src/type1/t1objs.c,
-    src/type42/t42objs.c, src/winfonts/winfnt.c: code cleanup,
-    FT_CONFIG_OPTION_USE_CMAPS is now the default
+    src/type42/t42objs.c, src/type42/t42objs.h, src/type42/t42drivr.c,
+    src/winfonts/winfnt.c: code cleanup, FT_CONFIG_OPTION_USE_CMAPS is now
+    the default
+
+    * src/sfnt/ttload.c (TT_Load_SFNT_Header): fixed a recent bug that prevented
+    OpenType fonts to be recognized by FreeType
 
 2002-07-11  David Turner  <david@freetype.org>
 
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index d5fb518..752c532 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -733,6 +733,26 @@
     if ( error )
       goto Fail;
 
+    /* select Unicode charmap by default */
+    {
+      FT_Int      nn;
+      FT_CharMap  unicmap = NULL, cmap;
+
+      for ( nn = 0; nn < face->num_charmaps; nn++ )
+      {
+        cmap = face->charmaps[nn];
+
+        if ( cmap->encoding == ft_encoding_unicode )
+        {
+          unicmap = cmap;
+          break;
+        }
+      }
+
+      if ( unicmap != NULL )
+        face->charmap = unicmap;
+    }
+
     *aface = face;
 
   Fail:
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index 5af8e3a..3773432 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -411,9 +411,11 @@ THE SOFTWARE.
 
               error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
 
+#if 0
               /* Select default charmap */
               if (root->num_charmaps)
                 root->charmap = root->charmaps[0];
+#endif
             }
 
             goto Exit;
diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c
index cc6cb91..812e2be 100644
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -266,9 +266,11 @@ THE SOFTWARE.
 
         error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
 
+#if 0
         /* Select default charmap */
         if (face->root.num_charmaps)
           face->root.charmap = face->root.charmaps[0];
+#endif
       }
     }
 
diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c
index 69fb7e1..3134e41 100644
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -167,18 +167,20 @@
        /* create charmap */
        {
          FT_CharMapRec  charmap;
-         
+
 
          charmap.face        = root;
          charmap.platform_id = 3;
          charmap.encoding_id = 1;
          charmap.encoding    = ft_encoding_unicode;
-         
+
          FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
 
+#if 0
          /* Select default charmap */
          if (root->num_charmaps)
            root->charmap = root->charmaps[0];
+#endif
        }
 
        /* check whether we've loaded any kerning pairs */
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 3b55d63..cf7f5ba 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -595,12 +595,14 @@
           charmap->encoding = sfnt_find_encoding( charmap->platform_id,
                                                   charmap->encoding_id );
 
+#if 0
           if ( root->charmap     == NULL &&
                charmap->encoding == ft_encoding_unicode )
           {
             /* set 'root->charmap' to the first Unicode encoding we find */
             root->charmap = charmap;
           }
+#endif
         }
       }
 
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 6fe6b3c..fc167f7 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -228,7 +228,7 @@
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
-  /*    TT_Load_SFNT_HeaderRec                                             */
+  /*    TT_Load_SFNT_Header                                                */
   /*                                                                       */
   /* <Description>                                                         */
   /*    Loads the header of a SFNT font file.  Supports collections.       */
@@ -345,9 +345,6 @@
         goto Exit;
     }
 
-    if ( format_tag != 0x10000UL && format_tag != 0x74727565UL )
-      goto Bad_Format;
-
     /* the format tag was read, now check the rest of the header */
     sfnt->format_tag = format_tag;
     sfnt->offset     = offset;
@@ -359,7 +356,6 @@
     error = sfnt_dir_check( stream, offset, sfnt->num_tables );
     if ( error )
     {
-    Bad_Format:
       FT_TRACE2(( "TT_Load_SFNT_Header: file is not SFNT!\n" ));
       error = SFNT_Err_Unknown_File_Format;
     }
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 64863de..51131ff 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -484,9 +484,11 @@
         if ( clazz )
           FT_CMap_New( clazz, NULL, &charmap, NULL );
 
+#if 0
         /* Select default charmap */
         if (root->num_charmaps)
           root->charmap = root->charmaps[0];
+#endif
       }
     }
 
diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c
index 3669d24..ae1d542 100644
--- a/src/type42/t42objs.c
+++ b/src/type42/t42objs.c
@@ -337,9 +337,11 @@
         if ( clazz )
           FT_CMap_New( clazz, NULL, &charmap, NULL );
 
+#if 0
         /* Select default charmap */
         if (root->num_charmaps)
           root->charmap = root->charmaps[0];
+#endif
       }
     }
   Exit: