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

but FT_STREAM_READ.
Declare `stream' variable.
This commit is contained in:
Werner Lemberg 2002-05-28 06:03:10 +00:00
parent c9d2024e0e
commit aa9b8506c4
5 changed files with 52 additions and 28 deletions

View File

@ -1,19 +1,40 @@
2002-05-29 Werner Lemberg <wl@gnu.org>
* 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 <david@freetype.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.
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 <enchanter@users.sourceforge.net>

View File

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

View File

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

View File

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

View File

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