shithub: freetype+ttf2subf

Download patch

ref: 2d3e0af942eada7dbfe8475df89f687c3f14cbeb
parent: 21bd5165927ec8e694e632fc0ef44cb2c5ddc2d6
author: Suzuki, Toshiya (鈴木俊哉) <[email protected]>
date: Sat Oct 4 22:38:57 EDT 2008

* `FT_Open_Face' tries `open_face_PS_from_sfnt_stream' when a sfnt container is found but not OpenType.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2008-10-05  suzuki toshiya  <[email protected]>
+
+	* src/sfnt/sfobjs.c (sfnt_open_font): Allow 'typ1' version
+	tag in the beginning of sfnt container.
+	* src/sfnt/ttload.c (check_table_dir): Return
+	`SFNT_Err_Table_Missing' when sfnt table directory structure
+	is correct but essential tables for TrueType fonts (`head',
+	`bhed' or `SING') are missing. Other errors are returned
+	by SFNT_Err_Unknown_File_Format.
+
+	* src/base/ftobjs.c (FT_Open_Face): When TrueType driver returns
+	`FT_Err_Table_Missing', try  `open_face_PS_from_sfnt_stream'.
+	It is enabled only when old mac font support is configured.
+
 2008-10-04  suzuki toshiya  <[email protected]>
 
 	* include/freetype/tttags.h: Add TTAG_CID, TTAG_FOND, TTAG_LWFN,
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1951,6 +1951,28 @@
           if ( !error )
             goto Success;
 
+#ifdef FT_CONFIG_OPTION_MAC_FONTS
+          if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 &&
+               FT_ERROR_BASE( error ) == FT_Err_Table_Missing )
+          {
+            /* TrueType but essential tables are missing */
+            if ( FT_Stream_Seek( stream, 0 ) )
+              break;
+
+            error = open_face_PS_from_sfnt_stream( library,
+                                                   stream,
+                                                   face_index,
+                                                   num_params,
+                                                   params,
+                                                   aface );
+            if ( !error )
+            {
+              FT_Stream_Free( stream, external_stream );
+              return error;
+            }
+          }
+#endif
+
           if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format )
             goto Fail3;
         }
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -367,6 +367,7 @@
          tag != TTAG_ttcf                         &&
          tag != TTAG_OTTO                         &&
          tag != TTAG_true                         &&
+         tag != TTAG_typ1                         &&
          tag != 0x00020000UL                      )
       return SFNT_Err_Unknown_File_Format;
 
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -141,6 +141,13 @@
   /* - look for a `head' table, check its size, and parse it to check */
   /*   whether its `magic' field is correctly set                     */
   /*                                                                  */
+  /* - errors (except of errors returned by stream handling)          */
+  /*                                                                  */
+  /* SFNT_Err_Unknown_File_Format: no table is defined in directory,  */
+  /*                               it's not sfnt-wrapped data.        */
+  /* SFNT_Err_Table_Missing: table directory is valid, but essential  */
+  /*                         tables (head/bhed/SING) are missing.     */
+  /*                                                                  */
   static FT_Error
   check_table_dir( SFNT_Header  sfnt,
                    FT_Stream    stream )
@@ -213,7 +220,7 @@
         if ( table.Length < 0x36 )
         {
           FT_TRACE2(( "check_table_dir: `head' table too small\n" ));
-          error = SFNT_Err_Unknown_File_Format;
+          error = SFNT_Err_Table_Missing;
           goto Exit;
         }
 
@@ -225,7 +232,7 @@
         {
           FT_TRACE2(( "check_table_dir:"
                       " no magic number found in `head' table\n"));
-          error = SFNT_Err_Unknown_File_Format;
+          error = SFNT_Err_Table_Missing;
           goto Exit;
         }
 
@@ -261,7 +268,7 @@
 #else
       FT_TRACE2(( " neither `head' nor `sing' table found\n" ));
 #endif
-      error = SFNT_Err_Unknown_File_Format;
+      error = SFNT_Err_Table_Missing;
     }
 
   Exit:
@@ -341,7 +348,7 @@
     error = check_table_dir( &sfnt, stream );
     if ( error )
     {
-      FT_TRACE2(( "tt_face_load_font_dir: invalid table directory!\n" ));
+      FT_TRACE2(( "tt_face_load_font_dir: invalid table directory for TrueType!\n" ));
 
       goto Exit;
     }