Skip to content

Commit

Permalink
Update ots to v9.1.0 and vendor dependencies
Browse files Browse the repository at this point in the history
Update `ots` to the latest release and vendor ots and all dependencies.
Cargo build will recursively clone submodules for `git` dependencies.
`ots` itself and some of its dependencies have quite large git repos,
e.g. `ots` has 80MB of test font files. Vendoring the sources reduces
the required network bandwidth and disk space usage greatly.
See also rust-lang/cargo#7987 for more details
on the effects on disk usage (not super relevant for us, since we rarely
update our dependencies).

Ideally each of the C dependencies would have their own crate, but that
can be done later.
  • Loading branch information
jschwe committed Feb 4, 2024
1 parent 0e9bc74 commit 7e6ad7f
Show file tree
Hide file tree
Showing 214 changed files with 61,618 additions and 157 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 0.5.0

- Fix a build issue on windows
- Update ots to v1.9.0
- Vendor ots and dependencies (brotli, lz4 and woff2)
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fontsan"
version = "0.4.0"
version = "0.5.0"
authors = ["The Servo Project Developers"]
description = "Sanitiser for untrusted font files"
build = "build.rs"
Expand Down
176 changes: 21 additions & 155 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,184 +1,50 @@
cmake_minimum_required(VERSION 3.13)
project(ots)

set(OTS_SOURCES
ots/src/cff.cc
ots/src/cff.h
ots/src/cff_type2_charstring.cc
ots/src/cff_type2_charstring.h
ots/src/cmap.cc
ots/src/cmap.h
ots/src/cvt.cc
ots/src/cvt.h
ots/src/feat.cc
ots/src/feat.h
ots/src/fpgm.cc
ots/src/fpgm.h
ots/src/gasp.cc
ots/src/gasp.h
ots/src/gdef.cc
ots/src/gdef.h
ots/src/glat.cc
ots/src/glat.h
ots/src/gloc.cc
ots/src/gloc.h
ots/src/glyf.cc
ots/src/glyf.h
ots/src/gpos.cc
ots/src/gpos.h
ots/src/graphite.h
ots/src/gsub.cc
ots/src/gsub.h
ots/src/hdmx.cc
ots/src/hdmx.h
ots/src/head.cc
ots/src/head.h
ots/src/hhea.cc
ots/src/hhea.h
ots/src/hmtx.cc
ots/src/hmtx.h
ots/src/kern.cc
ots/src/kern.h
ots/src/layout.cc
ots/src/layout.h
ots/src/loca.cc
ots/src/loca.h
ots/src/ltsh.cc
ots/src/ltsh.h
ots/src/math.cc
ots/src/math_.h
ots/src/maxp.cc
ots/src/maxp.h
ots/src/metrics.cc
ots/src/metrics.h
ots/src/name.cc
ots/src/name.h
ots/src/os2.cc
ots/src/os2.h
ots/src/ots.cc
ots/src/ots.h
ots/src/post.cc
ots/src/post.h
ots/src/prep.cc
ots/src/prep.h
ots/src/sile.cc
ots/src/sile.h
ots/src/silf.cc
ots/src/silf.h
ots/src/sill.cc
ots/src/sill.h
ots/src/vdmx.cc
ots/src/vdmx.h
ots/src/vhea.cc
ots/src/vhea.h
ots/src/vmtx.cc
ots/src/vmtx.h
ots/src/vorg.cc
ots/src/vorg.h
)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(BROTLI_SOURCES
ots/third_party/brotli/c/common/dictionary.c
ots/third_party/brotli/c/common/dictionary.h
ots/third_party/brotli/c/dec/bit_reader.c
ots/third_party/brotli/c/dec/bit_reader.h
ots/third_party/brotli/c/dec/context.h
ots/third_party/brotli/c/dec/decode.c
ots/third_party/brotli/c/dec/huffman.c
ots/third_party/brotli/c/dec/huffman.h
ots/third_party/brotli/c/dec/port.h
ots/third_party/brotli/c/dec/prefix.h
ots/third_party/brotli/c/dec/state.c
ots/third_party/brotli/c/dec/state.h
ots/third_party/brotli/c/dec/transform.h
ots/third_party/brotli/c/include/brotli/decode.h
ots/third_party/brotli/c/include/brotli/port.h
ots/third_party/brotli/c/include/brotli/types.h
ots/third_party/brotli/c/enc/backward_references.c
ots/third_party/brotli/c/enc/backward_references_hq.c
ots/third_party/brotli/c/enc/bit_cost.c
ots/third_party/brotli/c/enc/block_splitter.c
ots/third_party/brotli/c/enc/brotli_bit_stream.c
ots/third_party/brotli/c/enc/cluster.c
ots/third_party/brotli/c/enc/compress_fragment.c
ots/third_party/brotli/c/enc/compress_fragment_two_pass.c
ots/third_party/brotli/c/enc/dictionary_hash.c
ots/third_party/brotli/c/enc/encode.c
ots/third_party/brotli/c/enc/entropy_encode.c
ots/third_party/brotli/c/enc/histogram.c
ots/third_party/brotli/c/enc/literal_cost.c
ots/third_party/brotli/c/enc/memory.c
ots/third_party/brotli/c/enc/metablock.c
ots/third_party/brotli/c/enc/static_dict.c
ots/third_party/brotli/c/enc/utf8_util.c
)
file(GLOB OTS_SOURCES CONFIGURE_DEPENDS "ots/src/*.cc")

