freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] GSoC-2019-nikhil 8e05ab3: Add Brotli dependency and required


From: Nikhil Ramakrishnan
Subject: [freetype2] GSoC-2019-nikhil 8e05ab3: Add Brotli dependency and required checks.
Date: Thu, 27 Jun 2019 15:34:47 -0400 (EDT)

branch: GSoC-2019-nikhil
commit 8e05ab3e2ebf9d90b6015cb2aa7e789517b293e6
Author: Nikhil Ramakrishnan <address@hidden>
Commit: Nikhil Ramakrishnan <address@hidden>

    Add Brotli dependency and required checks.
    
    Brotli is required for decompressing WOFF2 font directory streams.
    The library is thus being added as an optional dependency for FreeType.
    
    * builds/unix/configure.raw: Add checks for `libbrotlidec'.
    
    * devel/ftoption.h, include/freetype/config/ftoption.h
    (FT_CONFIG_OPTION_USE_BROTLI): New macro.
---
 builds/unix/configure.raw          | 57 +++++++++++++++++++++++++++++++++++++-
 devel/ftoption.h                   | 16 +++++++++++
 include/freetype/config/ftoption.h | 16 +++++++++++
 3 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/builds/unix/configure.raw b/builds/unix/configure.raw
index acefa11..292e660 100644
--- a/builds/unix/configure.raw
+++ b/builds/unix/configure.raw
@@ -543,6 +543,50 @@ if test x"$with_harfbuzz" = xyes -a "$have_harfbuzz" = no; 
then
 fi
 
 
+# check for system libbrotlidec
+
+AC_ARG_WITH([libbrotlidec],
+  [AS_HELP_STRING([--with-brotli=@<:@yes|no|auto@:>@],
+                  [Support decompression of WOFF2 streams 
@<:@default=auto@:>@])],
+  [], [with_brotli=auto])
+
+have_brotli=no
+if test x"$with_brotli" = xyes -o x"$with_brotli" = xauto; then
+  brotli_pkg="libbrotlidec"
+  have_brotli_pkg=no
+
+  if test x"$BROTLI_CFLAGS" = x -a x"$BROTLI_LIBS" = x; then
+    PKG_CHECK_EXISTS([$brotli_pkg], [have_brotli_pkg=yes])
+  fi
+  PKG_CHECK_MODULES([BROTLI], [$brotli_pkg],
+                    [have_brotli="yes (pkg-config)"], [:])
+
+  if test $have_brotli_pkg = yes; then
+    # we have libbrotlidec.pc
+    brotli_reqpriv="$brotli_pkg"
+    brotli_libspriv=
+    brotli_libsstaticconf=`$PKG_CONFIG --static --libs "$brotli_pkg"`
+  else
+    brotli_reqpriv=
+
+    if test "$have_brotli" != no; then
+      # BROTLI_CFLAGS and BROTLI_LIBS are set by the user
+      brotli_libspriv="$BROTLI_LIBS"
+      brotli_libsstaticconf="$BROTLI_LIBS"
+      have_brotli="yes (BROTLI_CFLAGS and BROTLI_LIBS)"
+    else
+      # since Brotli is quite a new library we don't fall back to a
+      # different test;
+      :
+    fi
+  fi
+fi
+
+if test x"$with_brotli" = xyes -a "$have_brotli" = no; then
+  AC_MSG_ERROR([brotli support requested but library not found])
+fi
+
+
 # check for librt
 #
 # We need `clock_gettime' for the `ftbench' demo program.
@@ -992,7 +1036,8 @@ fi
 REQUIRES_PRIVATE="$zlib_reqpriv,     \
                   $bzip2_reqpriv,    \
                   $libpng_reqpriv,   \
-                  $harfbuzz_reqpriv"
+                  $harfbuzz_reqpriv, \
+                  $brotli_reqpriv"
 # beautify
 REQUIRES_PRIVATE=`echo "$REQUIRES_PRIVATE" \
                   | sed -e 's/^  *//'      \
@@ -1007,6 +1052,7 @@ LIBS_PRIVATE="$zlib_libspriv     \
               $bzip2_libspriv    \
               $libpng_libspriv   \
               $harfbuzz_libspriv \
+              $brotli_libspriv   \
               $ft2_extra_libs"
 # beautify
 LIBS_PRIVATE=`echo "$LIBS_PRIVATE"  \
@@ -1019,6 +1065,7 @@ LIBSSTATIC_CONFIG="-lfreetype               \
                    $bzip2_libsstaticconf    \
                    $libpng_libsstaticconf   \
                    $harfbuzz_libsstaticconf \
+                   $brotli_libsstaticconf   \
                    $ft2_extra_libs"
 # remove -L/usr/lib and -L/usr/lib64 since `freetype-config' adds them later
 # on if necessary; also beautify
@@ -1083,6 +1130,13 @@ if test "$have_harfbuzz" != no; then
 else
   ftoption_unset FT_CONFIG_OPTION_USE_HARFBUZZ
 fi
+if test "$have_brotli" != no; then
+  CFLAGS="$CFLAGS $BROTLI_CFLAGS"
+  LDFLAGS="$LDFLAGS $BROTLI_LIBS"
+  ftoption_set FT_CONFIG_OPTION_USE_BROTLI
+else
+  ftoption_unset FT_CONFIG_OPTION_USE_BROTLI
+fi
 
 AC_SUBST([CFLAGS])
 AC_SUBST([LDFLAGS])
@@ -1129,6 +1183,7 @@ Library configuration:
   bzip2:         $have_bzip2
   libpng:        $have_libpng
   harfbuzz:      $have_harfbuzz
+  brotli:        $have_brotli
 ])
 
 # Warn if docwriter is not installed
diff --git a/devel/ftoption.h b/devel/ftoption.h
index 16cf4e1..ef8d5e5 100644
--- a/devel/ftoption.h
+++ b/devel/ftoption.h
@@ -294,6 +294,22 @@ FT_BEGIN_HEADER
 
   /**************************************************************************
    *
+   * Brotli support.
+   *
+   *   FreeType uses the Brotli library to provide support for decompressing
+   *   WOFF2 streams.
+   *
+   *   Define this macro if you want to enable this 'feature'.
+   *
+   *   If you use a build system like cmake or the `configure` script,
+   *   options set by those programs have precedence, overwriting the value
+   *   here with the configured one.
+   */
+#define FT_CONFIG_OPTION_USE_BROTLI
+
+
+  /**************************************************************************
+   *
    * Glyph Postscript Names handling
    *
    *   By default, FreeType 2 is compiled with the 'psnames' module.  This
diff --git a/include/freetype/config/ftoption.h 
b/include/freetype/config/ftoption.h
index 12f47a8..c3fd181 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -294,6 +294,22 @@ FT_BEGIN_HEADER
 
   /**************************************************************************
    *
+   * Brotli support.
+   *
+   *   FreeType uses the Brotli library to provide support for decompressing
+   *   WOFF2 streams.
+   *
+   *   Define this macro if you want to enable this 'feature'.
+   *
+   *   If you use a build system like cmake or the `configure` script,
+   *   options set by those programs have precedence, overwriting the value
+   *   here with the configured one.
+   */
+#define FT_CONFIG_OPTION_USE_BROTLI
+
+
+  /**************************************************************************
+   *
    * Glyph Postscript Names handling
    *
    *   By default, FreeType 2 is compiled with the 'psnames' module.  This



reply via email to

[Prev in Thread] Current Thread [Next in Thread]