зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1870240 - patch 3 - Re-apply local OTS patches. r=gfx-reviewers,lsalzman
Generated by running ./mach vendor --patch-mode only gfx/ots/moz.yaml Differential Revision: https://phabricator.services.mozilla.com/D209482
This commit is contained in:
Родитель
4f693882be
Коммит
0e4a7cd7f1
|
@ -5,6 +5,26 @@
|
|||
#ifndef OPENTYPE_SANITISER_H_
|
||||
#define OPENTYPE_SANITISER_H_
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define OTS_DLL_IMPORT __declspec(dllimport)
|
||||
#define OTS_DLL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#if __GNUC__ >= 4
|
||||
#define OTS_DLL_IMPORT __attribute__((visibility ("default")))
|
||||
#define OTS_DLL_EXPORT __attribute__((visibility ("default")))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef OTS_DLL
|
||||
#ifdef OTS_DLL_EXPORTS
|
||||
#define OTS_API OTS_DLL_EXPORT
|
||||
#else
|
||||
#define OTS_API OTS_DLL_IMPORT
|
||||
#endif
|
||||
#else
|
||||
#define OTS_API
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <stdlib.h>
|
||||
typedef signed char int8_t;
|
||||
|
@ -175,7 +195,7 @@ enum TableAction {
|
|||
TABLE_ACTION_DROP // Drop the table
|
||||
};
|
||||
|
||||
class OTSContext {
|
||||
class OTS_API OTSContext {
|
||||
public:
|
||||
OTSContext() {}
|
||||
virtual ~OTSContext() {}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "glat.h"
|
||||
|
||||
#include "gloc.h"
|
||||
#include "lz4.h"
|
||||
#include "mozilla/Compression.h"
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
|
@ -215,14 +215,15 @@ bool OpenTypeGLAT_v3::Parse(const uint8_t* data, size_t length,
|
|||
decompressed_size / (1024.0 * 1024.0));
|
||||
}
|
||||
std::unique_ptr<uint8_t> decompressed(new uint8_t[decompressed_size]());
|
||||
int ret = LZ4_decompress_safe_partial(
|
||||
size_t outputSize = 0;
|
||||
bool ret = mozilla::Compression::LZ4::decompressPartial(
|
||||
reinterpret_cast<const char*>(data + table.offset()),
|
||||
reinterpret_cast<char*>(decompressed.get()),
|
||||
table.remaining(), // input buffer size (input size + padding)
|
||||
reinterpret_cast<char*>(decompressed.get()),
|
||||
decompressed_size, // target output size
|
||||
decompressed_size); // output buffer size
|
||||
if (ret < 0 || unsigned(ret) != decompressed_size) {
|
||||
return DropGraphite("Decompression failed with error code %d", ret);
|
||||
&outputSize); // return output size
|
||||
if (!ret || outputSize != decompressed_size) {
|
||||
return DropGraphite("Decompression failed");
|
||||
}
|
||||
return this->Parse(decompressed.get(), decompressed_size, true);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <woff2/decode.h>
|
||||
#include "../RLBoxWOFF2Host.h"
|
||||
|
||||
// The OpenType Font File
|
||||
// http://www.microsoft.com/typography/otspec/otff.htm
|
||||
|
@ -518,43 +518,9 @@ bool ProcessWOFF(ots::FontFile *header,
|
|||
return ProcessGeneric(header, font, woff_tag, output, data, length, tables, file);
|
||||
}
|
||||
|
||||
bool ProcessWOFF2(ots::FontFile *header,
|
||||
ots::OTSStream *output,
|
||||
const uint8_t *data,
|
||||
size_t length,
|
||||
uint32_t index) {
|
||||
size_t decompressed_size = woff2::ComputeWOFF2FinalSize(data, length);
|
||||
|
||||
if (decompressed_size < length) {
|
||||
return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 is less than compressed size");
|
||||
}
|
||||
|
||||
if (decompressed_size == 0) {
|
||||
return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 is set to 0");
|
||||
}
|
||||
// decompressed font must be <= OTS_MAX_DECOMPRESSED_FILE_SIZE
|
||||
if (decompressed_size > OTS_MAX_DECOMPRESSED_FILE_SIZE) {
|
||||
return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 font exceeds %gMB",
|
||||
OTS_MAX_DECOMPRESSED_FILE_SIZE / (1024.0 * 1024.0));
|
||||
}
|
||||
|
||||
if (decompressed_size > output->size()) {
|
||||
return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 font exceeds output size (%gMB)", output->size() / (1024.0 * 1024.0));
|
||||
}
|
||||
|
||||
std::string buf(decompressed_size, 0);
|
||||
woff2::WOFF2StringOut out(&buf);
|
||||
if (!woff2::ConvertWOFF2ToTTF(data, length, &out)) {
|
||||
return OTS_FAILURE_MSG_HDR("Failed to convert WOFF 2.0 font to SFNT");
|
||||
}
|
||||
const uint8_t *decompressed = reinterpret_cast<const uint8_t*>(buf.data());
|
||||
|
||||
if (data[4] == 't' && data[5] == 't' && data[6] == 'c' && data[7] == 'f') {
|
||||
return ProcessTTC(header, output, decompressed, out.Size(), index);
|
||||
} else {
|
||||
ots::Font font(header);
|
||||
return ProcessTTF(header, &font, output, decompressed, out.Size());
|
||||
}
|
||||
bool ProcessWOFF2(ots::FontFile* header, ots::OTSStream* output,
|
||||
const uint8_t* data, size_t length, uint32_t index) {
|
||||
return RLBoxProcessWOFF2(header, output, data, length, index, ProcessTTC, ProcessTTF);
|
||||
}
|
||||
|
||||
ots::TableAction GetTableAction(const ots::FontFile *header, uint32_t tag) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "silf.h"
|
||||
|
||||
#include "name.h"
|
||||
#include "lz4.h"
|
||||
#include "mozilla/Compression.h"
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
|
||||
|
@ -50,14 +50,15 @@ bool OpenTypeSILF::Parse(const uint8_t* data, size_t length,
|
|||
decompressed_size / (1024.0 * 1024.0));
|
||||
}
|
||||
std::unique_ptr<uint8_t> decompressed(new uint8_t[decompressed_size]());
|
||||
int ret = LZ4_decompress_safe_partial(
|
||||
size_t outputSize = 0;
|
||||
bool ret = mozilla::Compression::LZ4::decompressPartial(
|
||||
reinterpret_cast<const char*>(data + table.offset()),
|
||||
reinterpret_cast<char*>(decompressed.get()),
|
||||
table.remaining(), // input buffer size (input size + padding)
|
||||
reinterpret_cast<char*>(decompressed.get()),
|
||||
decompressed_size, // target output size
|
||||
decompressed_size); // output buffer size
|
||||
if (ret < 0 || unsigned(ret) != decompressed_size) {
|
||||
return DropGraphite("Decompression failed with error code %d", ret);
|
||||
&outputSize); // return output size
|
||||
if (!ret || outputSize != decompressed_size) {
|
||||
return DropGraphite("Decompression failed");
|
||||
}
|
||||
return this->Parse(decompressed.get(), decompressed_size, true);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче