freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 8ed5346: [psaux, type1] Trace PostScript dictionaries


From: Werner LEMBERG
Subject: [freetype2] master 8ed5346: [psaux, type1] Trace PostScript dictionaries and other things.
Date: Wed, 25 Jul 2018 16:08:04 -0400 (EDT)

branch: master
commit 8ed53468772ec0bc70d121cc1af2c77b1a15e8d0
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [psaux, type1] Trace PostScript dictionaries and other things.
    
    The tracing of /Encoding, /Subrs, and /Charstrings is rudimentary
    right now.
    
    * src/psaux/psobjs.c (ps_parser_load_field,
    ps_parser_load_field_table): Add tracing calls.
    
    * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Make tracing
    output more compact.
    
    * src/type1/t1gload.c (T1_Compute_Max_Advance, T1_Get_Advances): Add
    tracing messages.
    
    * src/type1/t1load.c (parse_blend_axis_types,
    parse_blend_design_positions, parse_blend_design_map,
    parse_weight_vector, t1_load_keyword, t1_parse_font_matrix,
    parse_encoding, parse_subrs, parse_charstrings, T1_Open_Face): Add
    tracing calls.
    
    * src/type1/t1objs.c (T1_Face_Init): Add tracing call.
    
    * src/sfnt/sfobjs.c (sfnt_init_face): Make tracing message more
    verbose.
---
 ChangeLog            |  27 ++++++++++++++
 src/cff/cffparse.c   |   1 +
 src/psaux/psobjs.c   |  29 +++++++++++++++
 src/psaux/t1decode.c |   6 ++--
 src/sfnt/sfobjs.c    |   4 ++-
 src/type1/t1gload.c  |  17 +++++++++
 src/type1/t1load.c   | 100 +++++++++++++++++++++++++++++++++++++++++++++++++--
 src/type1/t1objs.c   |   4 +++
 8 files changed, 182 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fdc9662..9f787aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,32 @@
 2018-07-25  Werner Lemberg  <address@hidden>
 
+       [psaux, type1] Trace PostScript dictionaries and other things.
+
+       The tracing of /Encoding, /Subrs, and /Charstrings is rudimentary
+       right now.
+
+       * src/psaux/psobjs.c (ps_parser_load_field,
+       ps_parser_load_field_table): Add tracing calls.
+
+       * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Make tracing
+       output more compact.
+
+       * src/type1/t1gload.c (T1_Compute_Max_Advance, T1_Get_Advances): Add
+       tracing messages.
+
+       * src/type1/t1load.c (parse_blend_axis_types,
+       parse_blend_design_positions, parse_blend_design_map,
+       parse_weight_vector, t1_load_keyword, t1_parse_font_matrix,
+       parse_encoding, parse_subrs, parse_charstrings, T1_Open_Face): Add
+       tracing calls.
+
+       * src/type1/t1objs.c (T1_Face_Init): Add tracing call.
+
+       * src/sfnt/sfobjs.c (sfnt_init_face): Make tracing message more
+       verbose.
+
+2018-07-25  Werner Lemberg  <address@hidden>
+
        Fix minor ASAN run-time warnings.
 
        * src/base/ftutil.c (ft_mem_alloc, ft_mem_realloc): Only call
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 0e5f951..b6f5dae 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -1146,6 +1146,7 @@
     {
       FT_UInt  v = *p;
 
+
       /* Opcode 31 is legacy MM T2 operator, not a number.      */
       /* Opcode 255 is reserved and should not appear in fonts; */
       /* it is used internally for CFF2 blends.                 */
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index f22c5b9..36ee663 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -1108,18 +1108,22 @@
       {
       case T1_FIELD_TYPE_BOOL:
         val = ps_tobool( &cur, limit );
+        FT_TRACE4(( " %s", val ? "true" : "false" ));
         goto Store_Integer;
 
       case T1_FIELD_TYPE_FIXED:
         val = PS_Conv_ToFixed( &cur, limit, 0 );
+        FT_TRACE4(( " %f", (double)val / 65536 ));
         goto Store_Integer;
 
       case T1_FIELD_TYPE_FIXED_1000:
         val = PS_Conv_ToFixed( &cur, limit, 3 );
+        FT_TRACE4(( " %f", (double)val / 65536 / 1000 ));
         goto Store_Integer;
 
       case T1_FIELD_TYPE_INTEGER:
         val = PS_Conv_ToInt( &cur, limit );
+        FT_TRACE4(( " %ld", val ));
         /* fall through */
 
       Store_Integer:
@@ -1196,6 +1200,13 @@
           FT_MEM_COPY( string, cur, len );
           string[len] = 0;
 
+#ifdef FT_DEBUG_LEVEL_TRACE
+          if ( token.type == T1_TOKEN_TYPE_STRING )
+            FT_TRACE4(( " (%s)", string ));
+          else
+            FT_TRACE4(( " /%s", string ));
+#endif
+
           *(FT_String**)q = string;
         }
         break;
@@ -1221,6 +1232,12 @@
           bbox->yMin = FT_RoundFix( temp[1] );
           bbox->xMax = FT_RoundFix( temp[2] );
           bbox->yMax = FT_RoundFix( temp[3] );
+
+          FT_TRACE4(( " [%d %d %d %d]",
+                      bbox->xMin / 65536,
+                      bbox->yMin / 65536,
+                      bbox->xMax / 65536,
+                      bbox->yMax / 65536 ));
         }
         break;
 
@@ -1259,6 +1276,7 @@
             skip_spaces( &cur, limit );
           }
 
+          FT_TRACE4(( " [" ));
           for ( i = 0; i < max_objects; i++ )
           {
             FT_BBox*  bbox = (FT_BBox*)objects[i];
@@ -1268,7 +1286,14 @@
             bbox->yMin = FT_RoundFix( temp[i +     max_objects] );
             bbox->xMax = FT_RoundFix( temp[i + 2 * max_objects] );
             bbox->yMax = FT_RoundFix( temp[i + 3 * max_objects] );
+
+            FT_TRACE4(( " [%d %d %d %d]",
+                        bbox->xMin / 65536,
+                        bbox->yMin / 65536,
+                        bbox->xMax / 65536,
+                        bbox->yMax / 65536 ));
           }
+          FT_TRACE4(( "]" ));
 
           FT_FREE( temp );
         }
@@ -1341,6 +1366,8 @@
       *(FT_Byte*)( (FT_Byte*)objects[0] + field->count_offset ) =
         (FT_Byte)num_elements;
 
+    FT_TRACE4(( " [" ));
+
     /* we now load each element, adjusting the field.offset on each one */
     token = elements;
     for ( ; num_elements > 0; num_elements--, token++ )
@@ -1359,6 +1386,8 @@
       fieldrec.offset += fieldrec.size;
     }
 
+    FT_TRACE4(( "]" ));
+
 #if 0  /* obsolete -- keep for reference */
     if ( pflags )
       *pflags |= 1L << field->flag_bit;
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index 6bbce4d..b763e35 100644
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -479,9 +479,6 @@
     if ( decoder->buildchar && decoder->len_buildchar > 0 )
       FT_ARRAY_ZERO( decoder->buildchar, decoder->len_buildchar );
 
-    FT_TRACE4(( "\n"
-                "Start charstring\n" ));
-
     zone->base           = charstring_base;
     limit = zone->limit  = charstring_base + charstring_len;
     ip    = zone->cursor = zone->base;
@@ -1237,7 +1234,10 @@
           /* the glyph's metrics (lsb + advance width), not load the   */
           /* rest of it; so exit immediately                           */
           if ( builder->metrics_only )
+          {
+            FT_TRACE4(( "\n" ));
             return FT_Err_Ok;
+          }
 
           break;
 
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 7777db1..03e49a9 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -918,7 +918,9 @@
     /* Stream may have changed in sfnt_open_font. */
     stream = face->root.stream;
 
-    FT_TRACE2(( "sfnt_init_face: %08p, %d\n", face, face_instance_index ));
+    FT_TRACE2(( "sfnt_init_face: %08p (index %d)\n",
+                face,
+                face_instance_index ));
 
     face_index = FT_ABS( face_instance_index ) & 0xFFFF;
 
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index de97e29..c1d5de4 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -62,6 +62,7 @@
     PS_Driver  driver = (PS_Driver)FT_FACE_DRIVER( face );
 #endif
 
+
     decoder->font_matrix = type1->font_matrix;
     decoder->font_offset = type1->font_offset;
 
@@ -249,6 +250,8 @@
 
     *max_advance = 0;
 
+    FT_TRACE6(( "T1_Compute_Max_Advance: start parsing glyphs\n" ));
+
     /* for each glyph, parse the glyph charstring and extract */
     /* the advance width                                      */
     for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
@@ -261,6 +264,10 @@
       /* ignore the error if one occurred - skip to next glyph */
     }
 
+    FT_TRACE6(( "T1_Compute_Max_Advance: parsing glyphs done\n"
+                "                        max advance: %f\n",
+                *max_advance / 65536.0 ));
+
     psaux->t1_decoder_funcs->done( &decoder );
 
     return FT_Err_Ok;
@@ -285,8 +292,13 @@
     if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
     {
       for ( nn = 0; nn < count; nn++ )
+      {
         advances[nn] = 0;
 
+        FT_TRACE5(( "  idx %d: advance height 0 font units\n",
+                    first + nn ));
+      }
+
       return FT_Err_Ok;
     }
 
