Backed out changeset db90809844d2 (bug 1884769) for causing detekt linter failures...
[gecko.git] / gfx / ots / ots-rlbox.patch
blobaa5763c91c501239347046f0fb94417baf3274f6
1 diff --git a/src/ots.cc b/src/ots.cc
2 --- a/src/ots.cc
3 +++ b/src/ots.cc
4 @@ -14,7 +14,7 @@
5 #include <map>
6 #include <vector>
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,
20 - size_t length,
21 - uint32_t index) {
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");
26 - }
28 - if (decompressed_size == 0) {
29 - return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 is set to 0");
30 - }
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));
35 - }
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));
39 - }
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");
45 - }
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);
50 - } else {
51 - ots::Font font(header);
52 - return ProcessTTF(header, &font, output, decompressed, out.Size());
53 - }
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) {