Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
[submodule "vendor/sfnt2woff/source"]
path = vendor/sfnt2woff/source
url = https://github.com/kseo/sfnt2woff.git
[submodule "vendor/woff2/source"]
path = vendor/woff2/source
url = https://github.com/google/woff2.git
16 changes: 16 additions & 0 deletions vendor/woff2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# woff2 Vendored

Original Repo: https://github.com/google/woff2
Current Commit: `0f4d304faa1c62994536dc73510305c7357da8d4`

## To update and re-apply patch
```bash
cd vendor/woff2/
rm -rf source/
git clone https://github.com/google/woff2.git source
cd source
git checkout <NEW_COMMIT_HASH>
rm -rf .git
cd ..
patch -p1 < local-patches.patch
```
11 changes: 11 additions & 0 deletions vendor/woff2/local-patches.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/source/include/woff2/output.h
+++ b/source/include/woff2/output.h
@@ -11,6 +11,7 @@

#include <algorithm>
#include <cstring>
#include <memory>
+#include <stdint.h>
#include <string>

namespace woff2 {
1 change: 0 additions & 1 deletion vendor/woff2/source
Submodule source deleted from 0f4d30
5 changes: 5 additions & 0 deletions vendor/woff2/source/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.o
*.a
/woff2_compress
/woff2_decompress
/woff2_info
285 changes: 285 additions & 0 deletions vendor/woff2/source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
# Copyright 2017 Igalia S.L. All Rights Reserved.
#
# Distributed under MIT license.
# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT

# Ubuntu 12.04 LTS has CMake 2.8.7, and is an important target since
# several CI services, such as Travis and Drone, use it. Solaris 11
# has 2.8.6, and it's not difficult to support if you already have to
# support 2.8.7.
cmake_minimum_required(VERSION 2.8.6)

project(woff2)

include(GNUInstallDirs)

# Build options
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(CANONICAL_PREFIXES "Canonical prefixes" OFF)
option(NOISY_LOGGING "Noisy logging" ON)

# Version information
set(WOFF2_VERSION 1.0.2)

# When building shared libraries it is important to set the correct rpath
# See https://cmake.org/Wiki/CMake_RPATH_handling#Always_full_RPATH
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_LIBDIR}" isSystemDir)
if ("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
endif()

# Find Brotli dependencies
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(BrotliDec)
if (NOT BROTLIDEC_FOUND)
message(FATAL_ERROR "librotlidec is needed to build woff2.")
endif ()
find_package(BrotliEnc)
if (NOT BROTLIENC_FOUND)
message(FATAL_ERROR "librotlienc is needed to build woff2.")
endif ()

# Set compiler flags
if (NOT CANONICAL_PREFIXES)
add_definitions(-no-canonical-prefixes)
endif ()
if (NOISY_LOGGING)
add_definitions(-DFONT_COMPRESSION_BIN)
endif ()
add_definitions(-D__STDC_FORMAT_MACROS)
set(COMMON_FLAGS -fno-omit-frame-pointer)

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_definitions(-DOS_MACOSX)
else ()
set(COMMON_FLAGS "${COMMON_FLAG} -fno-omit-frame-pointer")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAG}")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAG}")
set(CMAKE_CXX_STANDARD 11)

# Set search path for our private/public headers as well as Brotli headers
include_directories("src" "include"
"${BROTLIDEC_INCLUDE_DIRS}" "${BROTLIENC_INCLUDE_DIRS}")

# Common part used by decoder and encoder
add_library(woff2common
src/table_tags.cc
src/variable_length.cc
src/woff2_common.cc)

# WOFF2 Decoder
add_library(woff2dec
src/woff2_dec.cc
src/woff2_out.cc)
target_link_libraries(woff2dec woff2common "${BROTLIDEC_LIBRARIES}")
add_executable(woff2_decompress src/woff2_decompress.cc)
target_link_libraries(woff2_decompress woff2dec)

# WOFF2 Encoder
add_library(woff2enc
src/font.cc
src/glyph.cc
src/normalize.cc
src/transform.cc
src/woff2_enc.cc)
target_link_libraries(woff2enc woff2common "${BROTLIENC_LIBRARIES}")
add_executable(woff2_compress src/woff2_compress.cc)
target_link_libraries(woff2_compress woff2enc)

