shithub: freetype+ttf2subf

Download patch

ref: fed59b7cc2294cb4020993a9761d1abc9bfdd6f2
parent: 3e19d85dd46eed324791e4aa6fb4c97d76385c0e
author: David Turner <[email protected]>
date: Wed Jul 17 18:51:06 EDT 2002

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

git/fs: mount .git/fs: mount/attach disallowed
--- 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  <[email protected]>
 
--- 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:
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -411,9 +411,11 @@
 
               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;
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -266,9 +266,11 @@
 
         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
       }
     }
 
--- 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 */
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -595,6 +595,7 @@
           charmap->encoding = sfnt_find_encoding( charmap->platform_id,
                                                   charmap->encoding_id );
 
+#if 0
           if ( root->charmap     == NULL &&
                charmap->encoding == ft_encoding_unicode )
           {
@@ -601,6 +602,7 @@
             /* set 'root->charmap' to the first Unicode encoding we find */
             root->charmap = charmap;
           }
+#endif
         }
       }
 
--- 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;
     }
--- 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
       }
     }
 
--- 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: