[OTS] Integrate WOFF 2.0 algorithm into OTS
Add woff2.h and woff2.cc from the WOFF 2.0 reference implementation
(https://code.google.com/p/font-compression-reference/).
WOFF2 support is disabled by default and is enabled by ots::EnableWOFF2().
Patch originally by bashi@chromium.org.
BUG=122603
R=yusukes@chromium.org
Review URL: https://codereview.chromium.org/13918002
git-svn-id: http://ots.googlecode.com/svn/trunk@100 a4e77c2c-9104-11de-800e-5b313e0d2bf3
diff --git a/src/ots.h b/src/ots.h
index c1741e2..a7b6d61 100644
--- a/src/ots.h
+++ b/src/ots.h
@@ -11,9 +11,15 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <limits>
#include "opentype-sanitiser.h"
+// arraysize borrowed from base/basictypes.h
+template <typename T, size_t N>
+char (&ArraySizeHelper(T (&array)[N]))[N];
+#define arraysize(array) (sizeof(ArraySizeHelper(array)))
+
namespace ots {
#if defined(_MSC_VER) || !defined(OTS_DEBUG)
@@ -158,6 +164,17 @@
size_t offset_;
};
+// Round a value up to the nearest multiple of 4. Don't round the value in the
+// case that rounding up overflows.
+template<typename T> T Round4(T value) {
+ if (std::numeric_limits<T>::max() - value < 3) {
+ return value;
+ }
+ return (value + 3) & ~3;
+}
+
+bool IsValidVersionTag(uint32_t tag);
+
#define FOR_EACH_TABLE_TYPE \
F(cff, CFF) \
F(cmap, CMAP) \