1 diff --git a/src/ots.cc b/src/ots.cc
8 -#include <woff2/decode.h>
9 +#include "../RLBoxWOFF2Host.h"
11 // The OpenType Font File
12 // http://www.microsoft.com/typography/otspec/otff.htm
13 @@ -511,43 +511,9 @@ bool ProcessWOFF(ots::FontFile *header,
14 return ProcessGeneric(header, font, woff_tag, output, data, length, tables, file);
17 -bool ProcessWOFF2(ots::FontFile *header,
18 - ots::OTSStream *output,
19 - const uint8_t *data,
22 - size_t decompressed_size = woff2::ComputeWOFF2FinalSize(data, length);
24 - if (decompressed_size < length) {
25 - return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 is less than compressed size");
28 - if (decompressed_size == 0) {
29 - return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 is set to 0");
31 - // decompressed font must be <= OTS_MAX_DECOMPRESSED_FILE_SIZE
32 - if (decompressed_size > OTS_MAX_DECOMPRESSED_FILE_SIZE) {
33 - return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 font exceeds %gMB",
34 - OTS_MAX_DECOMPRESSED_FILE_SIZE / (1024.0 * 1024.0));
37 - if (decompressed_size > output->size()) {
38 - return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 font exceeds output size (%gMB)", output->size() / (1024.0 * 1024.0));
41 - std::string buf(decompressed_size, 0);
42 - woff2::WOFF2StringOut out(&buf);
43 - if (!woff2::ConvertWOFF2ToTTF(data, length, &out)) {
44 - return OTS_FAILURE_MSG_HDR("Failed to convert WOFF 2.0 font to SFNT");
46 - const uint8_t *decompressed = reinterpret_cast<const uint8_t*>(buf.data());
48 - if (data[4] == 't' && data[5] == 't' && data[6] == 'c' && data[7] == 'f') {
49 - return ProcessTTC(header, output, decompressed, out.Size(), index);
51 - ots::Font font(header);
52 - return ProcessTTF(header, &font, output, decompressed, out.Size());
54 +bool ProcessWOFF2(ots::FontFile* header, ots::OTSStream* output,
55 + const uint8_t* data, size_t length, uint32_t index) {
56 + return RLBoxProcessWOFF2(header, output, data, length, index, ProcessTTC, ProcessTTF);
59 ots::TableAction GetTableAction(const ots::FontFile *header, uint32_t tag) {