Compare commits
11 Commits
master
...
GSoC-2020-
Author | SHA1 | Date | |
---|---|---|---|
|
2579d0acea | ||
|
7e6b43edf3 | ||
|
526d973e31 | ||
|
968d484cc0 | ||
|
c5dba671aa | ||
|
802176853b | ||
|
1c095f8174 | ||
|
806adbe829 | ||
|
85060d51a1 | ||
|
c2da552c7f | ||
|
62e5220edb |
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "submodules/dlg"]
|
||||
path = submodules/dlg
|
||||
url = https://github.com/nyorain/dlg.git
|
@ -35,6 +35,14 @@ Similarly, a build with `cmake' can be done directly from the git
|
||||
repository.
|
||||
|
||||
|
||||
For using the `FT_LOGGING' macro while debugging(see docs/DEBUG for
|
||||
more information) use the following git commands to checkout `dlg'
|
||||
library as a git submodule.
|
||||
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (C) 2005-2020 by
|
||||
|
25
autogen.sh
25
autogen.sh
@ -162,4 +162,29 @@ cd ../..
|
||||
|
||||
chmod +x ./configure
|
||||
|
||||
|
||||
# Copy all necessary dlg files.
|
||||
copy_submodule_files()
|
||||
{
|
||||
echo "Copying files from \`submodules/dlg' to \`src/dlg'"
|
||||
mkdir src/dlg/dlg
|
||||
cp $DLG_INC_DIR/dlg.h src/dlg/dlg
|
||||
cp $DLG_INC_DIR/output.h src/dlg/dlg
|
||||
cp $DLG_SRC_DIR/* src/dlg
|
||||
}
|
||||
|
||||
|
||||
DLG_INC_DIR=submodules/dlg/include/dlg
|
||||
DLG_SRC_DIR=submodules/dlg/src/dlg
|
||||
|
||||
if ! test -d "$DLG_INC_DIR"; then
|
||||
echo "Submodule check out in \`submodules/dlg':"
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
||||
copy_submodule_files
|
||||
else
|
||||
copy_submodule_files
|
||||
fi
|
||||
|
||||
# EOF
|
||||
|
@ -101,6 +101,7 @@ PUBLIC_DIR := $(TOP_DIR)/include/freetype
|
||||
INTERNAL_DIR := $(PUBLIC_DIR)/internal
|
||||
SERVICES_DIR := $(INTERNAL_DIR)/services
|
||||
CONFIG_DIR := $(PUBLIC_DIR)/config
|
||||
DLG_DIR := $(TOP_DIR)/src/dlg
|
||||
|
||||
# The documentation directory.
|
||||
#
|
||||
@ -122,6 +123,7 @@ PROJECT_LIBRARY := $(LIB_DIR)/$(LIBRARY).$A
|
||||
INCLUDES := $(subst /,$(COMPILER_SEP),$(OBJ_DIR) \
|
||||
$(DEVEL_DIR) \
|
||||
$(BUILD_DIR) \
|
||||
$(DLG_DIR) \
|
||||
$(TOP_DIR)/include)
|
||||
|
||||
INCLUDE_FLAGS := $(INCLUDES:%=$I%)
|
||||
@ -152,7 +154,7 @@ endif
|
||||
#
|
||||
FT_CFLAGS = $(CPPFLAGS) \
|
||||
$(CFLAGS) \
|
||||
$DFT2_BUILD_LIBRARY
|
||||
$DFT2_BUILD_LIBRARY -std=c99
|
||||
|
||||
FT_COMPILE := $(CC) $(ANSIFLAGS) $(INCLUDE_FLAGS) $(FT_CFLAGS)
|
||||
|
||||
@ -220,6 +222,7 @@ $(FTDEBUG_OBJ): $(FTDEBUG_SRC) $(FREETYPE_H)
|
||||
#
|
||||
include $(SRC_DIR)/base/rules.mk
|
||||
include $(patsubst %,$(SRC_DIR)/%/rules.mk,$(MODULES))
|
||||
include $(SRC_DIR)/dlg/rules.mk
|
||||
|
||||
|
||||
# ftinit component
|
||||
@ -260,8 +263,8 @@ endif
|
||||
|
||||
# All FreeType library objects.
|
||||
#
|
||||
OBJ_M := $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M)
|
||||
OBJ_S := $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S)
|
||||
OBJ_M := $(BASE_OBJ_M) $(BASE_EXT_OBJ) $(DRV_OBJS_M) $(DLG_OBJS_M)
|
||||
OBJ_S := $(BASE_OBJ_S) $(BASE_EXT_OBJ) $(DRV_OBJS_S) $(DLG_OBJS_S)
|
||||
|
||||
|
||||
# The target `multi' on the Make command line indicates that we want to
|
||||
|
@ -103,6 +103,23 @@ ifneq ($(findstring setup,$(MAKECMDGOALS)),)
|
||||
check_platform := 1
|
||||
endif
|
||||
|
||||
# For builds directly from the git repository we need to copy files
|
||||
# from `submodule/dlg' to `src/dlg'
|
||||
#
|
||||
ifeq ($(wildcard src/dlg/dlg.*),)
|
||||
ifeq ($(wildcard submodules/dlg/dlg.*),)
|
||||
$(info Submodule check out in `submodules/dlg' )
|
||||
$(shell git submodule init)
|
||||
$(shell git submodule update)
|
||||
endif
|
||||
|
||||
$(info Copying files from `submodules/dlg' to `src/dlg')
|
||||
$(shell mkdir src/dlg/dlg)
|
||||
$(shell cp submodules/dlg/include/dlg/dlg.h src/dlg/dlg)
|
||||
$(shell cp submodules/dlg/include/dlg/output.h src/dlg/dlg)
|
||||
$(shell cp submodules/dlg/src/dlg/dlg.c src/dlg/)
|
||||
endif
|
||||
|
||||
# Include the automatic host platform detection rules when we need to
|
||||
# check the platform.
|
||||
#
|
||||
|
507
builds/unix/ax_pthread.m4
Normal file
507
builds/unix/ax_pthread.m4
Normal file
@ -0,0 +1,507 @@
|
||||
# ===========================================================================
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_pthread.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro figures out how to build C programs using POSIX threads. It
|
||||
# sets the PTHREAD_LIBS output variable to the threads library and linker
|
||||
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
|
||||
# flags that are needed. (The user can also force certain compiler
|
||||
# flags/libs to be tested by setting these environment variables.)
|
||||
#
|
||||
# Also sets PTHREAD_CC to any special C compiler that is needed for
|
||||
# multi-threaded programs (defaults to the value of CC otherwise). (This
|
||||
# is necessary on AIX to use the special cc_r compiler alias.)
|
||||
#
|
||||
# NOTE: You are assumed to not only compile your program with these flags,
|
||||
# but also to link with them as well. For example, you might link with
|
||||
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
|
||||
#
|
||||
# If you are only building threaded programs, you may wish to use these
|
||||
# variables in your default LIBS, CFLAGS, and CC:
|
||||
#
|
||||
# LIBS="$PTHREAD_LIBS $LIBS"
|
||||
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
# CC="$PTHREAD_CC"
|
||||
#
|
||||
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
|
||||
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
|
||||
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||
#
|
||||
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
|
||||
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
|
||||
# PTHREAD_CFLAGS.
|
||||
#
|
||||
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
|
||||
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
|
||||
# is not found. If ACTION-IF-FOUND is not specified, the default action
|
||||
# will define HAVE_PTHREAD.
|
||||
#
|
||||
# Please let the authors know if this macro fails on any platform, or if
|
||||
# you have any other suggestions or comments. This macro was based on work
|
||||
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
|
||||
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
|
||||
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
|
||||
# grateful for the helpful feedback of numerous users.
|
||||
#
|
||||
# Updated for Autoconf 2.68 by Daniel Richard G.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
|
||||
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
|
||||
# Copyright (c) 2019 Marc Stevens <marc.stevens@cwi.nl>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation, either version 3 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||
# gives unlimited permission to copy, distribute and modify the configure
|
||||
# scripts that are the output of Autoconf when processing the Macro. You
|
||||
# need not follow the terms of the GNU General Public License when using
|
||||
# or distributing such scripts, even though portions of the text of the
|
||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
# all other use of the material that constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the Autoconf
|
||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 27
|
||||
|
||||
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
|
||||
AC_DEFUN([AX_PTHREAD], [
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([AC_PROG_SED])
|
||||
AC_LANG_PUSH([C])
|
||||
ax_pthread_ok=no
|
||||
|
||||
# We used to check for pthread.h first, but this fails if pthread.h
|
||||
# requires special compiler flags (e.g. on Tru64 or Sequent).
|
||||
# It gets checked for in the link test anyway.
|
||||
|
||||
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
||||
# etcetera environment variables, and if threads linking works using
|
||||
# them:
|
||||
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
|
||||
ax_pthread_save_CC="$CC"
|
||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
||||
ax_pthread_save_LIBS="$LIBS"
|
||||
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
|
||||
AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
|
||||
AC_MSG_RESULT([$ax_pthread_ok])
|
||||
if test "x$ax_pthread_ok" = "xno"; then
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
fi
|
||||
CC="$ax_pthread_save_CC"
|
||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
||||
LIBS="$ax_pthread_save_LIBS"
|
||||
fi
|
||||
|
||||
# We must check for the threads library under a number of different
|
||||
# names; the ordering is very important because some systems
|
||||
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
||||
# libraries is broken (non-POSIX).
|
||||
|
||||
# Create a list of thread flags to try. Items with a "," contain both
|
||||
# C compiler flags (before ",") and linker flags (after ","). Other items
|
||||
# starting with a "-" are C compiler flags, and remaining items are
|
||||
# library names, except for "none" which indicates that we try without
|
||||
# any flags at all, and "pthread-config" which is a program returning
|
||||
# the flags for the Pth emulation library.
|
||||
|
||||
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
||||
|
||||
# The ordering *is* (sometimes) important. Some notes on the
|
||||
# individual items follow:
|
||||
|
||||
# pthreads: AIX (must check this before -lpthread)
|
||||
# none: in case threads are in libc; should be tried before -Kthread and
|
||||
# other compiler flags to prevent continual compiler warnings
|
||||
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
|
||||
# (Note: HP C rejects this with "bad form for `-t' option")
|
||||
# -pthreads: Solaris/gcc (Note: HP C also rejects)
|
||||
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
||||
# doesn't hurt to check since this sometimes defines pthreads and
|
||||
# -D_REENTRANT too), HP C (must be checked before -lpthread, which
|
||||
# is present but should not be used directly; and before -mthreads,
|
||||
# because the compiler interprets this as "-mt" + "-hreads")
|
||||
# -mthreads: Mingw32/gcc, Lynx/gcc
|
||||
# pthread: Linux, etcetera
|
||||
# --thread-safe: KAI C++
|
||||
# pthread-config: use pthread-config program (for GNU Pth library)
|
||||
|
||||
case $host_os in
|
||||
|
||||
freebsd*)
|
||||
|
||||
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
||||
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
||||
|
||||
ax_pthread_flags="-kthread lthread $ax_pthread_flags"
|
||||
;;
|
||||
|
||||
hpux*)
|
||||
|
||||
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
|
||||
# multi-threading and also sets -lpthread."
|
||||
|
||||
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
|
||||
;;
|
||||
|
||||
openedition*)
|
||||
|
||||
# IBM z/OS requires a feature-test macro to be defined in order to
|
||||
# enable POSIX threads at all, so give the user a hint if this is
|
||||
# not set. (We don't define these ourselves, as they can affect
|
||||
# other portions of the system API in unpredictable ways.)
|
||||
|
||||
AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
|
||||
[
|
||||
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
|
||||
AX_PTHREAD_ZOS_MISSING
|
||||
# endif
|
||||
],
|
||||
[AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
|
||||
;;
|
||||
|
||||
solaris*)
|
||||
|
||||
# On Solaris (at least, for some versions), libc contains stubbed
|
||||
# (non-functional) versions of the pthreads routines, so link-based
|
||||
# tests will erroneously succeed. (N.B.: The stubs are missing
|
||||
# pthread_cleanup_push, or rather a function called by this macro,
|
||||
# so we could check for that, but who knows whether they'll stub
|
||||
# that too in a future libc.) So we'll check first for the
|
||||
# standard Solaris way of linking pthreads (-mt -lpthread).
|
||||
|
||||
ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Are we compiling with Clang?
|
||||
|
||||
AC_CACHE_CHECK([whether $CC is Clang],
|
||||
[ax_cv_PTHREAD_CLANG],
|
||||
[ax_cv_PTHREAD_CLANG=no
|
||||
# Note that Autoconf sets GCC=yes for Clang as well as GCC
|
||||
if test "x$GCC" = "xyes"; then
|
||||
AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
|
||||
[/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
|
||||
# if defined(__clang__) && defined(__llvm__)
|
||||
AX_PTHREAD_CC_IS_CLANG
|
||||
# endif
|
||||
],
|
||||
[ax_cv_PTHREAD_CLANG=yes])
|
||||
fi
|
||||
])
|
||||
ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
|
||||
|
||||
|
||||
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
|
||||
|
||||
# Note that for GCC and Clang -pthread generally implies -lpthread,
|
||||
# except when -nostdlib is passed.
|
||||
# This is problematic using libtool to build C++ shared libraries with pthread:
|
||||
# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460
|
||||
# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333
|
||||
# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555
|
||||
# To solve this, first try -pthread together with -lpthread for GCC
|
||||
|
||||
AS_IF([test "x$GCC" = "xyes"],
|
||||
[ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"])
|
||||
|
||||
# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first
|
||||
|
||||
AS_IF([test "x$ax_pthread_clang" = "xyes"],
|
||||
[ax_pthread_flags="-pthread,-lpthread -pthread"])
|
||||
|
||||
|
||||
# The presence of a feature test macro requesting re-entrant function
|
||||
# definitions is, on some systems, a strong hint that pthreads support is
|
||||
# correctly enabled
|
||||
|
||||
case $host_os in
|
||||
darwin* | hpux* | linux* | osf* | solaris*)
|
||||
ax_pthread_check_macro="_REENTRANT"
|
||||
;;
|
||||
|
||||
aix*)
|
||||
ax_pthread_check_macro="_THREAD_SAFE"
|
||||
;;
|
||||
|
||||
*)
|
||||
ax_pthread_check_macro="--"
|
||||
;;
|
||||
esac
|
||||
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
|
||||
[ax_pthread_check_cond=0],
|
||||
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
|
||||
|
||||
|
||||
if test "x$ax_pthread_ok" = "xno"; then
|
||||
for ax_pthread_try_flag in $ax_pthread_flags; do
|
||||
|
||||
case $ax_pthread_try_flag in
|
||||
none)
|
||||
AC_MSG_CHECKING([whether pthreads work without any flags])
|
||||
;;
|
||||
|
||||
*,*)
|
||||
PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"`
|
||||
PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"`
|
||||
AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"])
|
||||
;;
|
||||
|
||||
-*)
|
||||
AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
|
||||
PTHREAD_CFLAGS="$ax_pthread_try_flag"
|
||||
;;
|
||||
|
||||
pthread-config)
|
||||
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
|
||||
AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
|
||||
PTHREAD_CFLAGS="`pthread-config --cflags`"
|
||||
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
|
||||
PTHREAD_LIBS="-l$ax_pthread_try_flag"
|
||||
;;
|
||||
esac
|
||||
|
||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
||||
ax_pthread_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
|
||||
# Check for various functions. We must include pthread.h,
|
||||
# since some functions may be macros. (On the Sequent, we
|
||||
# need a special flag -Kthread to make this header compile.)
|
||||
# We check for pthread_join because it is in -lpthread on IRIX
|
||||
# while pthread_create is in libc. We check for pthread_attr_init
|
||||
# due to DEC craziness with -lpthreads. We check for
|
||||
# pthread_cleanup_push because it is one of the few pthread
|
||||
# functions on Solaris that doesn't have a non-functional libc stub.
|
||||
# We try pthread_create on general principles.
|
||||
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
|
||||
# if $ax_pthread_check_cond
|
||||
# error "$ax_pthread_check_macro must be defined"
|
||||
# endif
|
||||
static void *some_global = NULL;
|
||||
static void routine(void *a)
|
||||
{
|
||||
/* To avoid any unused-parameter or
|
||||
unused-but-set-parameter warning. */
|
||||
some_global = a;
|
||||
}
|
||||
static void *start_routine(void *a) { return a; }],
|
||||
[pthread_t th; pthread_attr_t attr;
|
||||
pthread_create(&th, 0, start_routine, 0);
|
||||
pthread_join(th, 0);
|
||||
pthread_attr_init(&attr);
|
||||
pthread_cleanup_push(routine, 0);
|
||||
pthread_cleanup_pop(0) /* ; */])],
|
||||
[ax_pthread_ok=yes],
|
||||
[])
|
||||
|
||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
||||
LIBS="$ax_pthread_save_LIBS"
|
||||
|
||||
AC_MSG_RESULT([$ax_pthread_ok])
|
||||
AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
|
||||
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Clang needs special handling, because older versions handle the -pthread
|
||||
# option in a rather... idiosyncratic way
|
||||
|
||||
if test "x$ax_pthread_clang" = "xyes"; then
|
||||
|
||||
# Clang takes -pthread; it has never supported any other flag
|
||||
|
||||
# (Note 1: This will need to be revisited if a system that Clang
|
||||
# supports has POSIX threads in a separate library. This tends not
|
||||
# to be the way of modern systems, but it's conceivable.)
|
||||
|
||||
# (Note 2: On some systems, notably Darwin, -pthread is not needed
|
||||
# to get POSIX threads support; the API is always present and
|
||||
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
|
||||
# -pthread does define _REENTRANT, and while the Darwin headers
|
||||
# ignore this macro, third-party headers might not.)
|
||||
|
||||
# However, older versions of Clang make a point of warning the user
|
||||
# that, in an invocation where only linking and no compilation is
|
||||
# taking place, the -pthread option has no effect ("argument unused
|
||||
# during compilation"). They expect -pthread to be passed in only
|
||||
# when source code is being compiled.
|
||||
#
|
||||
# Problem is, this is at odds with the way Automake and most other
|
||||
# C build frameworks function, which is that the same flags used in
|
||||
# compilation (CFLAGS) are also used in linking. Many systems
|
||||
# supported by AX_PTHREAD require exactly this for POSIX threads
|
||||
# support, and in fact it is often not straightforward to specify a
|
||||
# flag that is used only in the compilation phase and not in
|
||||
# linking. Such a scenario is extremely rare in practice.
|
||||
#
|
||||
# Even though use of the -pthread flag in linking would only print
|
||||
# a warning, this can be a nuisance for well-run software projects
|
||||
# that build with -Werror. So if the active version of Clang has
|
||||
# this misfeature, we search for an option to squash it.
|
||||
|
||||
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
|
||||
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
|
||||
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
|
||||
# Create an alternate version of $ac_link that compiles and
|
||||
# links in two steps (.c -> .o, .o -> exe) instead of one
|
||||
# (.c -> exe), because the warning occurs only in the second
|
||||
# step
|
||||
ax_pthread_save_ac_link="$ac_link"
|
||||
ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
|
||||
ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
|
||||
ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
|
||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
||||
for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
|
||||
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
|
||||
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
|
||||
ac_link="$ax_pthread_save_ac_link"
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
|
||||
[ac_link="$ax_pthread_2step_ac_link"
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
|
||||
[break])
|
||||
])
|
||||
done
|
||||
ac_link="$ax_pthread_save_ac_link"
|
||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
||||
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
|
||||
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
|
||||
])
|
||||
|
||||
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
|
||||
no | unknown) ;;
|
||||
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
|
||||
esac
|
||||
|
||||
fi # $ax_pthread_clang = yes
|
||||
|
||||
|
||||
|
||||
# Various other checks:
|
||||
if test "x$ax_pthread_ok" = "xyes"; then
|
||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
||||
ax_pthread_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
|
||||
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
||||
AC_CACHE_CHECK([for joinable pthread attribute],
|
||||
[ax_cv_PTHREAD_JOINABLE_ATTR],
|
||||
[ax_cv_PTHREAD_JOINABLE_ATTR=unknown
|
||||
for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
|
||||
[int attr = $ax_pthread_attr; return attr /* ; */])],
|
||||
[ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
|
||||
[])
|
||||
done
|
||||
])
|
||||
AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
|
||||
test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
|
||||
test "x$ax_pthread_joinable_attr_defined" != "xyes"],
|
||||
[AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
|
||||
[$ax_cv_PTHREAD_JOINABLE_ATTR],
|
||||
[Define to necessary symbol if this constant
|
||||
uses a non-standard name on your system.])
|
||||
ax_pthread_joinable_attr_defined=yes
|
||||
])
|
||||
|
||||
AC_CACHE_CHECK([whether more special flags are required for pthreads],
|
||||
[ax_cv_PTHREAD_SPECIAL_FLAGS],
|
||||
[ax_cv_PTHREAD_SPECIAL_FLAGS=no
|
||||
case $host_os in
|
||||
solaris*)
|
||||
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
|
||||
;;
|
||||
esac
|
||||
])
|
||||
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
|
||||
test "x$ax_pthread_special_flags_added" != "xyes"],
|
||||
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
|
||||
ax_pthread_special_flags_added=yes])
|
||||
|
||||
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
|
||||
[[int i = PTHREAD_PRIO_INHERIT;
|
||||
return i;]])],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT=no])
|
||||
])
|
||||
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
|
||||
test "x$ax_pthread_prio_inherit_defined" != "xyes"],
|
||||
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
|
||||
ax_pthread_prio_inherit_defined=yes
|
||||
])
|
||||
|
||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
||||
LIBS="$ax_pthread_save_LIBS"
|
||||
|
||||
# More AIX lossage: compile with *_r variant
|
||||
if test "x$GCC" != "xyes"; then
|
||||
case $host_os in
|
||||
aix*)
|
||||
AS_CASE(["x/$CC"],
|
||||
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
|
||||
[#handle absolute path differently from PATH based program lookup
|
||||
AS_CASE(["x$CC"],
|
||||
[x/*],
|
||||
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
|
||||
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
|
||||
|
||||
AC_SUBST([PTHREAD_LIBS])
|
||||
AC_SUBST([PTHREAD_CFLAGS])
|
||||
AC_SUBST([PTHREAD_CC])
|
||||
|
||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
||||
if test "x$ax_pthread_ok" = "xyes"; then
|
||||
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
|
||||
:
|
||||
else
|
||||
ax_pthread_ok=no
|
||||
$2
|
||||
fi
|
||||
AC_LANG_POP
|
||||
])dnl AX_PTHREAD
|
@ -1012,6 +1012,10 @@ case "$CFLAGS" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check for pthreads
|
||||
|
||||
AX_PTHREAD([have_pthread=yes], [have_pthread=no])
|
||||
|
||||
# Check for Python and docwriter
|
||||
|
||||
have_py3=no
|
||||
@ -1141,6 +1145,13 @@ if test "$have_brotli" != no; then
|
||||
else
|
||||
ftoption_unset FT_CONFIG_OPTION_USE_BROTLI
|
||||
fi
|
||||
if test "$have_pthread" != no; then
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
LDFLAGS="$LDFLAGS $PTHREAD_CFLAGS $PTHREAD_LIBS"
|
||||
ftoption_set FT_LOGGING
|
||||
else
|
||||
ftoption_unset FT_LOGGING
|
||||
fi
|
||||
|
||||
AC_SUBST([CFLAGS])
|
||||
AC_SUBST([LDFLAGS])
|
||||
@ -1176,6 +1187,7 @@ Library configuration:
|
||||
libpng: $have_libpng
|
||||
harfbuzz: $have_harfbuzz
|
||||
brotli: $have_brotli
|
||||
pthread: $have_pthread
|
||||
])
|
||||
|
||||
# Warn if docwriter is not installed
|
||||
@ -1189,4 +1201,12 @@ if test $have_docwriter = no; then
|
||||
])
|
||||
fi
|
||||
|
||||
# Warn if pthread is not available
|
||||
|
||||
if test $have_pthread = no; then
|
||||
AC_MSG_WARN([
|
||||
`FT_LOGGING' will not work since pthread library is not available.
|
||||
])
|
||||
fi
|
||||
|
||||
# end of configure.raw
|
||||
|
@ -16,34 +16,77 @@
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* This component contains various macros and functions used to ease the
|
||||
* debugging of the FreeType engine. Its main purpose is in assertion
|
||||
* checking, tracing, and error detection.
|
||||
*
|
||||
* There are now three debugging modes:
|
||||
*
|
||||
* - trace mode
|
||||
*
|
||||
* Error and trace messages are sent to the log file (which can be the
|
||||
* standard error output).
|
||||
*
|
||||
* - error mode
|
||||
*
|
||||
* Only error messages are generated.
|
||||
*
|
||||
* - release mode:
|
||||
*
|
||||
* No error message is sent or generated. The code is free from any
|
||||
* debugging parts.
|
||||
*
|
||||
*/
|
||||
/**************************************************************************
|
||||
*
|
||||
* This component contains various macros and functions used to ease the
|
||||
* debugging of the FreeType engine. Its main purpose is in assertion
|
||||
* checking, tracing, and error detection.
|
||||
*
|
||||
* There are now three debugging modes:
|
||||
*
|
||||
* - trace mode
|
||||
*
|
||||
* Error and trace messages are sent to the log file (which can be the
|
||||
* standard error output).
|
||||
*
|
||||
* - error mode
|
||||
*
|
||||
* Only error messages are generated.
|
||||
*
|
||||
* - release mode:
|
||||
*
|
||||
* No error message is sent or generated. The code is free from any
|
||||
* debugging parts.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Variable used when FT_LOGGING is enabled to control logging:
|
||||
*
|
||||
* 1. ft_default_trace_level: stores the value of trace levels which are
|
||||
* provided to FreeType using FT2_DEBUG environment variable.
|
||||
*
|
||||
* 2. ft_fileptr: store the FILE*
|
||||
*
|
||||
* 3. ft_component: a string that holds the name of FT_COMPONENT
|
||||
*
|
||||
* 4. ft_component_flag: a flag when true, prints the name of
|
||||
* FT_COMPONENT along with actual log message.
|
||||
*
|
||||
* 5. ft_timestamp_flag: a flag when true, prints time along with log
|
||||
* actual log message.
|
||||
*
|
||||
* 6. ft_have_newline_char: It is used to differentiate between a log
|
||||
* message with '\n' char and log message without '\n' char
|
||||
*
|
||||
* 7. ft_custom_trace_level: stores the value of custom trace level which
|
||||
* is provided by user at run-time.
|
||||
*
|
||||
* Static Variables are defined here to remove [ -Wunused-variable ]
|
||||
* warning
|
||||
*
|
||||
*/
|
||||
static const char* ft_default_trace_level = NULL;
|
||||
static FILE* ft_fileptr = NULL;
|
||||
static const char* ft_component = NULL;
|
||||
static bool ft_component_flag = false;
|
||||
static bool ft_timestamp_flag = false;
|
||||
static bool ft_have_newline_char = true;
|
||||
static const char* ft_custom_trace_level = NULL;
|
||||
|
||||
/* declared in ftdebug.h */
|
||||
|
||||
dlg_handler ft_default_log_handler = NULL;
|
||||
FT_Custom_Log_Handler custom_output_handler = NULL;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef FT_DEBUG_LEVEL_ERROR
|
||||
|
||||
@ -54,51 +97,51 @@
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Message( const char* fmt,
|
||||
... )
|
||||
{
|
||||
static char buf[8192];
|
||||
va_list ap;
|
||||
|
||||
|
||||
va_start( ap, fmt );
|
||||
vfprintf( stderr, fmt, ap );
|
||||
/* send the string to the debugger as well */
|
||||
vsprintf( buf, fmt, ap );
|
||||
OutputDebugStringA( buf );
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Panic( const char* fmt,
|
||||
FT_BASE_DEF( void )
|
||||
FT_Message( const char* fmt,
|
||||
... )
|
||||
{
|
||||
static char buf[8192];
|
||||
va_list ap;
|
||||
{
|
||||
static char buf[8192];
|
||||
va_list ap;
|
||||
|
||||
|
||||
va_start( ap, fmt );
|
||||
vsprintf( buf, fmt, ap );
|
||||
OutputDebugStringA( buf );
|
||||
va_end( ap );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
va_start( ap, fmt );
|
||||
vfprintf( stderr, fmt, ap );
|
||||
/* send the string to the debugger as well */
|
||||
vsprintf( buf, fmt, ap );
|
||||
OutputDebugStringA( buf );
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( int )
|
||||
FT_Throw( FT_Error error,
|
||||
int line,
|
||||
const char* file )
|
||||
{
|
||||
FT_BASE_DEF( void )
|
||||
FT_Panic( const char* fmt,
|
||||
... )
|
||||
{
|
||||
static char buf[8192];
|
||||
va_list ap;
|
||||
|
||||
|
||||
va_start( ap, fmt );
|
||||
vsprintf( buf, fmt, ap );
|
||||
OutputDebugStringA( buf );
|
||||
va_end( ap );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( int )
|
||||
FT_Throw( FT_Error error,
|
||||
int line,
|
||||
const char* file )
|
||||
{
|
||||
#if 0
|
||||
/* activating the code in this block makes FreeType very chatty */
|
||||
fprintf( stderr,
|
||||
@ -108,223 +151,410 @@
|
||||
error,
|
||||
FT_Error_String( error ) );
|
||||
#else
|
||||
FT_UNUSED( error );
|
||||
FT_UNUSED( line );
|
||||
FT_UNUSED( file );
|
||||
FT_UNUSED( error );
|
||||
FT_UNUSED( line );
|
||||
FT_UNUSED( file );
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* FT_DEBUG_LEVEL_ERROR */
|
||||
|
||||
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
|
||||
/* array of trace levels, initialized to 0; */
|
||||
/* this gets adjusted at run-time */
|
||||
static int ft_trace_levels_enabled[trace_count];
|
||||
/* array of trace levels, initialized to 0; */
|
||||
/* this gets adjusted at run-time */
|
||||
static int ft_trace_levels_enabled[trace_count];
|
||||
|
||||
/* array of trace levels, always initialized to 0 */
|
||||
static int ft_trace_levels_disabled[trace_count];
|
||||
/* array of trace levels, always initialized to 0 */
|
||||
static int ft_trace_levels_disabled[trace_count];
|
||||
|
||||
/* a pointer to either `ft_trace_levels_enabled' */
|
||||
/* or `ft_trace_levels_disabled' */
|
||||
int* ft_trace_levels;
|
||||
/* a pointer to either `ft_trace_levels_enabled' */
|
||||
/* or `ft_trace_levels_disabled' */
|
||||
int* ft_trace_levels;
|
||||
|
||||
/* define array of trace toggle names */
|
||||
/* define array of trace toggle names */
|
||||
#define FT_TRACE_DEF( x ) #x ,
|
||||
|
||||
static const char* ft_trace_toggles[trace_count + 1] =
|
||||
{
|
||||
static const char* ft_trace_toggles[trace_count + 1] =
|
||||
{
|
||||
#include <freetype/internal/fttrace.h>
|
||||
NULL
|
||||
};
|
||||
};
|
||||
|
||||
#undef FT_TRACE_DEF
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( FT_Int )
|
||||
FT_Trace_Get_Count( void )
|
||||
FT_BASE_DEF( FT_Int )
|
||||
FT_Trace_Get_Count( void )
|
||||
{
|
||||
return trace_count;
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( const char * )
|
||||
FT_Trace_Get_Name( FT_Int idx )
|
||||
{
|
||||
int max = FT_Trace_Get_Count();
|
||||
|
||||
|
||||
if ( idx < max )
|
||||
return ft_trace_toggles[idx];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* 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
|
||||
* value of the `FT2_DEBUG' environment variable. It must be a list of
|
||||
* toggles, separated by spaces, `;', or `,'. Example:
|
||||
*
|
||||
* export FT2_DEBUG="any:3 memory:7 stream:5"
|
||||
*
|
||||
* This requests that all levels be set to 3, except the trace level for
|
||||
* the memory and stream components which are set to 7 and 5,
|
||||
* respectively.
|
||||
*
|
||||
* See the file `include/freetype/internal/fttrace.h' for details of
|
||||
* the available toggle names.
|
||||
*
|
||||
* The level must be between 0 and 7; 0 means quiet (except for serious
|
||||
* runtime errors), and 7 means _very_ verbose.
|
||||
*/
|
||||
FT_BASE_DEF( void )
|
||||
ft_debug_init( void )
|
||||
{
|
||||
const char* ft2_debug = NULL;
|
||||
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
if( ft_custom_trace_level != NULL )
|
||||
ft2_debug = ft_custom_trace_level;
|
||||
else
|
||||
ft2_debug = ft_default_trace_level;
|
||||
|
||||
#else
|
||||
ft2_debug = ft_getenv( "FT2_DEBUG" );
|
||||
#endif /* FT_LOGGIGN */
|
||||
|
||||
if ( ft2_debug )
|
||||
{
|
||||
return trace_count;
|
||||
}
|
||||
const char* p = ft2_debug;
|
||||
const char* q;
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( const char * )
|
||||
FT_Trace_Get_Name( FT_Int idx )
|
||||
{
|
||||
int max = FT_Trace_Get_Count();
|
||||
|
||||
|
||||
if ( idx < max )
|
||||
return ft_trace_toggles[idx];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* 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
|
||||
* value of the `FT2_DEBUG' environment variable. It must be a list of
|
||||
* toggles, separated by spaces, `;', or `,'. Example:
|
||||
*
|
||||
* export FT2_DEBUG="any:3 memory:7 stream:5"
|
||||
*
|
||||
* This requests that all levels be set to 3, except the trace level for
|
||||
* the memory and stream components which are set to 7 and 5,
|
||||
* respectively.
|
||||
*
|
||||
* See the file `include/freetype/internal/fttrace.h' for details of
|
||||
* the available toggle names.
|
||||
*
|
||||
* The level must be between 0 and 7; 0 means quiet (except for serious
|
||||
* runtime errors), and 7 means _very_ verbose.
|
||||
*/
|
||||
FT_BASE_DEF( void )
|
||||
ft_debug_init( void )
|
||||
{
|
||||
const char* ft2_debug = getenv( "FT2_DEBUG" );
|
||||
|
||||
|
||||
if ( ft2_debug )
|
||||
for ( ; *p; p++ )
|
||||
{
|
||||
const char* p = ft2_debug;
|
||||
const char* q;
|
||||
/* skip leading whitespace and separators */
|
||||
if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
|
||||
continue;
|
||||
|
||||
|
||||
for ( ; *p; p++ )
|
||||
{
|
||||
/* skip leading whitespace and separators */
|
||||
if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
|
||||
continue;
|
||||
|
||||
/* read toggle name, followed by ':' */
|
||||
q = p;
|
||||
while ( *p && *p != ':' )
|
||||
p++;
|
||||
|
||||
if ( !*p )
|
||||
break;
|
||||
|
||||
if ( *p == ':' && p > q )
|
||||
#ifdef FT_LOGGING
|
||||
/* check extra arguments for logging */
|
||||
if( *p == '-' )
|
||||
{
|
||||
FT_Int n, i, len = (FT_Int)( p - q );
|
||||
FT_Int level = -1, found = -1;
|
||||
|
||||
|
||||
for ( n = 0; n < trace_count; n++ )
|
||||
const char* r = ++p;
|
||||
if( *r == 'v' )
|
||||
{
|
||||
const char* toggle = ft_trace_toggles[n];
|
||||
|
||||
|
||||
for ( i = 0; i < len; i++ )
|
||||
ft_component_flag = true;
|
||||
const char* s = ++r;
|
||||
if( *s == 't' )
|
||||
{
|
||||
if ( toggle[i] != q[i] )
|
||||
break;
|
||||
ft_timestamp_flag = true;
|
||||
p++;
|
||||
}
|
||||
|
||||
if ( i == len && toggle[i] == 0 )
|
||||
p++;
|
||||
}
|
||||
else if( *r == 't' )
|
||||
{
|
||||
ft_timestamp_flag = true;
|
||||
const char* s = ++r;
|
||||
if( *s == 'v' )
|
||||
{
|
||||
found = n;
|
||||
ft_component_flag = true;
|
||||
p++;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
/* read toggle name, followed by ':' */
|
||||
q = p;
|
||||
while ( *p && *p != ':' )
|
||||
p++;
|
||||
|
||||
if ( !*p )
|
||||
break;
|
||||
|
||||
if ( *p == ':' && p > q )
|
||||
{
|
||||
FT_Int n, i, len = (FT_Int)( p - q );
|
||||
FT_Int level = -1, found = -1;
|
||||
|
||||
|
||||
for ( n = 0; n < trace_count; n++ )
|
||||
{
|
||||
const char* toggle = ft_trace_toggles[n];
|
||||
|
||||
|
||||
for ( i = 0; i < len; i++ )
|
||||
{
|
||||
if ( toggle[i] != q[i] )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* read level */
|
||||
p++;
|
||||
if ( *p )
|
||||
if ( i == len && toggle[i] == 0 )
|
||||
{
|
||||
level = *p - '0';
|
||||
if ( level < 0 || level > 7 )
|
||||
level = -1;
|
||||
found = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( found >= 0 && level >= 0 )
|
||||
/* read level */
|
||||
p++;
|
||||
if ( *p )
|
||||
{
|
||||
level = *p - '0';
|
||||
if ( level < 0 || level > 7 )
|
||||
level = -1;
|
||||
}
|
||||
|
||||
if ( found >= 0 && level >= 0 )
|
||||
{
|
||||
if ( found == trace_any )
|
||||
{
|
||||
if ( found == trace_any )
|
||||
{
|
||||
/* special case for `any' */
|
||||
for ( n = 0; n < trace_count; n++ )
|
||||
ft_trace_levels_enabled[n] = level;
|
||||
}
|
||||
else
|
||||
ft_trace_levels_enabled[found] = level;
|
||||
/* special case for `any' */
|
||||
for ( n = 0; n < trace_count; n++ )
|
||||
ft_trace_levels_enabled[n] = level;
|
||||
}
|
||||
else
|
||||
ft_trace_levels_enabled[found] = level;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ft_trace_levels = ft_trace_levels_enabled;
|
||||
}
|
||||
|
||||
ft_trace_levels = ft_trace_levels_enabled;
|
||||
}
|
||||
|
||||
|
||||
#else /* !FT_DEBUG_LEVEL_TRACE */
|
||||
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
ft_debug_init( void )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
FT_BASE_DEF( void )
|
||||
ft_debug_init( void )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
|
||||
FT_BASE_DEF( FT_Int )
|
||||
FT_Trace_Get_Count( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
FT_BASE_DEF( FT_Int )
|
||||
FT_Trace_Get_Count( void )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
FT_BASE_DEF( const char * )
|
||||
FT_Trace_Get_Name( FT_Int idx )
|
||||
{
|
||||
FT_UNUSED( idx );
|
||||
FT_BASE_DEF( const char * )
|
||||
FT_Trace_Get_Name( FT_Int idx )
|
||||
{
|
||||
FT_UNUSED( idx );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Trace_Disable( void )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
FT_BASE_DEF( void )
|
||||
FT_Trace_Disable( void )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Trace_Enable( void )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
/* documentation is in ftdebug.h */
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Trace_Enable( void )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
#endif /* !FT_DEBUG_LEVEL_TRACE */
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* If FT_LOGGING is enabled, FreeType needs to initialize all logging
|
||||
* variables to write logs.
|
||||
* Therefore it uses `ft_logging_init()` function to initialize a
|
||||
* loggging variables and `ft_logging_deinit()` to un-initialize the
|
||||
* logging variables.
|
||||
*
|
||||
*/
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
ft_logging_init( void )
|
||||
{
|
||||
ft_default_log_handler = ft_log_handler;
|
||||
ft_default_trace_level = ft_getenv( "FT2_DEBUG" );
|
||||
if( ft_getenv( "FT_LOGGING_FILE" ) )
|
||||
ft_fileptr = fopen( ft_getenv( "FT_LOGGING_FILE" ) , "w" );
|
||||
else
|
||||
ft_fileptr = stderr;
|
||||
|
||||
ft_debug_init();
|
||||
/* We need to set the default FreeType specific dlg's output handler */
|
||||
dlg_set_handler( ft_default_log_handler, NULL );
|
||||
|
||||
}
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
ft_logging_deinit( void )
|
||||
{
|
||||
fclose( ft_fileptr );
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* An Output log handler specific to FreeType used by dlg library.
|
||||
*
|
||||
*/
|
||||
FT_BASE_DEF( void )
|
||||
ft_log_handler( const struct dlg_origin* origin,
|
||||
const char* string,
|
||||
void* data )
|
||||
{
|
||||
( void ) data;
|
||||
char* features ;
|
||||
if( ft_timestamp_flag && ft_component_flag && ft_have_newline_char )
|
||||
features = "[%h:%m %t]";
|
||||
else if( ft_component_flag && ft_have_newline_char)
|
||||
features = "[%t]";
|
||||
else if( ft_timestamp_flag && ft_have_newline_char )
|
||||
features = "[%h:%m]";
|
||||
else
|
||||
features = "";
|
||||
|
||||
long int tag_length = strlen( *origin->tags );
|
||||
long int features_length = strlen( features );
|
||||
|
||||
char* features_ = (char*)malloc( sizeof(char) * (features_length + 18) );
|
||||
|
||||
strcpy( features_, features );
|
||||
|
||||
if( ft_have_newline_char && ( ft_component_flag || ft_timestamp_flag ) )
|
||||
{
|
||||
long int num_of_spaces = 15 - tag_length;
|
||||
int i;
|
||||
for( i = 0; i < num_of_spaces; i++ )
|
||||
strcat( features_, " " );
|
||||
}
|
||||
|
||||
strcat( features_, "%c" );
|
||||
|
||||
dlg_generic_outputf_stream( ft_fileptr, (const char*)features_, origin, string,
|
||||
dlg_default_output_styles, true );
|
||||
|
||||
|
||||
if( strchr( string, '\n' ) )
|
||||
ft_have_newline_char = true;
|
||||
else
|
||||
ft_have_newline_char = false;
|
||||
|
||||
}
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
FT_BASE_DEF( void )
|
||||
ft_add_tag( const char* tag )
|
||||
{
|
||||
ft_component = tag;
|
||||
dlg_add_tag( tag, NULL );
|
||||
}
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
FT_BASE_DEF( void )
|
||||
ft_remove_tag( const char* tag )
|
||||
{
|
||||
dlg_remove_tag( tag, NULL );
|
||||
}
|
||||
|
||||
/* documentation is in ftlogging.h */
|
||||
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Trace_Set_Level( const char* level )
|
||||
{
|
||||
ft_component_flag = NULL;
|
||||
ft_timestamp_flag = NULL;
|
||||
ft_custom_trace_level = level;
|
||||
ft_debug_init();
|
||||
}
|
||||
|
||||
/* documentation is in ftlogging.h */
|
||||
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Trace_Set_Default_Level( void )
|
||||
{
|
||||
ft_component_flag = NULL;
|
||||
ft_timestamp_flag = NULL;
|
||||
ft_custom_trace_level = NULL ;
|
||||
ft_debug_init();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Functions to handle custom log handler:
|
||||
*
|
||||
*/
|
||||
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Set_Log_Handler( FT_Custom_Log_Handler handler )
|
||||
{
|
||||
custom_output_handler = handler;
|
||||
}
|
||||
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Set_Default_Log_Handler()
|
||||
{
|
||||
custom_output_handler = NULL;
|
||||
}
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Callback( const char* fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_start( ap, fmt );
|
||||
custom_output_handler( ft_component , fmt, ap );
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
/* END */
|
||||
|
@ -89,11 +89,11 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\..\src\dlg\;$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;DLL_EXPORT;FT_LOGGING;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<DisableLanguageExtensions>true</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
@ -111,15 +111,18 @@
|
||||
<AdditionalLibraryDirectories>$(UserLibraryDirectories);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>$(UserDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Lib>
|
||||
<PreBuildEvent>
|
||||
<Command>call $(SolutionDir)script.bat</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\..\src\dlg\;$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;DLL_EXPORT;FT_LOGGING;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<DisableLanguageExtensions>true</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
@ -137,15 +140,18 @@
|
||||
<AdditionalLibraryDirectories>$(UserLibraryDirectories);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>$(UserDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Lib>
|
||||
<PreBuildEvent>
|
||||
<Command>call $(SolutionDir)script.bat</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\..\src\dlg;$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;FT_LOGGING;DLG_STATIC;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<DisableLanguageExtensions>true</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
@ -163,15 +169,18 @@
|
||||
<AdditionalLibraryDirectories>$(UserLibraryDirectories);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>$(UserDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Lib>
|
||||
<PreBuildEvent>
|
||||
<Command>call $(SolutionDir)script.bat</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\..\src\dlg;$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;FT_LOGGING;DLG_STATIC;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<DisableLanguageExtensions>true</DisableLanguageExtensions>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
@ -189,12 +198,15 @@
|
||||
<AdditionalLibraryDirectories>$(UserLibraryDirectories);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>$(UserDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Lib>
|
||||
<PreBuildEvent>
|
||||
<Command>call $(SolutionDir)script.bat</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\src\dlg;$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT2_BUILD_LIBRARY;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
@ -221,7 +233,7 @@
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\src\dlg;$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT2_BUILD_LIBRARY;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
@ -248,7 +260,7 @@
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\src\dlg;$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT2_BUILD_LIBRARY;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
@ -275,7 +287,7 @@
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\src\dlg;$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT2_BUILD_LIBRARY;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
@ -323,6 +335,7 @@
|
||||
<ClCompile Include="..\..\..\src\cache\ftcache.c" />
|
||||
<ClCompile Include="..\..\..\src\cff\cff.c" />
|
||||
<ClCompile Include="..\..\..\src\cid\type1cid.c" />
|
||||
<ClCompile Include="..\..\..\src\dlg\dlgwrap.c" />
|
||||
<ClCompile Include="..\..\..\src\gzip\ftgzip.c" />
|
||||
<ClCompile Include="..\..\..\src\lzw\ftlzw.c" />
|
||||
<ClCompile Include="..\..\..\src\pcf\pcf.c" />
|
||||
@ -348,4 +361,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
<Copy SourceFiles="$(TargetPath)" DestinationFolder="..\..\..\objs" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
@ -131,6 +131,9 @@
|
||||
<ClCompile Include="..\..\..\src\base\ftwinfnt.c">
|
||||
<Filter>Source Files\FT_MODULES</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\dlg\dlgwrap.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\..\..\src\base\ftver.rc">
|
||||
|
11
builds/windows/vc2010/script.bat
Normal file
11
builds/windows/vc2010/script.bat
Normal file
@ -0,0 +1,11 @@
|
||||
@echo OFF
|
||||
|
||||
:: Move to Top Dir
|
||||
cd ..\..\..\
|
||||
|
||||
:: Copy dlg's files from `submodules\dlg' to `src\dlg'
|
||||
IF NOT EXIST src\dlg\dlg (
|
||||
mkdir src\dlg\dlg
|
||||
COPY submodules\dlg\include\dlg\dlg.h src\dlg\dlg
|
||||
COPY submodules\dlg\include\dlg\output.h src\dlg\dlg
|
||||
COPY submodules\dlg\src\dlg\dlg.c src\dlg\ )
|
@ -431,6 +431,21 @@ 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`.
|
||||
* For writing logs to file FreeType uses an external library `dlg`
|
||||
* Source Code - `src/dlg`
|
||||
*
|
||||
*/
|
||||
#define FT_LOGGING
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Autofitter debugging
|
||||
|
132
docs/DEBUG
132
docs/DEBUG
@ -44,6 +44,32 @@ located in the file `ftoption.h'. The macros are:
|
||||
When `FT2_DEBUG_MEMORY' isn't defined at runtime, the debugging
|
||||
memory manager is ignored, and performance is unaffected.
|
||||
|
||||
FT_LOGGING
|
||||
|
||||
As mentioned above if `FT_DEBUG_LEVEL_ERROR' and
|
||||
`FT_DEBUG_LEVEL_TRACE' macros are defined, FreeType will send the
|
||||
debug and trace logs outputted from `FT_ERROR' and `FT_TRACE'
|
||||
macros to `stderr'.
|
||||
|
||||
`FT_LOGGING' is a new macro which is introduced to enhance the
|
||||
capabilities of `FT_TRACE' and `FT_ERROR' macros.
|
||||
`FT_LOGGING' macro depends on `FT_DEBUG_LEVEL_TRACE' and
|
||||
`FT_DEBUG_LEVEL_ERROR', therefore these macros will automatically
|
||||
be #defined once `FT_LOGGING' macro is #defined and
|
||||
the behaviour of `FT_TRACE' and `FT_ERROR' macros will change.
|
||||
Now, `FT_TRACE' and `FT_ERROR' macros will start sending the
|
||||
tracing and debugging messages to the file system instead of
|
||||
`stderr'.
|
||||
On the file system the log file will be generated on the path
|
||||
specified using `FT_LOGGING_FILE' environment variable(more on
|
||||
this later).
|
||||
|
||||
There is an additional support of logging Time and the name of
|
||||
the `FT_COMPONENT' from which the current log is generated along
|
||||
with the actual tracing and debugging message, and for this user
|
||||
will have to define additional tags under the `FT2_DEBUG'
|
||||
environment variable(More details under section `FT2_DEBUG' under
|
||||
Environment Variables heading).
|
||||
|
||||
II. Debugging macros
|
||||
--------------------
|
||||
@ -150,6 +176,48 @@ behaviour of FreeType at runtime.
|
||||
the memory and io components, which are set to the trace levels 5
|
||||
and 4, respectively.
|
||||
|
||||
`FT_LOGGING' related tags:
|
||||
|
||||
As mentioned above in the `FT_LOGGING' section below are the
|
||||
additional tags which can be added in `FT2_DEBUG' environment
|
||||
variable to log the time and the value of `FT_COMPONENT' in the
|
||||
actual log message:
|
||||
* -v: For printing the name of FreeType's component from which
|
||||
the current log is produced.
|
||||
* -t: For printing the time(in milliseconds) along with actual
|
||||
log message.
|
||||
|
||||
Example:
|
||||
|
||||
Case 1: FT2_DEBUG="any:7 memory:5 -vt"
|
||||
|
||||
[20:32:02:44969 ttload] table directory loaded
|
||||
|
||||
Case 2: FT2_DEBUG="any:7 memory:5 -t"
|
||||
|
||||
[20:32:02:44969 ttload] table directory loaded
|
||||
|
||||
Case 3: FT2_DEBUG="any:7 memory:5 -v"
|
||||
|
||||
[ttload] table directory loaded
|
||||
|
||||
|
||||
FT_LOGGING_FILE
|
||||
|
||||
This variable is only used when FreeType is built with
|
||||
`FT_LOGGING' macro defined. It contains the path to the file where
|
||||
the user wants to put his log file.
|
||||
|
||||
On Linux with bash:
|
||||
export FT_LOGGING_FILE="/tmp/freetype2.log"
|
||||
|
||||
On Windows:
|
||||
set FT_LOGGING_FILE=C:\Users\AppData\Local\Temp\freetype2.log
|
||||
|
||||
Use the following `FT_LOGGING_FILE' value to print logs to stderr.
|
||||
|
||||
export FT_LOGGING_FILE=/dev/stderr
|
||||
|
||||
|
||||
FT2_DEBUG_MEMORY
|
||||
|
||||
@ -201,6 +269,70 @@ behaviour of FreeType at runtime.
|
||||
If it is undefined, or if its value is not strictly positive,
|
||||
freed blocks are released at runtime.
|
||||
|
||||
|
||||
IV. Additional Capabilities with `FT_LOGGING'
|
||||
--------------------------------------------
|
||||
|
||||
With the support of `FT_LOGGING', four APIs have been introduced for
|
||||
providing additional debugging support to the applications using
|
||||
FreeType.
|
||||
|
||||
FT_Trace_Set_Level( const char* )
|
||||
|
||||
If FreeType is configured with `FT_LOGGING' the levels of tracing
|
||||
component set using `FT2_DEBUG' environment variable is considered
|
||||
as a default value.
|
||||
And this function can be used change/set the value of the levels
|
||||
of tracing components at run-time.
|
||||
|
||||
NOTE: If the environment variable `FT2_DEBUG is not defined the
|
||||
default value of the levels of tracing components will be NULL.
|
||||
|
||||
FT_Trace_Set_Default_Level():
|
||||
|
||||
If previously, `FT_Trace_Set_Level' functions is used to set new
|
||||
values of the tracing components of FreeType, this function could
|
||||
be used to reset the level of tracing components to the default
|
||||
value.
|
||||
Hence, the functions `FT_Trace_Set_Default_Level' and
|
||||
`FT_Trace_Set_Level' could be combined and used together to
|
||||
change the trace levels of FreeType's components for a particular
|
||||
block of code.
|
||||
|
||||
FT_Set_Log_Handler( ft_custom_log_handler ):
|
||||
|
||||
This API has been provided under the `FT_LOGGING' macro to support
|
||||
a feature wherein a custom log handler can be provided based on
|
||||
user’s choice. Doing so, FreeType will start calling the custom
|
||||
handler for new log messages and will no longer write these
|
||||
messages in predefined log file of FreeType. It will totally
|
||||
depend on user how the log messages will be handled.
|
||||
User just need to call this API with an argument of type
|
||||
ft_custom_log_handler which should match following function
|
||||
prototype:
|
||||
|
||||
void (*ft_custom_log_handler)( const char* ft_component,
|
||||
const char* fmt,
|
||||
va_list args );
|
||||
|
||||
|
||||
|
||||
FT_Set_Default_Log_Handler():
|
||||
|
||||
If the user has chosen to set a custom log handler using the
|
||||
`FT_Set_Log_Handler' API above, the current API can be used to
|
||||
reset back the log handler to the Freetype's inbuilt log handler.
|
||||
Hence, the functions `FT_Set_Default_Log_Handler' and
|
||||
`FT_Set_Log_Handler' in combination can be used to separately
|
||||
handle the trace or error logs generated by a particular block
|
||||
of code.
|
||||
|
||||
|
||||
Applications need to #include the following header file to avail the
|
||||
above APIs:
|
||||
|
||||
#include<freetype/ftlogging.h>
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Copyright (C) 2002-2020 by
|
||||
|
@ -431,6 +431,21 @@ 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`.
|
||||
* For writing logs to file FreeType uses an external library `dlg`
|
||||
* Source Code - `src/dlg`
|
||||
*
|
||||
*/
|
||||
/* #define FT_LOGGING */
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Autofitter debugging
|
||||
|
@ -123,6 +123,7 @@
|
||||
* gzip
|
||||
* lzw
|
||||
* bzip2
|
||||
* debugging_apis
|
||||
*
|
||||
*/
|
||||
|
||||
|
149
include/freetype/ftlogging.h
Normal file
149
include/freetype/ftlogging.h
Normal file
@ -0,0 +1,149 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* ftlogging.h
|
||||
*
|
||||
* Additional debugging APIs.
|
||||
*
|
||||
* Copyright (C) 2008-2020 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used,
|
||||
* modified, and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify, or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FTLOGGING_H_
|
||||
#define FTLOGGING_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_CONFIG_CONFIG_H
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* debugging_apis
|
||||
*
|
||||
* @title:
|
||||
* External Debugging APIs
|
||||
*
|
||||
* @abstract:
|
||||
* Pubic APIs to use while debugging using `FT_LOGGING' macro
|
||||
*
|
||||
* @description:
|
||||
* This section contains the declaration of the public APIs which can be
|
||||
* used to debug an application using `FT_LOGGING'.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Trace_Set_Level
|
||||
*
|
||||
* @description:
|
||||
* To change the levels of tracing components of FreeType, at run time.
|
||||
*
|
||||
* @input:
|
||||
*
|
||||
* tracing_level ::
|
||||
* New tracing values of FreeType's components.
|
||||
*
|
||||
* @example:
|
||||
* This function can be used to change the levels of tracing components
|
||||
* of FreeType as follows:
|
||||
*
|
||||
* ```
|
||||
* new_levels = "any:7 memory:0";
|
||||
* FT_Trace_Set_Level( new_levels );
|
||||
* ```
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Trace_Set_Level( const char* tracing_level );
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Trace_Set_Default_Level
|
||||
*
|
||||
* @description:
|
||||
* If previously, `FT_Trace_Set_Level' functions is used to set new
|
||||
* tracing values of FreeType components, this function could be used to
|
||||
* reset the tracing values of FreeType's components to the default value.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Trace_Set_Default_Level( void );
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @functype:
|
||||
* FT_Custom_Log_Handler
|
||||
*
|
||||
* @description:
|
||||
* Function which is used to handle the logging of tracing and debug messages
|
||||
* on a file system.
|
||||
*
|
||||
* @input:
|
||||
* ft_component ::
|
||||
* The name of `FT_COMPONENT' from which the current debug or error
|
||||
* message is produced.
|
||||
*
|
||||
* fmt ::
|
||||
* Actual debug or tracing message.
|
||||
*
|
||||
* args::
|
||||
* Arguments of debug or tracing messages.
|
||||
*
|
||||
*/
|
||||
typedef void
|
||||
(*FT_Custom_Log_Handler)( const char* ft_component,
|
||||
const char* fmt,
|
||||
va_list args );
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Set_Log_Handler
|
||||
*
|
||||
* @description:
|
||||
* A function to set a custom log handler
|
||||
*
|
||||
* @input:
|
||||
*
|
||||
* handler ::
|
||||
* New logging function
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Set_Log_Handler( FT_Custom_Log_Handler handler );
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Set_Default_Log_Handler
|
||||
*
|
||||
* @description:
|
||||
* If previously, `FT_Set_Log_Handler' functions is used to set new
|
||||
* custom logging function, this API could be used to reset the back
|
||||
* the log handler to FreeType's inbuilt log handler.
|
||||
*
|
||||
*/
|
||||
|
||||
FT_EXPORT( void )
|
||||
FT_Set_Default_Log_Handler( void );
|
||||
|
||||
/* */
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTLOGGING_H_ */
|
@ -31,9 +31,29 @@
|
||||
|
||||
#include "compiler-macros.h"
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Additional include files for supporting logging in FreeType using
|
||||
* external logging library ~ src/dlg and freetype/ftlogging.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
#include <../src/dlg/dlg/dlg.h>
|
||||
#include <../src/dlg/dlg/output.h>
|
||||
#include <freetype/ftlogging.h>
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/* force the definition of FT_DEBUG_LEVEL_TRACE if FT_LOGGING is already*/
|
||||
/* defined; therefore the following #ifdefs */
|
||||
/* */
|
||||
#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 */
|
||||
@ -84,18 +104,59 @@ FT_BEGIN_HEADER
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
/* we need two macros to convert the names of `FT_COMPONENT' to a string */
|
||||
#define FT_LOGGING_TAG( x ) FT_LOGGING_TAG_( x )
|
||||
#define FT_LOGGING_TAG_( x ) #x
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
*/
|
||||
|
||||
#define FT_LOG( level, varformat ) \
|
||||
do \
|
||||
{ \
|
||||
const char* dlg_tag = FT_LOGGING_TAG( FT_COMPONENT ); \
|
||||
ft_add_tag( dlg_tag ); \
|
||||
if( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \
|
||||
{ \
|
||||
if( custom_output_handler != NULL ) \
|
||||
FT_Callback varformat; \
|
||||
else \
|
||||
dlg_trace varformat; \
|
||||
} \
|
||||
ft_remove_tag( dlg_tag ); \
|
||||
}while( 0 )
|
||||
|
||||
#else
|
||||
#define FT_LOG( level, varformat ) \
|
||||
do \
|
||||
{ \
|
||||
if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \
|
||||
{ \
|
||||
FT_Message varformat; \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
|
||||
/* we need two macros here to make cpp expand `FT_COMPONENT' */
|
||||
#define FT_TRACE_COMP( x ) FT_TRACE_COMP_( x )
|
||||
#define FT_TRACE_COMP_( x ) trace_ ## x
|
||||
|
||||
#define FT_TRACE( level, varformat ) \
|
||||
do \
|
||||
{ \
|
||||
if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \
|
||||
FT_Message varformat; \
|
||||
} while ( 0 )
|
||||
#define FT_TRACE( level, varformat ) FT_LOG( level, varformat )
|
||||
|
||||
#else /* !FT_DEBUG_LEVEL_TRACE */
|
||||
|
||||
@ -204,8 +265,32 @@ FT_BEGIN_HEADER
|
||||
|
||||
#ifdef FT_DEBUG_LEVEL_ERROR
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* If FT_LOGGING is enabled, error messages will be sent to dlg's API and
|
||||
* if is FT_LOGGING is disabled error messages will be sent to
|
||||
* FT_Message(defined in ftdebug.c)
|
||||
* Therefore the following macros:
|
||||
*
|
||||
*/
|
||||
|
||||
#define FT_ERROR( varformat ) \
|
||||
do \
|
||||
{ \
|
||||
const char* dlg_tag = FT_LOGGING_TAG( FT_COMPONENT ); \
|
||||
ft_add_tag( dlg_tag ); \
|
||||
dlg_trace varformat; \
|
||||
ft_remove_tag( dlg_tag ); \
|
||||
} while ( 0 )
|
||||
|
||||
#else
|
||||
|
||||
#define FT_ERROR( varformat ) FT_Message varformat
|
||||
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
#else /* !FT_DEBUG_LEVEL_ERROR */
|
||||
|
||||
#define FT_ERROR( varformat ) do { } while ( 0 ) /* nothing */
|
||||
@ -277,6 +362,75 @@ FT_BEGIN_HEADER
|
||||
FT_BASE( void )
|
||||
ft_debug_init( void );
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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_log_handler( const struct dlg_origin* origin,
|
||||
const char* string,
|
||||
void* data );
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Variables used when FT_LOGGING is enabled to control logging:
|
||||
*
|
||||
* 1. ft_default_log_handler: stores the function pointer which is used
|
||||
* internally by FreeType to print logs to file.
|
||||
*
|
||||
* 2. custom_output_handler: stores the function pointer to the callback
|
||||
* function provided by user.
|
||||
*
|
||||
* These are defined in ftdebug.c
|
||||
*/
|
||||
extern dlg_handler ft_default_log_handler;
|
||||
extern FT_Custom_Log_Handler custom_output_handler;
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* If FT_LOGGING macro is enabled, Freetype needs to initialize and
|
||||
* un-initialize FILE* using following functions
|
||||
* These functions are defined in ftdebug.c
|
||||
*
|
||||
*/
|
||||
|
||||
FT_BASE( void )
|
||||
ft_logging_init( void );
|
||||
|
||||
FT_BASE( void )
|
||||
ft_logging_deinit( void );
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* For printing the name of `FT_COMPONENT' along with the actual log, a dlg
|
||||
* tag with the name of `FT_COMPONENT' needs to be added.
|
||||
*
|
||||
*/
|
||||
FT_BASE( void )
|
||||
ft_add_tag( const char* tag );
|
||||
|
||||
FT_BASE( void )
|
||||
ft_remove_tag( const char* tag );
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
FT_BASE( void )
|
||||
FT_Callback( const char* fmt,
|
||||
... );
|
||||
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTDEBUG_H_ */
|
||||
|
@ -44,6 +44,49 @@
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Variable used when FT_LOGGING is enabled to control logging:
|
||||
*
|
||||
* 1. ft_default_trace_level: stores the value of trace levels which are
|
||||
* provided to FreeType using FT2_DEBUG environment variable.
|
||||
*
|
||||
* 2. ft_fileptr: store the FILE*
|
||||
*
|
||||
* 3. ft_component: a string that holds the name of FT_COMPONENT
|
||||
*
|
||||
* 4. ft_component_flag: a flag when true, prints the name of
|
||||
* FT_COMPONENT along with actual log message.
|
||||
*
|
||||
* 5. ft_timestamp_flag: a flag when true, prints time along with log
|
||||
* actual log message.
|
||||
*
|
||||
* 6. ft_have_newline_char: It is used to differentiate between a log
|
||||
* message with '\n' char and log message without '\n' char
|
||||
*
|
||||
* 7. ft_custom_trace_level: stores the value of custom trace level which
|
||||
* is provided by user at run-time.
|
||||
*
|
||||
* Static Variables are defined here to remove [ -Wunused-variable ]
|
||||
* warning
|
||||
*
|
||||
*/
|
||||
static const char* ft_default_trace_level = NULL;
|
||||
static FILE* ft_fileptr = NULL;
|
||||
static const char* ft_component = NULL;
|
||||
static bool ft_component_flag = false;
|
||||
static bool ft_timestamp_flag = false;
|
||||
static bool ft_have_newline_char = true;
|
||||
static const char* ft_custom_trace_level = NULL;
|
||||
|
||||
/* declared in ftdebug.h */
|
||||
|
||||
dlg_handler ft_default_log_handler = NULL;
|
||||
FT_Custom_Log_Handler custom_output_handler = NULL;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef FT_DEBUG_LEVEL_ERROR
|
||||
|
||||
@ -195,8 +238,18 @@
|
||||
FT_BASE_DEF( void )
|
||||
ft_debug_init( void )
|
||||
{
|
||||
const char* ft2_debug = ft_getenv( "FT2_DEBUG" );
|
||||
const char* ft2_debug = NULL;
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
if( ft_custom_trace_level != NULL )
|
||||
ft2_debug = ft_custom_trace_level;
|
||||
else
|
||||
ft2_debug = ft_default_trace_level;
|
||||
|
||||
#else
|
||||
ft2_debug = ft_getenv( "FT2_DEBUG" );
|
||||
#endif /* FT_LOGGIGN */
|
||||
|
||||
if ( ft2_debug )
|
||||
{
|
||||
@ -210,6 +263,36 @@
|
||||
if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
|
||||
continue;
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
/* check extra arguments for logging */
|
||||
if( *p == '-' )
|
||||
{
|
||||
const char* r = ++p;
|
||||
if( *r == 'v' )
|
||||
{
|
||||
ft_component_flag = true;
|
||||
const char* s = ++r;
|
||||
if( *s == 't' )
|
||||
{
|
||||
ft_timestamp_flag = true;
|
||||
p++;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
else if( *r == 't' )
|
||||
{
|
||||
ft_timestamp_flag = true;
|
||||
const char* s = ++r;
|
||||
if( *s == 'v' )
|
||||
{
|
||||
ft_component_flag = true;
|
||||
p++;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
/* read toggle name, followed by ':' */
|
||||
q = p;
|
||||
while ( *p && *p != ':' )
|
||||
@ -314,5 +397,153 @@
|
||||
|
||||
#endif /* !FT_DEBUG_LEVEL_TRACE */
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* If FT_LOGGING is enabled, FreeType needs to initialize all logging
|
||||
* variables to write logs.
|
||||
* Therefore it uses `ft_logging_init()` function to initialize a
|
||||
* loggging variables and `ft_logging_deinit()` to un-initialize the
|
||||
* logging variables.
|
||||
*
|
||||
*/
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
ft_logging_init( void )
|
||||
{
|
||||
ft_default_log_handler = ft_log_handler;
|
||||
ft_default_trace_level = ft_getenv( "FT2_DEBUG" );
|
||||
if( ft_getenv( "FT_LOGGING_FILE" ) )
|
||||
ft_fileptr = fopen( ft_getenv( "FT_LOGGING_FILE" ) , "w" );
|
||||
else
|
||||
ft_fileptr = stderr;
|
||||
|
||||
ft_debug_init();
|
||||
/* We need to set the default FreeType specific dlg's output handler */
|
||||
dlg_set_handler( ft_default_log_handler, NULL );
|
||||
|
||||
}
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
ft_logging_deinit( void )
|
||||
{
|
||||
fclose( ft_fileptr );
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* An Output log handler specific to FreeType used by dlg library.
|
||||
*
|
||||
*/
|
||||
FT_BASE_DEF( void )
|
||||
ft_log_handler( const struct dlg_origin* origin,
|
||||
const char* string,
|
||||
void* data )
|
||||
{
|
||||
( void ) data;
|
||||
char* features ;
|
||||
if( ft_timestamp_flag && ft_component_flag && ft_have_newline_char )
|
||||
features = "[%h:%m %t]";
|
||||
else if( ft_component_flag && ft_have_newline_char)
|
||||
features = "[%t]";
|
||||
else if( ft_timestamp_flag && ft_have_newline_char )
|
||||
features = "[%h:%m]";
|
||||
else
|
||||
features = "";
|
||||
|
||||
long int tag_length = strlen( *origin->tags );
|
||||
long int features_length = strlen( features );
|
||||
|
||||
char features_[ features_length + 18 ];
|
||||
|
||||
strcpy( features_, features );
|
||||
|
||||
if( ft_have_newline_char && ( ft_component_flag || ft_timestamp_flag ) )
|
||||
{
|
||||
long int num_of_spaces = 15 - tag_length;
|
||||
int i;
|
||||
for( i = 0; i < num_of_spaces; i++ )
|
||||
strcat( features_, " " );
|
||||
}
|
||||
|
||||
strcat( features_, "%c" );
|
||||
|
||||
dlg_generic_outputf_stream( ft_fileptr, (const char*)features_, origin, string,
|
||||
dlg_default_output_styles, true );
|
||||
|
||||
|
||||
if( strchr( string, '\n' ) )
|
||||
ft_have_newline_char = true;
|
||||
else
|
||||
ft_have_newline_char = false;
|
||||
|
||||
}
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
FT_BASE_DEF( void )
|
||||
ft_add_tag( const char* tag )
|
||||
{
|
||||
ft_component = tag;
|
||||
dlg_add_tag( tag, NULL );
|
||||
}
|
||||
|
||||
/* documentation is in ftdebug.h */
|
||||
FT_BASE_DEF( void )
|
||||
ft_remove_tag( const char* tag )
|
||||
{
|
||||
dlg_remove_tag( tag, NULL );
|
||||
}
|
||||
|
||||
/* documentation is in ftlogging.h */
|
||||
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Trace_Set_Level( const char* level )
|
||||
{
|
||||
ft_component_flag = NULL;
|
||||
ft_timestamp_flag = NULL;
|
||||
ft_custom_trace_level = level;
|
||||
ft_debug_init();
|
||||
}
|
||||
|
||||
/* documentation is in ftlogging.h */
|
||||
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Trace_Set_Default_Level( void )
|
||||
{
|
||||
ft_component_flag = NULL;
|
||||
ft_timestamp_flag = NULL;
|
||||
ft_custom_trace_level = NULL ;
|
||||
ft_debug_init();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Functions to handle custom log handler:
|
||||
*
|
||||
*/
|
||||
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Set_Log_Handler( FT_Custom_Log_Handler handler )
|
||||
{
|
||||
custom_output_handler = handler;
|
||||
}
|
||||
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Set_Default_Log_Handler()
|
||||
{
|
||||
custom_output_handler = NULL;
|
||||
}
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
FT_Callback( const char* fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
va_start( ap, fmt );
|
||||
custom_output_handler( ft_component , fmt, ap );
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
/* END */
|
||||
|
@ -201,6 +201,10 @@
|
||||
FT_Error error;
|
||||
FT_Memory memory;
|
||||
|
||||
/* If logging is enabled initialize the FILE* */
|
||||
#ifdef FT_LOGGING
|
||||
ft_logging_init();
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
/* check of `alibrary' delayed to `FT_New_Library' */
|
||||
|
||||
@ -248,6 +252,11 @@
|
||||
/* discard memory manager */
|
||||
FT_Done_Memory( memory );
|
||||
|
||||
/* If logging is enabled we need to close the FILE* */
|
||||
#ifdef FT_LOGGING
|
||||
ft_logging_deinit();
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
@ -1937,7 +1937,7 @@
|
||||
{
|
||||
FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer"
|
||||
" %p + 0x%08lx\n",
|
||||
i, pfb_data, pfb_lenpos ));
|
||||
i, ( void* )pfb_data, pfb_lenpos ));
|
||||
|
||||
if ( pfb_lenpos + 3 > pfb_len + 2 )
|
||||
goto Exit2;
|
||||
@ -1952,7 +1952,7 @@
|
||||
|
||||
FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer"
|
||||
" %p + 0x%08lx\n",
|
||||
i, pfb_data, pfb_pos ));
|
||||
i, ( void* )pfb_data, pfb_pos ));
|
||||
|
||||
if ( pfb_pos + 6 > pfb_len + 2 )
|
||||
goto Exit2;
|
||||
@ -1975,7 +1975,7 @@
|
||||
|
||||
FT_TRACE3(( " Load POST fragment #%d (%ld byte) to buffer"
|
||||
" %p + 0x%08lx\n",
|
||||
i, rlen, pfb_data, pfb_pos ));
|
||||
i, rlen, ( void* )pfb_data, pfb_pos ));
|
||||
|
||||
error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen );
|
||||
if ( error )
|
||||
@ -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 ) )
|
||||
|
@ -275,7 +275,7 @@
|
||||
stream->close = ft_ansi_stream_close;
|
||||
|
||||
FT_TRACE1(( "FT_Stream_Open:" ));
|
||||
FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
|
||||
FT_TRACE1(( " opened `%s' (%ld bytes) successfully\n",
|
||||
filepathname, stream->size ));
|
||||
|
||||
return FT_Err_Ok;
|
||||
|
@ -185,11 +185,11 @@
|
||||
"Added `FONT_ASCENT %hd'.\n"
|
||||
#define ACMSG2 "FONT_DESCENT property missing. " \
|
||||
"Added `FONT_DESCENT %hd'.\n"
|
||||
#define ACMSG3 "Font width != actual width. Old: %hd New: %hd.\n"
|
||||
#define ACMSG3 "Font width != actual width. Old: %d New: %d.\n"
|
||||
#define ACMSG4 "Font left bearing != actual left bearing. " \
|
||||
"Old: %hd New: %hd.\n"
|
||||
#define ACMSG5 "Font ascent != actual ascent. Old: %hd New: %hd.\n"
|
||||
#define ACMSG6 "Font descent != actual descent. Old: %hd New: %hd.\n"
|
||||
#define ACMSG6 "Font descent != actual descent. Old: %d New: %d.\n"
|
||||
#define ACMSG7 "Font height != actual height. Old: %hd New: %hd.\n"
|
||||
#define ACMSG8 "Glyph scalable width (SWIDTH) adjustments made.\n"
|
||||
#define ACMSG9 "SWIDTH field missing at line %ld. Set automatically.\n"
|
||||
|
9
src/dlg/dlgwrap.c
Normal file
9
src/dlg/dlgwrap.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
#include "dlg.c"
|
||||
#else
|
||||
/* ANSI C doesn't like empty source files */
|
||||
typedef int _dlg_dummy;
|
||||
#endif
|
67
src/dlg/rules.mk
Normal file
67
src/dlg/rules.mk
Normal file
@ -0,0 +1,67 @@
|
||||
#
|
||||
# FreeType 2 dlg logging library configuration rules
|
||||
#
|
||||
|
||||
|
||||
# Copyright (C) 1996-2020 by
|
||||
# David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
#
|
||||
# This file is part of the FreeType project, and may only be used, modified,
|
||||
# and distributed under the terms of the FreeType project license,
|
||||
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
||||
# indicate that you have read the license and understand and accept it
|
||||
# fully.
|
||||
|
||||
|
||||
# dlg logging library directory
|
||||
#
|
||||
DLG_DIR := $(SRC_DIR)/dlg
|
||||
|
||||
DLG_COMPILE := $(CC) $(ANSIFLAGS) \
|
||||
$I$(subst /,$(COMPILER_SEP),$(DLG_DIR)) \
|
||||
$(INCLUDE_FLAGS) \
|
||||
$(FT_CFLAGS)
|
||||
|
||||
|
||||
# dlg logging library sources (i.e., C files)
|
||||
#
|
||||
DLG_SRC := $(DLG_DIR)/dlgwrap.c
|
||||
|
||||
# dlg logging library headers
|
||||
#
|
||||
DLG_H := $(DLG_DIR)/dlg/dlg.h \
|
||||
$(DLG_DIR)/dlg/output.h
|
||||
|
||||
|
||||
# dlg logging library object(s)
|
||||
#
|
||||
# DLG_OBJ_M is used during `multi' builds
|
||||
# DLG_OBJ_S is used during `single' builds
|
||||
#
|
||||
DLG_OBJ_M := $(DLG_SRC:$(DLG_DIR)/%.c=$(OBJ_DIR)/%.$O)
|
||||
DLG_OBJ_S := $(OBJ_DIR)/dlg.$O
|
||||
|
||||
# dlg logging library source file for single build
|
||||
#
|
||||
DLG_SRC_S := $(DLG_DIR)/dlgwrap.c
|
||||
|
||||
|
||||
# dlg logging library - single object
|
||||
#
|
||||
$(DLG_OBJ_S): $(DLG_SRC_S) $(DLG_SRC) $(FREETYPE_H) $(DLG_H)
|
||||
$(DLG_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(DLG_SRC_S))
|
||||
|
||||
|
||||
# dlg logging library - multiple objects
|
||||
#
|
||||
$(OBJ_DIR)/%.$O: $(DLG_DIR)/%.c $(FREETYPE_H) $(DLG_H)
|
||||
$(DLG_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
|
||||
|
||||
|
||||
# update main object lists
|
||||
#
|
||||
DLG_OBJS_S += $(DLG_OBJ_S)
|
||||
DLG_OBJS_M += $(DLG_OBJ_M)
|
||||
|
||||
|
||||
# EOF
|
@ -2153,7 +2153,7 @@
|
||||
decoder->locals_bias );
|
||||
|
||||
|
||||
FT_TRACE4(( " callsubr (idx %d, entering level %d)\n",
|
||||
FT_TRACE4(( " callsubr (idx %d, entering level %ld)\n",
|
||||
idx,
|
||||
zone - decoder->zones + 1 ));
|
||||
|
||||
@ -2197,7 +2197,7 @@
|
||||
decoder->globals_bias );
|
||||
|
||||
|
||||
FT_TRACE4(( " callgsubr (idx %d, entering level %d)\n",
|
||||
FT_TRACE4(( " callgsubr (idx %d, entering level %ld)\n",
|
||||
idx,
|
||||
zone - decoder->zones + 1 ));
|
||||
|
||||
@ -2236,7 +2236,7 @@
|
||||
break;
|
||||
|
||||
case cff_op_return:
|
||||
FT_TRACE4(( " return (leaving level %d)\n",
|
||||
FT_TRACE4(( " return (leaving level %ld)\n",
|
||||
decoder->zone - decoder->zones ));
|
||||
|
||||
if ( decoder->zone <= decoder->zones )
|
||||
|
@ -517,7 +517,7 @@
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
if ( bol )
|
||||
{
|
||||
FT_TRACE5(( " (%d)", decoder->top - decoder->stack ));
|
||||
FT_TRACE5(( " (%ld)", decoder->top - decoder->stack ));
|
||||
bol = FALSE;
|
||||
}
|
||||
#endif
|
||||
@ -1162,7 +1162,7 @@
|
||||
if ( top - decoder->stack != num_args )
|
||||
FT_TRACE0(( "t1_decoder_parse_charstrings:"
|
||||
" too much operands on the stack"
|
||||
" (seen %d, expected %d)\n",
|
||||
" (seen %ld, expected %d)\n",
|
||||
top - decoder->stack, num_args ));
|
||||
break;
|
||||
}
|
||||
@ -1209,7 +1209,7 @@
|
||||
FT_TRACE4(( "BuildCharArray = [ " ));
|
||||
|
||||
for ( i = 0; i < decoder->len_buildchar; i++ )
|
||||
FT_TRACE4(( "%d ", decoder->buildchar[i] ));
|
||||
FT_TRACE4(( "%ld ", decoder->buildchar[i] ));
|
||||
|
||||
FT_TRACE4(( "]\n" ));
|
||||
}
|
||||
|
@ -416,9 +416,9 @@
|
||||
FT_FRAME_ENTER( sfnt.num_tables * 16L ) )
|
||||
goto Exit;
|
||||
|
||||
FT_TRACE2(( "\n"
|
||||
" tag offset length checksum\n"
|
||||
" ----------------------------------\n" ));
|
||||
FT_TRACE2(( " tag offset length checksum\n"));
|
||||
FT_TRACE2(( " ----------------------------------\n" ));
|
||||
|
||||
|
||||
valid_entries = 0;
|
||||
for ( nn = 0; nn < sfnt.num_tables; nn++ )
|
||||
|
@ -3781,7 +3781,7 @@
|
||||
|
||||
if ( opcode_pointer[i] == opcode_size[i] )
|
||||
{
|
||||
FT_TRACE6(( "sph: Function %d, opcode ptrn: %d, %s %s\n",
|
||||
FT_TRACE6(( "sph: Function %d, opcode ptrn: %ld, %s %s\n",
|
||||
i, n,
|
||||
exc->face->root.family_name,
|
||||
exc->face->root.style_name ));
|
||||
|
1
submodules/dlg
Submodule
1
submodules/dlg
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit a4897614699fb8e76f23a2d50a63b4d674e39f90
|
Loading…
Reference in New Issue
Block a user