[base] Improve tracing in FT_Render_Glyph. * src/base/ftobjs.c (FT_Render_Glyph_Internal): Add total coverage calculations and downgrade Netpbm dump to bitmap:7.
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
diff --git a/ChangeLog b/ChangeLog
index 160f445..63a33cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,11 @@
-2017-10-12 Ewald Hew <ewaldhew@gmail.com>
+2017-10-18 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [base] Improve tracing in FT_Render_Glyph.
+
+ * src/base/ftobjs.c (FT_Render_Glyph_Internal): Add total coverage
+ calculations and downgrade Netpbm dump to bitmap:7.
+
+2017-10-15 Ewald Hew <ewaldhew@gmail.com>
[cff] Fix segfault on missing `psaux' (#52218)
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index eb14c6d..8f7466e 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -4548,54 +4548,63 @@
*/
/* we use FT_TRACE3 in this block */
- if ( ft_trace_levels[trace_bitmap] >= 3 )
+ if ( !error &&
+ ft_trace_levels[trace_bitmap] >= 3 &&
+ slot->bitmap.buffer )
{
+ FT_Bitmap bitmap;
+ FT_Error err;
+
+
+ FT_Bitmap_Init( &bitmap );
+
/* we convert to a single bitmap format for computing the checksum */
- if ( !error && slot->bitmap.buffer )
+ /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */
+ err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 );
+ if ( !err )
{
- FT_Bitmap bitmap;
- FT_Error err;
+ MD5_CTX ctx;
+ unsigned char md5[16];
+ unsigned long coverage = 0;
+ int i, j;
+ int rows = (int)bitmap.rows;
+ int pitch = bitmap.pitch;
- FT_Bitmap_Init( &bitmap );
+ FT_TRACE3(( "FT_Render_Glyph: bitmap %dx%d, mode %d\n",
+ rows, pitch, slot->bitmap.pixel_mode ));
- /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */
- err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 );
- if ( !err )
- {
- MD5_CTX ctx;
- unsigned char md5[16];
- int i;
- unsigned int rows = bitmap.rows;
- unsigned int pitch = (unsigned int)bitmap.pitch;
-
-
- MD5_Init( &ctx );
- if ( bitmap.buffer )
- MD5_Update( &ctx, bitmap.buffer, rows * pitch );
- MD5_Final( md5, &ctx );
-
- FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n"
- " ",
- rows, pitch ));
- for ( i = 0; i < 16; i++ )
- FT_TRACE3(( "%02X", md5[i] ));
- FT_TRACE3(( "\n" ));
- }
+ for ( i = 0; i < rows; i++ )
+ for ( j = 0; j < pitch; j++ )
+ coverage += bitmap.buffer[i * pitch + j];
+
+ FT_TRACE3(( " Total coverage: %lu\n", coverage ));
- FT_Bitmap_Done( library, &bitmap );
+ MD5_Init( &ctx );
+ if ( bitmap.buffer )
+ MD5_Update( &ctx, bitmap.buffer,
+ (unsigned long)rows * (unsigned long)pitch );
+ MD5_Final( md5, &ctx );
+
+ FT_TRACE3(( " MD5 checksum: " ));
+ for ( i = 0; i < 16; i++ )
+ FT_TRACE3(( "%02X", md5[i] ));
+ FT_TRACE3(( "\n" ));
}
+
+ FT_Bitmap_Done( library, &bitmap );
}
/*
* Dump bitmap in Netpbm format (PBM or PGM).
*/
- /* we use FT_TRACE2 in this block */
- if ( ft_trace_levels[trace_bitmap] >= 2 &&
- !error &&
+ /* we use FT_TRACE7 in this block */
+ if ( !error &&
+ ft_trace_levels[trace_bitmap] >= 7 &&
slot->bitmap.rows < 128U &&
- slot->bitmap.width < 128U )
+ slot->bitmap.width < 128U &&
+ slot->bitmap.buffer )
{
int rows = (int)slot->bitmap.rows;
int width = (int)slot->bitmap.width;
@@ -4606,30 +4615,30 @@
if ( pitch < 0 )
topleft -= pitch * ( rows - 1 );
- FT_TRACE2(( "Netpbm image: start\n" ));
+ FT_TRACE7(( "Netpbm image: start\n" ));
switch ( slot->bitmap.pixel_mode )
{
case FT_PIXEL_MODE_MONO:
- FT_TRACE2(( "P1 %d %d\n", width, rows ));
+ FT_TRACE7(( "P1 %d %d\n", width, rows ));
for ( i = 0; i < rows; i++ )
{
for ( j = 0; j < width; )
for ( m = 128; m > 0 && j < width; m >>= 1, j++ )
- FT_TRACE2(( " %d", ( topleft[i * pitch + j / 8] & m ) != 0 ));
- FT_TRACE2(( "\n" ));
+ FT_TRACE7(( " %d", ( topleft[i * pitch + j / 8] & m ) != 0 ));
+ FT_TRACE7(( "\n" ));
}
break;
default:
- FT_TRACE2(( "P2 %d %d 255\n", width, rows ));
+ FT_TRACE7(( "P2 %d %d 255\n", width, rows ));
for ( i = 0; i < rows; i++ )
{
for ( j = 0; j < width; j += 1 )
- FT_TRACE2(( " %3u", topleft[i * pitch + j] ));
- FT_TRACE2(( "\n" ));
+ FT_TRACE7(( " %3u", topleft[i * pitch + j] ));
+ FT_TRACE7(( "\n" ));
}
}
- FT_TRACE2(( "Netpbm image: end\n" ));
+ FT_TRACE7(( "Netpbm image: end\n" ));
}
#undef FT_COMPONENT