* src/base/ftnames.c (FT_Get_Sfnt_Name): Don't use FT_STREAM_READ_AT but FT_STREAM_READ. Declare `stream' variable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
diff --git a/ChangeLog b/ChangeLog
index 0696765..305c06f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
diff --git a/src/base/ftnames.c b/src/base/ftnames.c
index 9527583..74d7054 100644
--- 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;
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index e3a67ec..f0316e2 100644
--- 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 )
{
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index b9bbb33..fb67235 100644
--- 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> */
@@ -162,6 +163,7 @@
TT_NameEntry_ConvertFunc convert;
+
rec = face->name_table.names;
for ( n = 0; n < face->num_names; n++, rec++ )
{
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index d8fed1f..dbd9461 100644
--- 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;