Commit 3581d06464d3c964c112aeb9b28678f88fefed87

David Turner 2000-06-01T03:26:58

changed the SFNT format check to make it less strict. A certain number of TrueType fonts have invalid values in the SFNT header..

diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 72e9b54..8b1c7d9 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -165,7 +165,7 @@
            FT_FRAME_END };
 
     FT_TRACE2(( "TT_Load_SFNT_Header(%08p, %ld )\n",
-                face, faceIndex ));
+                face, face_index ));
 
     face->ttc_header.Tag      = 0;
     face->ttc_header.version  = 0;
@@ -224,13 +224,15 @@
     /* now, check the values of "num_tables", "seach_range", etc.. */
     {
       TT_UInt  num_tables     = sfnt->num_tables;
-      TT_UInt  search_range   = sfnt->search_range;
       TT_ULong entry_selector = 1L << sfnt->entry_selector;
-      
-      if ( entry_selector    > num_tables || entry_selector*2 <= num_tables ||
-           search_range  != 16*entry_selector ||
-           num_tables*16 != search_range + sfnt->range_shift )
-      {           
+
+      /* IMPORTANT: Many fonts have an incorrect "search_range" value, so    */
+      /*            we only check the "entry_selector" correctness here..    */
+      /*                                                                     */
+      if ( num_tables == 0                ||
+           entry_selector > num_tables    ||
+           entry_selector*2 <= num_tables )
+      {
         FT_TRACE2(( "TT_Load_SFNT_Header: file is not SFNT !\n" ));
         error = FT_Err_Unknown_File_Format;
       }
@@ -271,8 +273,8 @@
 
     TT_Table *entry, *limit;
 
-    FT_TRACE2(( "TT_Load_Directory( %08p, %ld )\n",
-                face, faceIndex ));
+    FT_TRACE2(( "TT_Load_Directory( %08p )\n",
+                face ));
 
     FT_TRACE2(( "-- Tables count   : %12u\n",  sfnt->num_tables ));
     FT_TRACE2(( "-- Format version : %08lx\n", sfnt->format_tag ));