diff --git a/[priyesh]ChangeLog b/[priyesh]ChangeLog index 7c91f11d8..b1778df9d 100644 --- a/[priyesh]ChangeLog +++ b/[priyesh]ChangeLog @@ -1,3 +1,19 @@ +2020-06-30 Priyesh Kumar + + * include/freetype/internal/ftdebug.h: Added a FreeType specific dlg + output handler to print trace logs to file ~ + `ft_freetype_output_handler()` + + * src/base/ftdebug.c: + 1. If FT_LOGGING is enabled `ft_debug_init()` will be called from + `ft_logging_init()` + 2. Added function definition of `ft_freetype_output_handler)()` + + * src/base/ftobjs.c: If FT_LOGGING macro is disabled, only then FreeType + will call `ft_debug_init()` else it is controlled by logging APIs. + + * Fixed Scaling + 2020-06-29 Priyesh Kumar * Added submodule - dlg library (https://github.com/nyorain/dlg) @@ -13,8 +29,9 @@ * include/freetype/internal/ftdebug.h: Created an environment for dlg support in FreeType. - * include/freetype/internal/ftdebug.h: Added functions `ft_logging_init()` and `ft_logging_deinit()` for - initializing and un-initalizing FILE*. + * include/freetype/internal/ftdebug.h: Added functions + `ft_logging_init()` and `ft_logging_deinit()` for initializing and + un-initalizing FILE*. * src/base/ftdebug.c: 1. Added a FILE* to write logs to file @@ -22,5 +39,7 @@ `ft_logging_init()` and `ft_logging_deinit()`. * src/base/ftinit.c: - 1. Added a function call to `ft_logging_init()` in `FT_Init_FreeType()` if FT_LOGGING macro is enabled. - 2. Added a function call to `ft_logging_deinit()` in `FT_Done_FreeType()` if FT_LOGGING macro is enabled. \ No newline at end of file + 1. Added a function call to `ft_logging_init()` in `FT_Init_FreeType()` + if FT_LOGGING macro is enabled. + 2. Added function call to `ft_logging_deinit()` in `FT_Done_FreeType()` + if FT_LOGGING macro is enabled. \ No newline at end of file diff --git a/include/freetype/internal/ftdebug.h b/include/freetype/internal/ftdebug.h index 4bc810486..00afb358a 100644 --- a/include/freetype/internal/ftdebug.h +++ b/include/freetype/internal/ftdebug.h @@ -29,9 +29,9 @@ #include FT_CONFIG_CONFIG_H #include - /* Additional include files for supporting logging in FreeType using */ - /* external logging library ~ src/dlg */ - /* */ + /* Additional include files for supporting logging in FreeType using */ + /* external logging library ~ src/dlg */ + /* */ #include <../src/dlg/include/dlg/dlg.h> #include <../src/dlg/include/dlg/output.h> @@ -95,8 +95,8 @@ FT_BEGIN_HEADER * Each component must define the macro FT_COMPONENT to a valid FT_Trace * value before using any TRACE macro. * - * If FT_LOGGING is enabled, trace messages will be sent to - * dlg's APIs and is FT_LOGGING is disabled trace messages will be sent to + * If FT_LOGGING is enabled, trace messages will be sent to dlg's API and + * if is FT_LOGGING is disabled trace messages will be sent to * FT_Message(defined in ftdebug.c) * Therefore the following macros: * @@ -107,6 +107,19 @@ FT_BEGIN_HEADER #undef FT_Log #define FT_Log dlg_trace +/**************************************************************************** + * + * dlg uses output handlers to control how and where the log messages are + * printed. + * Therefore we need to define an output handler specific to FreeType, it + * will act as a default output handler of Freetype. + * + */ + + FT_BASE( void ) + ft_freetype_output_handler( const struct dlg_origin* origin, + const char* string, void* data ); + #else #undef FT_Log @@ -309,7 +322,7 @@ FT_BEGIN_HEADER #ifdef FT_LOGGING - /************************************************************************ + /************************************************************************** * * If FT_LOGGING macro is enabled, Freetype needs to initialize and * un-initialize FILE* using following functions diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c index b5e4a4a7c..7b2550e66 100644 --- a/src/base/ftdebug.c +++ b/src/base/ftdebug.c @@ -317,7 +317,7 @@ #ifdef FT_LOGGING - /****************************************************************** + /************************************************************************** * If FT_LOGGING is enabled FreeType needs a FILE* to write logs * to file. */ @@ -325,7 +325,7 @@ - /******************************************************************* + /************************************************************************** * * If FT_LOGGING is enabled, FreeType needs a FILE* to write logs * therefore it uses `ft_logging_init()` function to initialize a @@ -336,7 +336,11 @@ FT_BASE_DEF( void ) ft_logging_init( void ) { - fileptr = fopen( "freetype2.logs", "w" ); + fileptr = fopen( "freetype2.log", "w" ); + ft_debug_init(); + + /* We need to set the default FreeType specific dlg's output handler */ + dlg_set_handler( &ft_freetype_output_handler, NULL ); } FT_BASE_DEF( void ) @@ -345,6 +349,22 @@ fclose( fileptr ); } + FT_BASE_DEF( void ) + + /************************************************************************* + * + * TODO: + * 1. Add support for priniting FT_COMPONENT + * + */ + ft_freetype_output_handler( const struct dlg_origin* origin, + const char* string, void* data ) + { + unsigned int features = dlg_output_threadsafe /*| dlg_output_tags*/ ; + dlg_generic_output_stream( fileptr, features, origin, string, + dlg_default_output_styles ); + } + #endif /* FT_LOGGING */ /* END */ diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 78164c8cb..0217c5172 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -5273,10 +5273,12 @@ if ( !memory || !alibrary ) return FT_THROW( Invalid_Argument ); +#ifndef FT_LOGGING #ifdef FT_DEBUG_LEVEL_ERROR /* init debugging support */ ft_debug_init(); -#endif +#endif /* FT_DEBUG_LEVEL_ERROR */ +#endif /* FT_LOGGING */ /* first of all, allocate the library object */ if ( FT_NEW( library ) )