shithub: freetype+ttf2subf

Download patch

ref: 877ff67887184a1f8edbccafc39c2ee3a5d88aa3
parent: 791d83a612ac9bbdd185dd3ad8ec7034e40a3959
author: Werner Lemberg <[email protected]>
date: Tue May 28 02:03:10 EDT 2002

* src/base/ftnames.c (FT_Get_Sfnt_Name): Don't use FT_STREAM_READ_AT
but FT_STREAM_READ.
Declare `stream' variable.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,19 +1,40 @@
+2002-05-29  Werner Lemberg  <[email protected]>
+
+	* src/base/ftnames.c (FT_Get_Sfnt_Name): Don't use FT_STREAM_READ_AT
+	but FT_STREAM_READ.
+	Declare `stream' variable.
+
 2002-05-28  David Turner  <[email protected]>
 
-    * include/freetype/internal/tttypes.h, src/sfnt/ttload.c,
-      src/sfnt/sfobjs.c, src/sfnt/sfdriver.c, src/base/ftnames.c:
-        fixing the SFNT name table loader to support various buggy fonts.
-        it now ignores empty name entries, entries with invalid pointer
-        offsets and certain fonts containing tables with broken "storageOffset"
-        fields.
+	Fixing the SFNT name table loader to support various buggy fonts. 
+	It now ignores empty name entries, entries with invalid pointer
+	Offsets and certain fonts containing tables with broken
+	"storageOffset" fields.
 
-        name strings are now loaded on demand, which reduces the memory
-        requirements for a given FT_Face tremendously (for example, the
-        name table of Arial.ttf is about 10Kb and contains 70 names !!)
+	Name strings are now loaded on demand, which reduces the memory
+	requirements for a given FT_Face tremendously (for example, the name
+	table of Arial.ttf is about 10Kb and contains 70 names).
 
-        finally, this is a _quick_ fix. The whole name table loader and
-        interface will be rewritten in a much more cleanly way shortly,
-        once CSEH have been introduced in the sources.
+	This is a temporary fix.  The whole name table loader and interface
+	will be rewritten in a much more cleanly way shortly, once CSEH have
+	been introduced in the sources.
+
+	* include/freetype/internal/tttypes.h (TT_NameEntryRec): Change
+	type of `stringOffset' to FT_ULong.
+	(TT_NameTableRec): Change type of `numNameRecords' and
+	`storageOffset' to FT_UInt.
+	Replace `storage' with `stream'.
+	* src/base/ftnames.c (FT_Get_Sfnt_Name): Load name on demand.
+	* src/sfnt/sfdriver.c (get_sfnt_postscript_name): Ditto.
+	Make code more robust.
+	* src/sfnt/sfobjs.c (TT_NameEntry_ConvertFunc): New typedef.
+	(tt_face_get_name): Use it.
+	Make code more robust.
+	* src/sfnt/ttload.c (TT_Load_Names): Use `static' for arrays.
+	Handle invalid `storageOffset' data better.
+	Set length fields to zero for invalid or ignored data.
+	Remove code within FT_DEBUG_LEVEL_TRACE.
+	(TT_Free_Names): Updated.
 
 2002-05-24  Tim Mooney  <[email protected]>
 
--- a/src/base/ftnames.c
+++ b/src/base/ftnames.c
@@ -60,11 +60,12 @@
         if ( entry->stringLength > 0 && entry->string == NULL )
         {
           FT_Memory  memory = face->memory;
+          FT_Stream  stream = face->stream;
 
 
-          if ( FT_NEW_ARRAY     ( entry->string, entry->stringLength ) ||
-               FT_STREAM_SEEK   ( entry->stringOffset )                ||
-               FT_STREAM_READ_AT( entry->string, entry->stringLength ) )
+          if ( FT_NEW_ARRAY  ( entry->string, entry->stringLength ) ||
+               FT_STREAM_SEEK( entry->stringOffset )                ||
+               FT_STREAM_READ( entry->string, entry->stringLength ) )
           {
             FT_FREE( entry->string );
             entry->stringLength = 0;
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -152,11 +152,11 @@
       FT_Error          error;
 
 
-      if ( !FT_ALLOC( result, name->stringLength+1 ) )
+      if ( !FT_ALLOC( result, name->stringLength + 1 ) )
       {
         FT_Stream   stream = face->name_table.stream;
-        FT_String*  r = (FT_String*)result;
-        FT_Byte*    p = (FT_Byte*)name->string;
+        FT_String*  r      = (FT_String*)result;
+        FT_Byte*    p      = (FT_Byte*)name->string;
 
 
         if ( FT_STREAM_SEEK( name->stringOffset ) ||
@@ -166,10 +166,11 @@
           name->stringLength = 0;
           name->stringOffset = 0;
           FT_FREE( name->string );
+
           goto Exit;
         }
 
-        p = (FT_Byte*) stream->cursor;
+        p = (FT_Byte*)stream->cursor;
 
         for ( ; len > 0; len--, p += 2 )
         {
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -132,6 +132,7 @@
   typedef FT_String*  (*TT_NameEntry_ConvertFunc)( TT_NameEntry  entry,
                                                    FT_Memory     memory );
 
+
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -161,6 +162,7 @@
     FT_Int            found_unicode = -1;
 
     TT_NameEntry_ConvertFunc  convert;
+
 
     rec = face->name_table.names;
     for ( n = 0; n < face->num_names; n++, rec++ )
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -967,7 +967,7 @@
     };
 
 
-    table     = &face->name_table;
+    table         = &face->name_table;
     table->stream = stream;
 
     FT_TRACE2(( "Names " ));
@@ -987,14 +987,13 @@
     if ( FT_STREAM_READ_FIELDS( name_table_fields, table ) )
       goto Exit;
 
-    /* some popular asian fonts have an invalid 'storageOffset' value  */
-    /* (it should be at least "6 + 12*num_names"). However, the string */
-    /* offsets, computed as "storageOffset + entry->stringOffset" are  */
-    /* valid pointers within the name table...                         */
-    /*                                                                 */
-    /* we thus can't check "storageOffset" right now                   */
-    /*                                                                 */
-
+    /* Some popular asian fonts have an invalid `storageOffset' value   */
+    /* (it should be at least "6 + 12*num_names").  However, the string */
+    /* offsets, computed as "storageOffset + entry->stringOffset", are  */
+    /* valid pointers within the name table...                          */
+    /*                                                                  */
+    /* We thus can't check `storageOffset' right now.                   */
+    /*                                                                  */
     storage_start = table_pos + 6 + 12*table->numNameRecords;
     storage_limit = table_pos + table_len;