shithub: freetype+ttf2subf

Download patch

ref: 83efe779e3e3c34af5f3cde93a12b97247f806c6
parent: 11785f56e5d71715fd67359719458257441abf5c
author: Werner Lemberg <[email protected]>
date: Tue Jun 22 02:24:09 EDT 2004

* src/pcf/pcfread.c (pcf_read_TOC, pcf_get_properties,
pcf_get_metrics, pcf_get_bitmaps, pcf_get_encodings): Improve
debugging messages.

* src/pcf/pcfdrivr.c (FT_COMPOMENT): Move up.
(PCF_Face_Init): Simplify code.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-06-22  Werner Lemberg  <[email protected]>
+
+	* src/pcf/pcfread.c (pcf_read_TOC, pcf_get_properties,
+	pcf_get_metrics, pcf_get_bitmaps, pcf_get_encodings): Improve
+	debugging messages.
+
+	* src/pcf/pcfdrivr.c (FT_COMPOMENT): Move up.
+	(PCF_Face_Init): Simplify code.
+
 2004-06-21  Werner Lemberg  <[email protected]>
 
 	* docs/CHANGES: Updated.
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -49,6 +49,16 @@
 #include FT_SERVICE_XFREE86_NAME_H
 
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
+  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
+  /* messages during execution.                                            */
+  /*                                                                       */
+#undef  FT_COMPONENT
+#define FT_COMPONENT  trace_pcfdriver
+
+
   typedef struct  PCF_CMapRec_
   {
     FT_CMapRec    root;
@@ -170,9 +180,10 @@
   }
 
 
-  FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec  pcf_cmap_class =
+  FT_CALLBACK_TABLE_DEF
+  const FT_CMap_ClassRec  pcf_cmap_class =
   {
-    sizeof( PCF_CMapRec ),
+    sizeof ( PCF_CMapRec ),
     pcf_cmap_init,
     pcf_cmap_done,
     pcf_cmap_char_index,
@@ -180,16 +191,6 @@
   };
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
-  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
-  /* messages during execution.                                            */
-  /*                                                                       */
-#undef  FT_COMPONENT
-#define FT_COMPONENT  trace_pcfdriver
-
-
   FT_CALLBACK_DEF( void )
   PCF_Face_Done( FT_Face  pcfface )         /* PCF_Face */
   {
@@ -298,19 +299,16 @@
       }
     }
 