# WOFF2 info
add_executable(woff2_info src/woff2_info.cc)
target_link_libraries(woff2_info woff2common)

foreach(lib woff2common woff2dec woff2enc)
set_target_properties(${lib} PROPERTIES
SOVERSION ${WOFF2_VERSION}
VERSION ${WOFF2_VERSION}
POSITION_INDEPENDENT_CODE TRUE)
endforeach()

# Fuzzer libraries
add_library(convert_woff2ttf_fuzzer STATIC src/convert_woff2ttf_fuzzer.cc)
target_link_libraries(convert_woff2ttf_fuzzer woff2dec)
add_library(convert_woff2ttf_fuzzer_new_entry STATIC src/convert_woff2ttf_fuzzer_new_entry.cc)
target_link_libraries(convert_woff2ttf_fuzzer_new_entry woff2dec)

# PC files
include(CMakeParseArguments)

function(generate_pkg_config_path outvar path)
string(LENGTH "${path}" path_length)

set(path_args ${ARGV})
list(REMOVE_AT path_args 0 1)
list(LENGTH path_args path_args_remaining)

set("${outvar}" "${path}")

while(path_args_remaining GREATER 1)
list(GET path_args 0 name)
list(GET path_args 1 value)

get_filename_component(value_full "${value}" ABSOLUTE)
string(LENGTH "${value}" value_length)

if(path_length EQUAL value_length AND path STREQUAL value)
set("${outvar}" "\${${name}}")
break()
elseif(path_length GREATER value_length)
# We might be in a subdirectory of the value, but we have to be
# careful about a prefix matching but not being a subdirectory
# (for example, /usr/lib64 is not a subdirectory of /usr/lib).
# We'll do this by making sure the next character is a directory
# separator.
string(SUBSTRING "${path}" ${value_length} 1 sep)
if(sep STREQUAL "/")
string(SUBSTRING "${path}" 0 ${value_length} s)
if(s STREQUAL value)
string(SUBSTRING "${path}" "${value_length}" -1 suffix)
set("${outvar}" "\${${name}}${suffix}")
break()
endif()
endif()
endif()

list(REMOVE_AT path_args 0 1)
list(LENGTH path_args path_args_remaining)
endwhile()

set("${outvar}" "${${outvar}}" PARENT_SCOPE)
endfunction(generate_pkg_config_path)

