shithub: freetype+ttf2subf

Download patch

ref: 3de1b8d0b0983cf49a187a4227e7950395a3b08f
parent: bbb14361dbb87e6ef30d0f35b22770c965d166b4
author: Werner Lemberg <wl@gnu.org>
date: Thu Sep 5 10:10:01 EDT 2019

[cmake] Add brotli support.

* CMakeLists.txt (FT_WITH_BROTLI): New option.

* builds/cmake/FindBrotliDec.cmake: New file.

git/fs: mount .git/fs: mount/attach disallowed
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,13 +68,15 @@
 # . `CMakeLists.txt' is provided as-is since it is normally not used by the
 #   developer team.
 #
-# . Set the `FT_WITH_ZLIB', `FT_WITH_BZIP2', `FT_WITH_PNG', and
-#   `FT_WITH_HARFBUZZ' CMake variables to `ON' to force using a dependency.
-#   Leave a variable undefined (which is the default) to use the dependency
-#   only if it is available.  Set `CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE' to
-#   disable a dependency completely (CMake package name, so `BZip2' instead of
-#   `BZIP2'). Example:
+# . Set the `FT_WITH_ZLIB', `FT_WITH_BZIP2', `FT_WITH_PNG',
+#   `FT_WITH_HARFBUZZ', and `FT_WITH_BROTLI' CMake variables to `ON' to
+#   force using a dependency.  Leave a variable undefined (which is the
+#   default) to use the dependency only if it is available.  Set
+#   `CMAKE_DISABLE_FIND_PACKAGE_XXX=TRUE' to disable a dependency completely
+#   (where `XXX' is a CMake package name like `BZip2').
 #
+#   Example:
+#
 #     cmake -DFT_WITH_ZLIB=ON -DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE [...]
 #
 # . Installation of FreeType can be controlled with the CMake variables
@@ -156,14 +158,15 @@
 math(EXPR LIBRARY_SOVERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}")
 set(LIBRARY_VERSION "${LIBRARY_SOVERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION}")
 
-# These options mean "require x and complain if not found". They'll get
-# optionally found anyway. Use `-DCMAKE_DISABLE_FIND_PACKAGE_x=TRUE` to disable
-# searching for a packge entirely (x is the CMake package name, so "BZip2"
-# instead of "BZIP2").
+# These options mean `require x and complain if not found'.  They'll get
+# optionally found anyway.  Use `-DCMAKE_DISABLE_FIND_PACKAGE_x=TRUE` to
+# disable searching for a package entirely (`x' is the CMake package name,
+# so `BZip2' instead of `BZIP2').
 option(FT_WITH_ZLIB "Use system zlib instead of internal library." OFF)
 option(FT_WITH_BZIP2 "Support bzip2 compressed fonts." OFF)
 option(FT_WITH_PNG "Support PNG compressed OpenType embedded bitmaps." OFF)
 option(FT_WITH_HARFBUZZ "Improve auto-hinting of OpenType fonts." OFF)
+option(FT_WITH_BROTLI "Support compressed WOFF2 fonts." OFF)
 
 
 # Disallow in-source builds
@@ -219,6 +222,12 @@
   find_package(BZip2)
 endif ()
 
+if (FT_WITH_BROTLI)
+  find_package(BrotliDec REQUIRED)
+else ()
+  find_package(BrotliDec)
+endif ()
+
 # Create the configuration file
 if (UNIX)
   check_include_file("unistd.h" HAVE_UNISTD_H)
@@ -283,6 +292,11 @@
     "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
     FTOPTION_H "${FTOPTION_H}")
 endif ()
+if (BROTLIDEC_FOUND)
+  string(REGEX REPLACE
+    "/\\* +(#define +FT_CONFIG_OPTION_USE_BROTLI) +\\*/" "\\1"
+    FTOPTION_H "${FTOPTION_H}")
+endif ()
 
 set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h")
 if (EXISTS "${FTOPTION_H_NAME}")
@@ -438,6 +452,12 @@
   target_link_libraries(freetype PRIVATE ${HARFBUZZ_LIBRARIES})
   target_include_directories(freetype PRIVATE ${HARFBUZZ_INCLUDE_DIRS})
   list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}")
+endif ()
+if (BROTLIDEC_FOUND)
+  target_link_libraries(freetype PRIVATE ${BROTLIDEC_LIBRARIES})
+  target_compile_definitions(freetype PRIVATE ${BROTLIDEC_DEFINITIONS})
+  target_include_directories(freetype PRIVATE ${BROTLIDEC_INCLUDE_DIRS})
+  list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "libbrotlidec")
 endif ()
 
 
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2019-09-05  Werner Lemberg  <wl@gnu.org>
 
+	[cmake] Add brotli support.
+
+	* CMakeLists.txt (FT_WITH_BROTLI): New option.
+
+	* builds/cmake/FindBrotliDec.cmake: New file.
+
+2019-09-05  Werner Lemberg  <wl@gnu.org>
+
 	Fix handling of `AF_CONFIG_OPTION_INDIC'.
 
 	* devel/ftoption.h, include/freetype/config/ftoption.h:
--- /dev/null
+++ b/builds/cmake/FindBrotliDec.cmake
@@ -1,0 +1,51 @@
+# FindBrotliDec.cmake
+#
+# Copyright (C) 2019 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# Written by Werner Lemberg <wl@gnu.org>
+#
+# 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.
+#
+#
+# Try to find libbrotlidec include and library directories.
+#
+# If found, the following variables are set.
+#
+#   BROTLIDEC_INCLUDE_DIRS
+#   BROTLIDEC_LIBRARIES
+
+include(FindPkgConfig)
+pkg_check_modules(PC_BROTLIDEC QUIET libbrotlidec)
+
+if (PC_BROTLIDEC_VERSION)
+  set(BROTLIDEC_VERSION "${PC_BROTLIDEC_VERSION}")
+endif ()
+
+
+find_path(BROTLIDEC_INCLUDE_DIRS
+  NAMES brotli/decode.h
+  HINTS ${PC_BROTLIDEC_INCLUDEDIR}
+        ${PC_BROTLIDEC_INCLUDE_DIRS}
+  PATH_SUFFIXES brotli)
+
+find_library(BROTLIDEC_LIBRARIES
+  NAMES brotlidec
+  HINTS ${PC_BROTLIDEC_LIBDIR}
+        ${PC_BROTLIDEC_LIBRARY_DIRS})
+
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+  brotlidec
+  REQUIRED_VARS BROTLIDEC_INCLUDE_DIRS BROTLIDEC_LIBRARIES
+  FOUND_VAR BROTLIDEC_FOUND
+  VERSION_VAR BROTLIDEC_VERSION)
+
+mark_as_advanced(
+  BROTLIDEC_INCLUDE_DIRS
+  BROTLIDEC_LIBRARIES)