-    /* set-up charmap */
+    /* set up charmap */
     {
-      FT_String  *charset_registry, *charset_encoding;
+      FT_String  *charset_registry = face->charset_registry;
+      FT_String  *charset_encoding = face->charset_encoding;
       FT_Bool     unicode_charmap  = 0;
 
 
-      charset_registry = face->charset_registry;
-      charset_encoding = face->charset_encoding;
-
-      if ( ( charset_registry != NULL ) &&
-           ( charset_encoding != NULL ) )
+      if ( charset_registry && charset_encoding )
       {
-        char*  s = face->charset_registry;
+        char*  s = charset_registry;
 
 
         /* Uh, oh, compare first letters manually to avoid dependency
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -122,7 +122,10 @@
       const char*  name = "?";
 
 
-      FT_TRACE4(( "Tables count: %ld\n", face->toc.count ));
+      FT_TRACE4(( "pcf_read_TOC:\n" ));
+
+      FT_TRACE4(( "  number of tables: %ld\n", face->toc.count ));
+
       tables = face->toc.tables;
       for ( i = 0; i < toc->count; i++ )
       {
@@ -130,12 +133,12 @@
           if ( tables[i].type == (FT_UInt)( 1 << j ) )
             name = tableNames[j];
 
-        FT_TRACE4(( "Table %d: type=%-6s format=0x%04lX "
-                    "size=0x%06lX (%8ld) offset=0x%04lX\n",
+        FT_TRACE4(( "  %d: type=%s, format=0x%X, "
+                    "size=%ld (0x%lX), offset=%ld (0x%lX)\n",
                     i, name,
                     tables[i].format,
                     tables[i].size, tables[i].size,
-                    tables[i].offset ));
+                    tables[i].offset, tables[i].offset ));
       }
     }
 
@@ -370,8 +373,10 @@
     if ( FT_READ_ULONG_LE( format ) )
       goto Bail;
 
-    FT_TRACE4(( "get_prop: format = %ld\n", format ));
+    FT_TRACE4(( "pcf_get_properties:\n" ));
 
+    FT_TRACE4(( "  format = %ld\n", format ));
+
     if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
       goto Bail;
 
@@ -382,7 +387,7 @@
     if ( error )
       goto Bail;
 
-    FT_TRACE4(( "get_prop: nprop = %d\n", nprops ));
+    FT_TRACE4(( "  nprop = %d\n", nprops ));
 
     if ( FT_NEW_ARRAY( props, nprops ) )
       goto Bail;
@@ -419,7 +424,7 @@
     if ( error )
       goto Bail;
 
-    FT_TRACE4(( "get_prop: string_size = %ld\n", string_size ));
+    FT_TRACE4(( "  string_size = %ld\n", string_size ));
 
     if ( FT_NEW_ARRAY( strings, string_size ) )
       goto Bail;
@@ -437,8 +442,10 @@
       if ( FT_NEW_ARRAY( properties[i].name,
                          ft_strlen( strings + props[i].name ) + 1 ) )
         goto Bail;
-      ft_strcpy( properties[i].name,strings + props[i].name );
+      ft_strcpy( properties[i].name, strings + props[i].name );
 
+      FT_TRACE4(( "  %s:", properties[i].name ));
+
       properties[i].isString = props[i].isString;
 
       if ( props[i].isString )
@@ -447,9 +454,15 @@
                            ft_strlen( strings + props[i].value ) + 1 ) )
           goto Bail;
         ft_strcpy( properties[i].value.atom, strings + props[i].value );
+
+        FT_TRACE4(( " `%s'\n", properties[i].value.atom ));
       }
       else
+      {
         properties[i].value.integer = props[i].value;
+
+        FT_TRACE4(( " %d\n", properties[i].value.integer ));
+      }
     }
 
     face->properties = properties;
@@ -518,6 +531,8 @@
     if ( FT_NEW_ARRAY( face->metrics, nmetrics ) )
       return PCF_Err_Out_Of_Memory;
 
+    FT_TRACE4(( "pcf_get_metrics:\n" ));
+
     metrics = face->metrics;
     for ( i = 0; i < nmetrics; i++ )
     {
@@ -525,7 +540,7 @@
 
       metrics[i].bits = 0;
 
-      FT_TRACE4(( "%d : width=%d, "
+      FT_TRACE4(( "  idx %d: width=%d, "
                   "lsb=%d, rsb=%d, ascent=%d, descent=%d, swidth=%d\n",
                   i,
                   ( metrics + i )->characterWidth,
@@ -588,6 +603,8 @@
     if ( FT_NEW_ARRAY( offsets, nbitmaps ) )
       return error;
 
+    FT_TRACE4(( "pcf_get_bitmaps:\n" ));
+
     for ( i = 0; i < nbitmaps; i++ )
     {
       if ( PCF_BYTE_ORDER( format ) == MSBFirst )
@@ -595,7 +612,8 @@
       else
         (void)FT_READ_LONG_LE( offsets[i] );
 
-      FT_TRACE4(( "bitmap %d is at offset %ld\n", i, offsets[i] ));
+      FT_TRACE4(( "  bitmap %d: offset %ld (0x%lX)\n",
+                  i, offsets[i], offsets[i] ));
     }
     if ( error )
       goto Bail;
@@ -611,13 +629,13 @@
 
       sizebitmaps = bitmapSizes[PCF_GLYPH_PAD_INDEX( format )];
 
-      FT_TRACE4(( "padding %d implies a size of %ld\n", i, bitmapSizes[i] ));
+      FT_TRACE4(( "  padding %d implies a size of %ld\n", i, bitmapSizes[i] ));
     }
 
     FT_TRACE4(( "  %d bitmaps, padding index %ld\n",
                 nbitmaps,
                 PCF_GLYPH_PAD_INDEX( format ) ));
-    FT_TRACE4(( "bitmap size = %d\n", sizebitmaps ));
+    FT_TRACE4(( "  bitmap size = %d\n", sizebitmaps ));
 
     FT_UNUSED( sizebitmaps );       /* only used for debugging */
 
@@ -640,8 +658,8 @@
   pcf_get_encodings( FT_Stream  stream,
                      PCF_Face   face )
   {
-    FT_Error      error   = PCF_Err_Ok;
-    FT_Memory     memory  = FT_FACE(face)->memory;
+    FT_Error      error  = PCF_Err_Ok;
+    FT_Memory     memory = FT_FACE(face)->memory;
     FT_ULong      format, size;
     int           firstCol, lastCol;
     int           firstRow, lastRow;
@@ -687,7 +705,9 @@
     if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
       return PCF_Err_Invalid_File_Format;
 
-    FT_TRACE4(( "enc: firstCol %d, lastCol %d, firstRow %d, lastRow %d\n",
+    FT_TRACE4(( "pdf_get_encodings:\n" ));
+
+    FT_TRACE4(( "  firstCol %d, lastCol %d, firstRow %d, lastRow %d\n",
                 firstCol, lastCol, firstRow, lastRow ));
 
     nencoding = ( lastCol - firstCol + 1 ) * ( lastRow - firstRow + 1 );
@@ -714,11 +734,13 @@
                                  firstCol );
 
         tmpEncoding[j].glyph = (FT_Short)encodingOffset;
+
+        FT_TRACE4(( "  code %d (0x%04X): idx %d\n",
+                    tmpEncoding[j].enc, tmpEncoding[j].enc,
+                    tmpEncoding[j].glyph ));
+
         j++;
       }
-
-      FT_TRACE4(( "enc n. %d ; Uni %ld ; Glyph %d\n",
-                  i, tmpEncoding[j - 1].enc, encodingOffset ));
     }
     FT_Stream_ExitFrame( stream );