@@ -320,6 +332,11 @@
         advances[nn] = FIXED_TO_INT( decoder.builder.advance.x );
       else
         advances[nn] = 0;
+
+      FT_TRACE5(( "  idx %d: advance width %d font unit%s\n",
+                  first + nn,
+                  advances[nn],
+                  advances[nn] == 1 ? "" : "s" ));
     }
 
     return FT_Err_Ok;
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index a20d178..3e67223 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -716,6 +716,8 @@
     if ( error )
       goto Exit;
 
+    FT_TRACE4(( " [" ));
+
     blend  = face->blend;
     memory = face->root.memory;
 
@@ -738,11 +740,13 @@
         goto Exit;
       }
 
+      FT_TRACE4(( " /%.*s", len, token->start ));
+
       name = (FT_Byte*)blend->axis_names[n];
       if ( name )
       {
         FT_TRACE0(( "parse_blend_axis_types:"
-                    " overwriting axis name `%s' with `%*.s'\n",
+                    " overwriting axis name `%s' with `%.*s'\n",
                     name, len, token->start ));
         FT_FREE( name );
       }
@@ -755,6 +759,8 @@
       name[len] = '\0';
     }
 
+    FT_TRACE4(( "]\n" ));
+
   Exit:
     loader->parser.root.error = error;
   }
@@ -799,6 +805,8 @@
       blend    = face->blend;
       num_axis = 0;  /* make compiler happy */
 
+      FT_TRACE4(( " [" ));
+
       for ( n = 0; n < num_designs; n++ )
       {
         T1_TokenRec  axis_tokens[T1_MAX_MM_AXIS];
@@ -839,6 +847,7 @@
         }
 
         /* now read each axis token into the design position */
+        FT_TRACE4(( " [" )) ;
         for ( axis = 0; axis < n_axis; axis++ )
         {
           T1_Token  token2 = axis_tokens + axis;
@@ -847,9 +856,13 @@
           parser->root.cursor = token2->start;
           parser->root.limit  = token2->limit;
           blend->design_pos[n][axis] = T1_ToFixed( parser, 0 );
+          FT_TRACE4(( " %f", (double)blend->design_pos[n][axis] / 65536 ));
         }
+        FT_TRACE4(( "]" )) ;
       }
 
+      FT_TRACE4(( "]\n" ));
+
       loader->parser.root.cursor = old_cursor;
       loader->parser.root.limit  = old_limit;
     }
@@ -896,6 +909,8 @@
       goto Exit;
     blend = face->blend;
 
+    FT_TRACE4(( " [" ));
+
     /* now read each axis design map */
     for ( n = 0; n < num_axis; n++ )
     {
@@ -912,6 +927,8 @@
       T1_ToTokenArray( parser, point_tokens,
                        T1_MAX_MM_MAP_POINTS, &num_points );
 
+      FT_TRACE4(( " [" ));
+
       if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS )
       {
         FT_ERROR(( "parse_blend_design_map: incorrect table\n" ));
@@ -945,9 +962,17 @@
 
         map->design_points[p] = T1_ToInt( parser );
         map->blend_points [p] = T1_ToFixed( parser, 0 );
+
+        FT_TRACE4(( " [%d %f]",
+                    map->design_points[p],
+                    (double)map->blend_points[p] / 65536 ));
       }
+
+      FT_TRACE4(( "]" ));
     }
 
+    FT_TRACE4(( "]\n" ));
+
     parser->root.cursor = old_cursor;
     parser->root.limit  = old_limit;
 
@@ -1007,6 +1032,8 @@
     old_cursor = parser->root.cursor;
     old_limit  = parser->root.limit;
 
+    FT_TRACE4(( "[" ));
+
     for ( n = 0; n < num_designs; n++ )
     {
       token = design_tokens + n;
@@ -1015,8 +1042,12 @@
 
       blend->default_weight_vector[n] =
       blend->weight_vector[n]         = T1_ToFixed( parser, 0 );
+
+      FT_TRACE4(( " %f", (float)blend->weight_vector[n] / 65536 ));
     }
 
+    FT_TRACE4(( "]\n" ));
+
     parser->root.cursor = old_cursor;
     parser->root.limit  = old_limit;
 
@@ -1031,8 +1062,16 @@
   parse_buildchar( T1_Face    face,
                    T1_Loader  loader )
   {
+    FT_UInt  i;
+
+
     face->len_buildchar = (FT_UInt)T1_ToFixedArray( &loader->parser,
                                                     0, NULL, 0 );
+    FT_TRACE4(( " [" ));
+    for ( i = 0; i < face->len_buildchar; i++ )
+      FT_TRACE4(( " 0" ));
+
+    FT_TRACE4(( "]\n" ));
     return;
   }
 