file(GLOB_RECURSE BROTLI_SOURCES CONFIGURE_DEPENDS "deps/brotli/c/*.c")

set(WOFF2_SOURCES
ots/third_party/woff2/include/woff2/decode.h
ots/third_party/woff2/include/woff2/encode.h
ots/third_party/woff2/include/woff2/output.h
ots/third_party/woff2/src/buffer.h
ots/third_party/woff2/src/file.h
ots/third_party/woff2/src/font.cc
ots/third_party/woff2/src/font.h
ots/third_party/woff2/src/glyph.cc
ots/third_party/woff2/src/glyph.h
ots/third_party/woff2/src/normalize.cc
ots/third_party/woff2/src/normalize.h
ots/third_party/woff2/src/port.h
ots/third_party/woff2/src/round.h
ots/third_party/woff2/src/store_bytes.h
ots/third_party/woff2/src/table_tags.cc
ots/third_party/woff2/src/table_tags.h
ots/third_party/woff2/src/transform.cc
ots/third_party/woff2/src/transform.h
ots/third_party/woff2/src/variable_length.cc
ots/third_party/woff2/src/variable_length.h
ots/third_party/woff2/src/woff2_common.cc
ots/third_party/woff2/src/woff2_common.h
ots/third_party/woff2/src/woff2_dec.cc
ots/third_party/woff2/src/woff2_enc.cc
ots/third_party/woff2/src/woff2_out.cc
deps/woff2/src/table_tags.cc
deps/woff2/src/variable_length.cc
deps/woff2/src/woff2_common.cc
deps/woff2/src/woff2_dec.cc
deps/woff2/src/woff2_out.cc
)

set(OTS_GLUE_SOURCES
ots_glue.cc
)

set(LZ4_SOURCES
ots/third_party/lz4/lib/lz4.c
ots/third_party/lz4/lib/lz4.h
deps/lz4/lib/lz4.c
deps/lz4/lib/lz4.h
)

include_directories(
fake-zlib
ots/include
ots/third_party/lz4/lib
ots/third_party/brotli/c/dec
ots/third_party/brotli/c/include
ots/third_party/woff2/include
ots/third_party/woff2/src
ots/src
deps/lz4/lib
deps/brotli/c/dec
deps/brotli/c/include
deps/woff2/include
deps/woff2/src
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fPIC")

add_library(ots STATIC ${OTS_SOURCES})
add_library(ots STATIC ${OTS_SOURCES} ${LZ4_SOURCES})
add_library(brotli STATIC ${BROTLI_SOURCES})
add_library(woff2 STATIC ${WOFF2_SOURCES})
add_library(ots_glue STATIC ${OTS_GLUE_SOURCES})

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_sources(ots PRIVATE "${LZ4_SOURCES}")
target_include_directories(ots PRIVATE ots/third_party/lz4/lib/)
endif()
set_property(TARGET woff2 PROPERTY CXX_STANDARD 11)
set_property(TARGET ots PROPERTY CXX_STANDARD 11)
set_property(TARGET ots_glue PROPERTY CXX_STANDARD 11)

SET_TARGET_PROPERTIES(woff2 PROPERTIES
COMPILE_FLAGS "-std=c++11"
)

SET_TARGET_PROPERTIES(ots PROPERTIES
COMPILE_FLAGS "-std=c++11"
)

install(TARGETS ots ARCHIVE DESTINATION lib)
install(TARGETS brotli ARCHIVE DESTINATION lib)
Expand Down
19 changes: 19 additions & 0 deletions src/deps/brotli/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2009, 2010, 2013-2016 by the Brotli 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.
15 changes: 15 additions & 0 deletions src/deps/brotli/c/common/constants.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Copyright 2013 Google Inc. All Rights Reserved.
Distributed under MIT license.
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

#include "./constants.h"

const BrotliPrefixCodeRange
_kBrotliPrefixCodeRanges[BROTLI_NUM_BLOCK_LEN_SYMBOLS] = {
{1, 2}, {5, 2}, {9, 2}, {13, 2}, {17, 3}, {25, 3},
{33, 3}, {41, 3}, {49, 4}, {65, 4}, {81, 4}, {97, 4},
{113, 5}, {145, 5}, {177, 5}, {209, 5}, {241, 6}, {305, 6},
{369, 7}, {497, 8}, {753, 9}, {1265, 10}, {2289, 11}, {4337, 12},
{8433, 13}, {16625, 24}};
Loading

0 comments on commit 7e6ad7f

Please sign in to comment.