Add internal functions `FT_Trace_Disable' and `FT_Trace_Enable'. It sometimes makes sense to suppress tracing informations, for example, if it outputs identical messages again and again. * include/freetype/internal/ftdebug.h: Make `ft_trace_levels' a pointer. (FT_Trace_Disable, FT_Trace_Enable): New declarations. * src/base/ftdebug.c (ft_trace_levels): Rename to... (ft_trace_levels_enabled): ... this. (ft_trace_levels_disabled): New array. (ft_trace_levels): New pointer. (FT_Trace_Disable, FT_Trace_Enable): Implement. (ft_debug_init): Updated.
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 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
diff --git a/ChangeLog b/ChangeLog
index 91bb37a..73259c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2018-08-08 Werner Lemberg <wl@gnu.org>
+ Add internal functions `FT_Trace_Disable' and `FT_Trace_Enable'.
+
+ It sometimes makes sense to suppress tracing informations, for
+ example, if it outputs identical messages again and again.
+
+ * include/freetype/internal/ftdebug.h: Make `ft_trace_levels' a
+ pointer.
+ (FT_Trace_Disable, FT_Trace_Enable): New declarations.
+
+ * src/base/ftdebug.c (ft_trace_levels): Rename to...
+ (ft_trace_levels_enabled): ... this.
+ (ft_trace_levels_disabled): New array.
+ (ft_trace_levels): New pointer.
+ (FT_Trace_Disable, FT_Trace_Enable): Implement.
+ (ft_debug_init): Updated.
+
+2018-08-08 Werner Lemberg <wl@gnu.org>
+
Debugging improvements.
* src/base/ftobjs.c (pixel_modes): Move this array to top level
diff --git a/include/freetype/internal/ftdebug.h b/include/freetype/internal/ftdebug.h
index 1b4f699..d6e8a3a 100644
--- a/include/freetype/internal/ftdebug.h
+++ b/include/freetype/internal/ftdebug.h
@@ -62,8 +62,9 @@ FT_BEGIN_HEADER
} FT_Trace;
- /* defining the array of trace levels, provided by `src/base/ftdebug.c' */
- extern int ft_trace_levels[trace_count];
+ /* a pointer to the array of trace levels, */
+ /* provided by `src/base/ftdebug.c' */
+ extern int* ft_trace_levels;
#undef FT_TRACE_DEF
@@ -111,7 +112,7 @@ FT_BEGIN_HEADER
*
* @note:
* This function may be useful if you want to access elements of
- * the internal `ft_trace_levels' array by an index.
+ * the internal trace levels array by an index.
*/
FT_BASE( FT_Int )
FT_Trace_Get_Count( void );
@@ -130,15 +131,12 @@ FT_BEGIN_HEADER
*
* @return:
* The name of the trace component. This is a statically allocated
- * C string, so do not free it after use. NULL if FreeType 2 is not
- * built with FT_DEBUG_LEVEL_TRACE definition.
+ * C~string, so do not free it after use. NULL if FreeType is not built
+ * with FT_DEBUG_LEVEL_TRACE definition.
*
* @note:
* Use @FT_Trace_Get_Count to get the number of available trace
* components.
- *
- * This function may be useful if you want to control FreeType 2's
- * debug level in your application.
*/
FT_BASE( const char* )
FT_Trace_Get_Name( FT_Int idx );
@@ -146,6 +144,32 @@ FT_BEGIN_HEADER
/**************************************************************************
*
+ * @function:
+ * FT_Trace_Disable
+ *
+ * @description:
+ * Switch off tracing temporarily. It can be activated again with
+ * @FT_Trace_Enable.
+ */
+ FT_BASE( void )
+ FT_Trace_Disable( void );
+
+
+ /**************************************************************************
+ *
+ * @function:
+ * FT_Trace_Enable
+ *
+ * @description:
+ * Activate tracing. Use it after tracing has been switched off with
+ * @FT_Trace_Disable.
+ */
+ FT_BASE( void )
+ FT_Trace_Enable( void );
+
+
+ /**************************************************************************
+ *
* You need two opening and closing parentheses!
*
* Example: FT_TRACE0(( "Value is %i", foo ))
diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c
index a5fae27..8c7e51c 100644
--- a/src/base/ftdebug.c
+++ b/src/base/ftdebug.c
@@ -100,9 +100,16 @@
#ifdef FT_DEBUG_LEVEL_TRACE
- /* array of trace levels, initialized to 0 */
- int ft_trace_levels[trace_count];
+ /* array of trace levels, initialized to 0; */
+ /* this gets adjusted at run-time */
+ int ft_trace_levels_enabled[trace_count];
+ /* array of trace levels, always initialized to 0 */
+ int ft_trace_levels_disabled[trace_count];
+
+ /* a pointer to either `ft_trace_levels_enabled' */
+ /* or `ft_trace_levels_disabled' */
+ int* ft_trace_levels;
/* define array of trace toggle names */
#define FT_TRACE_DEF( x ) #x ,
@@ -140,6 +147,24 @@
}
+ /* documentation is in ftdebug.h */
+
+ FT_BASE_DEF( void )
+ FT_Trace_Disable( void )
+ {
+ ft_trace_levels = ft_trace_levels_disabled;
+ }
+
+
+ /* documentation is in ftdebug.h */
+
+ FT_BASE_DEF( void )
+ FT_Trace_Enable( void )
+ {
+ ft_trace_levels = ft_trace_levels_enabled;
+ }
+
+
/**************************************************************************
*
* Initialize the tracing sub-system. This is done by retrieving the
@@ -223,14 +248,16 @@
{
/* special case for `any' */
for ( n = 0; n < trace_count; n++ )
- ft_trace_levels[n] = level;
+ ft_trace_levels_enabled[n] = level;
}
else
- ft_trace_levels[found] = level;
+ ft_trace_levels_enabled[found] = level;
}
}
}
}
+
+ ft_trace_levels = ft_trace_levels_enabled;
}
@@ -260,6 +287,22 @@
}
+ FT_BASE_DEF( void )
+ FT_Trace_Disable( void )
+ {
+ /* nothing */
+ }
+
+
+ /* documentation is in ftdebug.h */
+
+ FT_BASE_DEF( void )
+ FT_Trace_Enable( void )
+ {
+ /* nothing */
+ }
+
+
#endif /* !FT_DEBUG_LEVEL_TRACE */