From 01ce8ff34087f33591cf6eafafe55673a793bf32 Mon Sep 17 00:00:00 2001 From: Priyeshkkumar Date: Mon, 29 Jun 2020 17:49:57 +0530 Subject: [PATCH] Implemented a basic integration of dlg with FreeType --- .gitmodules | 3 +++ [priyesh]ChangeLog | 15 ++++++++++++ builds/unix/unix-cc.in | 2 +- include/freetype/config/ftoption.h | 14 +++++++++++ include/freetype/internal/ftdebug.h | 38 ++++++++++++++++++++++++++--- src/dlg | 1 + 6 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 .gitmodules create mode 100644 [priyesh]ChangeLog create mode 160000 src/dlg diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..967015f20 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/dlg"] + path = src/dlg + url = https://github.com/nyorain/dlg.git diff --git a/[priyesh]ChangeLog b/[priyesh]ChangeLog new file mode 100644 index 000000000..0f84213b6 --- /dev/null +++ b/[priyesh]ChangeLog @@ -0,0 +1,15 @@ +2020-06-29 Priyesh Kumar + + * Added submodule - dlg library (https://github.com/nyorain/dlg) + in src/dlg. + This library is used as a logger for FreeType. + + * include/freetype/config/ftoption.h: Added macro `FT_LOGGING` + to enable/disable logging in FreeType using dlg. + + * [builds] unix-cc-in: Added -std=c99, since dlg does not support + C standards below c99. + + * include/freetype/internal/ftdebug.h: Created an environment for dlg + support in FreeType. + \ No newline at end of file diff --git a/builds/unix/unix-cc.in b/builds/unix/unix-cc.in index 30d097b23..6dbf399b6 100644 --- a/builds/unix/unix-cc.in +++ b/builds/unix/unix-cc.in @@ -79,7 +79,7 @@ T := -o$(space) # We use our own FreeType configuration files overriding defaults. # CPPFLAGS := @CPPFLAGS@ -CFLAGS := -c @XX_CFLAGS@ @CFLAGS@ \ +CFLAGS := -c -std=c99 @XX_CFLAGS@ @CFLAGS@ \ $DFT_CONFIG_CONFIG_H="" \ $DFT_CONFIG_MODULES_H="" \ $DFT_CONFIG_OPTIONS_H="" diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h index fd686d954..92aa89bab 100644 --- a/include/freetype/config/ftoption.h +++ b/include/freetype/config/ftoption.h @@ -431,6 +431,20 @@ FT_BEGIN_HEADER /* #define FT_DEBUG_LEVEL_TRACE */ + /************************************************************************* + * + * Logging + * + * Compiling FreeType in debug or trace mode will make FreeType to write + * error and trace log messages to `stderr`. + * Enabling this macro will automatically force the `FT_DEBUG_LEVEL_ERROR` + * and `FT_DEBUG_LEVEL_TRACE` macros and will allow FreeType to write + * error and trace log messages to a file instead of `stderr` + * + */ +/* #define FT_LOGGING */ + + /************************************************************************** * * Autofitter debugging diff --git a/include/freetype/internal/ftdebug.h b/include/freetype/internal/ftdebug.h index e7eb29a1a..469220c9c 100644 --- a/include/freetype/internal/ftdebug.h +++ b/include/freetype/internal/ftdebug.h @@ -29,10 +29,25 @@ #include FT_CONFIG_CONFIG_H #include + /* 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> + FT_BEGIN_HEADER + /* force the definition of FT_DEBUG_LEVEL_TRACE if FT_LOGGING is already*/ + /* defined; therefore the following macros */ + /* */ +#ifdef FT_LOGGING +#undef FT_DEBUG_LEVEL_TRACE +#define FT_DEBUG_LEVEL_TRACE +#endif /* FT_LOGGING */ + + /* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */ /* is already defined; this simplifies the following #ifdefs */ /* */ @@ -74,14 +89,31 @@ FT_BEGIN_HEADER /************************************************************************** * * Define the FT_TRACE macro - * + * * IMPORTANT! * * 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 + * FT_Message(defined in ftdebug.c) + * Therefore the following macros: + * */ +#ifdef FT_LOGGING + +#undef FT_Log +#define FT_Log dlg_trace + +#else + +#undef FT_Log +#define FT_Log FT_Message + +#endif /* FT_LOGGING */ + #ifdef FT_DEBUG_LEVEL_TRACE /* we need two macros here to make cpp expand `FT_COMPONENT' */ @@ -92,7 +124,7 @@ FT_BEGIN_HEADER do \ { \ if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \ - FT_Message varformat; \ + FT_Log varformat; \ } while ( 0 ) #else /* !FT_DEBUG_LEVEL_TRACE */ diff --git a/src/dlg b/src/dlg new file mode 160000 index 000000000..407e385d2 --- /dev/null +++ b/src/dlg @@ -0,0 +1 @@ +Subproject commit 407e385d2e40e11a1f1643cdf698fd09d62561ca