function(generate_pkg_config output_file)
set (options)
set (oneValueArgs NAME DESCRIPTION URL VERSION PREFIX LIBDIR INCLUDEDIR)
set (multiValueArgs DEPENDS DEPENDS_PRIVATE CFLAGS LIBRARIES)
cmake_parse_arguments(GEN_PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
unset (options)
unset (oneValueArgs)
unset (multiValueArgs)

if(NOT GEN_PKG_PREFIX)
set(GEN_PKG_PREFIX "${CMAKE_INSTALL_PREFIX}")
endif()

if(NOT GEN_PKG_LIBDIR)
set(GEN_PKG_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()
generate_pkg_config_path(GEN_PKG_LIBDIR "${GEN_PKG_LIBDIR}"
prefix "${GEN_PKG_PREFIX}")

if(NOT GEN_PKG_INCLUDEDIR)
set(GEN_PKG_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
endif()
generate_pkg_config_path(GEN_PKG_INCLUDEDIR "${GEN_PKG_INCLUDEDIR}"
prefix "${GEN_PKG_PREFIX}")

file(WRITE "${output_file}" "prefix=${GEN_PKG_PREFIX}\n")
file(APPEND "${output_file}" "libdir=${GEN_PKG_LIBDIR}\n")
file(APPEND "${output_file}" "includedir=${GEN_PKG_INCLUDEDIR}\n")
file(APPEND "${output_file}" "\n")

if(GEN_PKG_NAME)
file(APPEND "${output_file}" "Name: ${GEN_PKG_NAME}\n")
else()
file(APPEND "${output_file}" "Name: ${CMAKE_PROJECT_NAME}\n")
endif()

if(GEN_PKG_DESCRIPTION)
file(APPEND "${output_file}" "Description: ${GEN_PKG_DESCRIPTION}\n")
endif()

if(GEN_PKG_URL)
file(APPEND "${output_file}" "URL: ${GEN_PKG_URL}\n")
endif()

if(GEN_PKG_VERSION)
file(APPEND "${output_file}" "Version: ${GEN_PKG_VERSION}\n")
endif()

if(GEN_PKG_DEPENDS)
file(APPEND "${output_file}" "Requires: ${GEN_PKG_DEPENDS}\n")
endif()

if(GEN_PKG_DEPENDS_PRIVATE)
file(APPEND "${output_file}" "Requires.private:")
foreach(lib ${GEN_PKG_DEPENDS_PRIVATE})
file(APPEND "${output_file}" " ${lib}")
endforeach()
file(APPEND "${output_file}" "\n")
endif()

if(GEN_PKG_LIBRARIES)
set(libs)

file(APPEND "${output_file}" "Libs: -L\${libdir}")
foreach(lib ${GEN_PKG_LIBRARIES})
file(APPEND "${output_file}" " -l${lib}")
endforeach()
file(APPEND "${output_file}" "\n")
endif()

file(APPEND "${output_file}" "Cflags: -I\${includedir}")
if(GEN_PKG_CFLAGS)
foreach(cflag ${GEN_PKG_CFLAGS})
file(APPEND "${output_file}" " ${cflag}")
endforeach()
endif()
file(APPEND "${output_file}" "\n")
endfunction(generate_pkg_config)

generate_pkg_config ("${CMAKE_CURRENT_BINARY_DIR}/libwoff2common.pc"
NAME libwoff2common
DESCRIPTION "Shared data used by libwoff2 and libwoff2dec libraries"
URL "https://github.com/google/woff2"
VERSION "${WOFF2_VERSION}"
LIBRARIES woff2common)

generate_pkg_config ("${CMAKE_CURRENT_BINARY_DIR}/libwoff2dec.pc"
NAME libwoff2dec
DESCRIPTION "WOFF2 decoder library"
URL "https://github.com/google/woff2"
VERSION "${WOFF2_VERSION}"
DEPENDS libbrotlidec
DEPENDS_PRIVATE libwoff2common
LIBRARIES woff2dec)

generate_pkg_config ("${CMAKE_CURRENT_BINARY_DIR}/libwoff2enc.pc"
NAME libwoff2enc
DESCRIPTION "WOFF2 encoder library"
URL "https://github.com/google/woff2"
VERSION "${WOFF2_VERSION}"
DEPENDS libbrotlienc
DEPENDS_PRIVATE libwoff2common
LIBRARIES woff2enc)

# Installation
if (NOT BUILD_SHARED_LIBS)
install(
TARGETS woff2_decompress woff2_compress woff2_info
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()

install(
TARGETS woff2common woff2dec woff2enc
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
install(
DIRECTORY include/woff2
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libwoff2common.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libwoff2dec.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libwoff2enc.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
27 changes: 27 additions & 0 deletions vendor/woff2/source/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Want to contribute? Great! First, read this page (including the small print at
the end).

### Before you contribute
Before we can use your code, you must sign the
[Google Individual Contributor License Agreement]
(https://cla.developers.google.com/about/google-individual)
(CLA), which you can do online. The CLA is necessary mainly because you own the
copyright to your changes, even after your contribution becomes part of our
codebase, so we need your permission to use and distribute your code. We also
need to be sure of various other things—for instance that you'll tell us if you
know that your code infringes on other people's patents. You don't have to sign
the CLA until after you've submitted your code for review and a member has
approved it, but you must do it before we can put your code into our codebase.
Before you start working on a larger contribution, you should get in touch with
us first through the issue tracker with your idea so that we can help out and
possibly guide you. Coordinating up front makes it much easier to avoid
frustration later on.

### Code reviews
All submissions, including submissions by project members, require review. We
use Github pull requests for this purpose.

### The small print
Contributions made by corporations are covered by a different agreement than
the one above, the [Software Grant and Corporate Contributor License Agreement]
(https://cla.developers.google.com/about/google-corporate).
19 changes: 19 additions & 0 deletions vendor/woff2/source/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2013-2017 by the WOFF2 Authors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading