Commit 32b14552d662f28290e2792ce775fcd65397479a

Werner Lemberg 2020-11-09T21:00:45

* src/type42/t42parse.c (t42_parse_sfnts): More tracing messages.

diff --git a/ChangeLog b/ChangeLog
index f296352..ae007eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2020-11-09  Werner Lemberg  <wl@gnu.org>
+
+	* src/type42/t42parse.c (t42_parse_sfnts): More tracing messages.
+
 2020-11-04  Werner Lemberg  <wl@gnu.org>
 
 	* meson.build: Fix .pc file generation.
diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c
index 9850769..88877dd 100644
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -576,6 +576,9 @@
     old_string_size = 0;
     count           = 0;
 
+    FT_TRACE2(( "\n" ));
+    FT_TRACE2(( "t42_parse_sfnts:\n" ));
+
     while ( parser->root.cursor < limit )
     {
       FT_ULong  size;
@@ -680,6 +683,9 @@
         goto Fail;
       }
 
+      FT_TRACE2(( "  PS string size %5lu bytes, offset 0x%08x (%lu)\n",
+                  string_size, count, count ));
+
       /* The whole TTF is now loaded into `string_buf'.  We are */
       /* checking its contents while copying it to `ttf_data'.  */
 
@@ -702,6 +708,9 @@
             status         = BEFORE_TABLE_DIR;
             face->ttf_size = 12 + 16 * num_tables;
 
+            FT_TRACE2(( "  SFNT directory contains %d tables\n",
+                        num_tables ));
+
             if ( (FT_Long)size < face->ttf_size )
             {
               FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
@@ -727,12 +736,18 @@
             FT_ULong  len;
 
 
+            FT_TRACE2(( "\n" ));
+            FT_TRACE2(( "  table    length\n" ));
+            FT_TRACE2(( "  ------------------------------\n" ));
+
             for ( i = 0; i < num_tables; i++ )
             {
               FT_Byte*  p = face->ttf_data + 12 + 16 * i + 12;
 
 
               len = FT_PEEK_ULONG( p );
+              FT_TRACE2(( "   %4i  0x%08x (%lu)\n", i, len, len ));
+
               if ( len > size                               ||
                    face->ttf_size > (FT_Long)( size - len ) )
               {
@@ -748,6 +763,10 @@
 
             status = OTHER_TABLES;
 
+            FT_TRACE2(( "\n" ));
+            FT_TRACE2(( "  allocating %ld bytes\n", face->ttf_size + 1 ));
+            FT_TRACE2(( "\n" ));
+
             if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
                              face->ttf_size + 1 ) )
               goto Fail;