* src/base/ftnames.c (FT_Get_Sfnt_Name): Don't use FT_STREAM_READ_AT


			
			
				BRANCH-2-1-5
			
			
		
Werner Lemberg 23 years ago
parent c9d2024e0e
commit aa9b8506c4
  1. 47
      ChangeLog
  2. 7
      src/base/ftnames.c
  3. 9
      src/sfnt/sfdriver.c
  4. 2
      src/sfnt/sfobjs.c
  5. 17
      src/sfnt/ttload.c

@ -1,19 +1,40 @@
2002-05-28 David Turner <david@freetype.org>
2002-05-29 Werner Lemberg <wl@gnu.org>
* 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.
* src/base/ftnames.c (FT_Get_Sfnt_Name): Don't use FT_STREAM_READ_AT
but FT_STREAM_READ.
Declare `stream' variable.
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 !!)
2002-05-28 David Turner <david@freetype.org>
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.
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).
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 <enchanter@users.sourceforge.net>

@ -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;

@ -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 )
{

@ -132,6 +132,7 @@
typedef FT_String* (*TT_NameEntry_ConvertFunc)( TT_NameEntry entry,
FT_Memory memory );
/*************************************************************************/
/* */
/* <Function> */
@ -162,6 +163,7 @@
TT_NameEntry_ConvertFunc convert;
rec = face->name_table.names;
for ( n = 0; n < face->num_names; n++, rec++ )
{

@ -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;

Loading…
Cancel
Save