@@ -1068,6 +1107,8 @@
     /* if the keyword has a dedicated callback, call it */
     if ( field->type == T1_FIELD_TYPE_CALLBACK )
     {
+      FT_TRACE4(( "  %s", field->ident ));
+
       field->reader( (FT_Face)face, loader );
       error = loader->parser.root.error;
       goto Exit;
@@ -1145,6 +1186,8 @@
       max_objects  = 0;
     }
 
+    FT_TRACE4(( "  %s", field->ident ));
+
     if ( *objects )
     {
       if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
@@ -1164,6 +1207,8 @@
       error = FT_Err_Ok;
     }
 
+    FT_TRACE4(( "\n" ));
+
   Exit:
     return error;
   }
@@ -1176,6 +1221,8 @@
     FT_UNUSED( face );
 
     loader->keywords_encountered |= T1_PRIVATE;
+
+    FT_TRACE4(( "\n" ));
   }
 
 
@@ -1255,6 +1302,14 @@
       return;
     }
 
+    FT_TRACE4(( " [%f %f %f %f %f %f]\n",
+                (double)temp[0] / 65536 / 1000,
+                (double)temp[1] / 65536 / 1000,
+                (double)temp[2] / 65536 / 1000,
+                (double)temp[3] / 65536 / 1000,
+                (double)temp[4] / 65536 / 1000,
+                (double)temp[5] / 65536 / 1000));
+
     temp_scale = FT_ABS( temp[3] );
 
     if ( temp_scale == 0 )
@@ -1277,7 +1332,6 @@
       temp[5] = FT_DivFix( temp[5], temp_scale );
       temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
     }
-
     matrix->xx = temp[0];
     matrix->yx = temp[1];
     matrix->xy = temp[2];
@@ -1498,6 +1552,15 @@
         T1_Skip_Spaces( parser );
       }
 
+#ifdef FT_DEBUG_LEVEL_TRACE
+      FT_TRACE4(( " [" ));
+
+      /* XXX show encoding vector */
+      FT_TRACE4(( "..." ));
+
+      FT_TRACE4(( "]\n" ));
+#endif
+
       face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
       parser->root.cursor       = cur;
     }
@@ -1508,18 +1571,30 @@
     {
       if ( cur + 17 < limit                                            &&
            ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
+      {
         face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD;
+        FT_TRACE4(( " StandardEncoding\n" ));
+      }
 
       else if ( cur + 15 < limit                                          &&
                 ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
+      {
         face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT;
+        FT_TRACE4(( " ExpertEncoding\n" ));
+      }
 
       else if ( cur + 18 < limit                                             &&
                 ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
+      {
         face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
+        FT_TRACE4(( " ISOLatin1Encoding\n" ));
+      }
 
       else
+      {
         parser->root.error = FT_ERR( Ignore );
+        FT_TRACE4(( "<unknown>\n" ));
+      }
     }
   }
 
@@ -1700,6 +1775,15 @@
     if ( !loader->num_subrs )
       loader->num_subrs = num_subrs;
 
+#ifdef FT_DEBUG_LEVEL_TRACE
+      FT_TRACE4(( " <" ));
+
+      /* XXX show subrs? */
+      FT_TRACE4(( "%d elements", num_subrs ));
+
+      FT_TRACE4(( ">\n" ));
+#endif
+
     return;
 
   Fail:
@@ -2021,6 +2105,15 @@
       loader->num_glyphs += 1;
     }
 
+#ifdef FT_DEBUG_LEVEL_TRACE
+      FT_TRACE4(( " <" ));
+
+      /* XXX show charstrings? */
+      FT_TRACE4(( "%d elements", loader->num_glyphs ));
+
+      FT_TRACE4(( ">\n" ));
+#endif
+
     return;
 
   Fail:
@@ -2220,6 +2313,7 @@
                     ? T1_FIELD_DICT_PRIVATE
                     : T1_FIELD_DICT_FONTDICT;
 
+
               if ( !( dict & keyword->dict ) )
               {
                 FT_TRACE1(( "parse_dict: found `%s' but ignoring it"
@@ -2334,6 +2428,7 @@
     if ( error )
       goto Exit;
 
+    FT_TRACE4(( " top dictionary:\n" ));
     error = parse_dict( face, &loader,
                         parser->base_dict, parser->base_len );
     if ( error )
@@ -2343,6 +2438,7 @@
     if ( error )
       goto Exit;
 
+    FT_TRACE4(( " private dictionary:\n" ));
     error = parse_dict( face, &loader,
                         parser->private_dict, parser->private_len );
     if ( error )
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 568440d..05f02d5 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -347,6 +347,10 @@
     if ( error )
       goto Exit;
 
+    FT_TRACE2(( "T1_Face_Init: %08p (index %d)\n",
+                face,
+                face_index ));
+
     /* if we just wanted to check the format, leave successfully now */
     if ( face_index < 0 )
       goto Exit;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]