bug 833283 - remove the option to bypass OTS for downloaded fonts. r=jdaggett

This commit is contained in:
Jonathan Kew 2013-01-23 16:41:18 +00:00
parent 550915d0b2
commit e091da2191
10 changed files with 39 additions and 1993 deletions

View File

@ -345,9 +345,7 @@ CMMSRCS = \
endif
CSRCS += woff.c
DEFINES += -DIMPL_THEBES -DWOFF_MOZILLA_CLIENT -DHB_DONT_DEFINE_STDINT
DEFINES += -DIMPL_THEBES -DHB_DONT_DEFINE_STDINT
DEFINES += -DMOZ_OTS_REPORT_ERRORS
ifeq (WINNT,$(OS_TARGET))

View File

@ -24,8 +24,6 @@
#include "plbase64.h"
#include "prlog.h"
#include "woff.h"
#ifdef XP_MACOSX
#include <CoreFoundation/CoreFoundation.h>
#endif
@ -1118,228 +1116,6 @@ gfxFontUtils::DetermineFontDataType(const uint8_t *aFontData, uint32_t aFontData
return GFX_USERFONT_UNKNOWN;
}
bool
gfxFontUtils::ValidateSFNTHeaders(const uint8_t *aFontData,
uint32_t aFontDataLength)
{
NS_ASSERTION(aFontData, "null font data");
uint64_t dataLength(aFontDataLength);
// read in the sfnt header
if (sizeof(SFNTHeader) > aFontDataLength) {
NS_WARNING("invalid font (insufficient data)");
return false;
}
const SFNTHeader *sfntHeader = reinterpret_cast<const SFNTHeader*>(aFontData);
uint32_t sfntVersion = sfntHeader->sfntVersion;
if (!IsValidSFNTVersion(sfntVersion)) {
NS_WARNING("invalid font (SFNT version)");
return false;
}
// iterate through the table headers to find the head, name and OS/2 tables
#ifdef XP_WIN
bool foundOS2 = false;
#endif
bool foundHead = false, foundName = false;
bool foundGlyphs = false, foundCFF = false, foundKern = false;
bool foundLoca = false, foundMaxp = false;
uint32_t headOffset = 0, headLen, nameOffset = 0, kernOffset = 0,
kernLen = 0, glyfLen = 0, locaOffset = 0, locaLen = 0,
maxpOffset = 0, maxpLen;
uint32_t i, numTables;
numTables = sfntHeader->numTables;
uint32_t headerLen = sizeof(SFNTHeader) + sizeof(TableDirEntry) * numTables;
if (headerLen > aFontDataLength) {
NS_WARNING("invalid font (table directory)");
return false;
}
// table directory entries begin immediately following SFNT header
const TableDirEntry *dirEntry =
reinterpret_cast<const TableDirEntry*>(aFontData + sizeof(SFNTHeader));
uint32_t checksum = 0;
// checksum for font = (checksum of header) + (checksum of tables)
const AutoSwap_PRUint32 *headerData =
reinterpret_cast<const AutoSwap_PRUint32*>(aFontData);
// header length is in bytes, checksum calculated in longwords
for (i = 0; i < (headerLen >> 2); i++, headerData++) {
checksum += *headerData;
}
for (i = 0; i < numTables; i++, dirEntry++) {
// sanity check on offset, length values
if (uint64_t(dirEntry->offset) + uint64_t(dirEntry->length) > dataLength) {
NS_WARNING("invalid font (table directory entry)");
return false;
}
checksum += dirEntry->checkSum;
switch (dirEntry->tag) {
case TRUETYPE_TAG('h','e','a','d'):
foundHead = true;
headOffset = dirEntry->offset;
headLen = dirEntry->length;
if (headLen < sizeof(HeadTable)) {
NS_WARNING("invalid font (head table length)");
return false;
}
break;
case TRUETYPE_TAG('k','e','r','n'):
foundKern = true;
kernOffset = dirEntry->offset;
kernLen = dirEntry->length;
break;
case TRUETYPE_TAG('n','a','m','e'):
foundName = true;
nameOffset = dirEntry->offset;
break;
case TRUETYPE_TAG('O','S','/','2'):
#ifdef XP_WIN
foundOS2 = true;
#endif
break;
case TRUETYPE_TAG('g','l','y','f'): // TrueType-style quadratic glyph table
foundGlyphs = true;
glyfLen = dirEntry->length;
break;
case TRUETYPE_TAG('l','o','c','a'): // glyph location table
foundLoca = true;
locaOffset = dirEntry->offset;
locaLen = dirEntry->length;
break;
case TRUETYPE_TAG('m','a','x','p'): // max profile
foundMaxp = true;
maxpOffset = dirEntry->offset;
maxpLen = dirEntry->length;
if (maxpLen < sizeof(MaxpTableHeader)) {
NS_WARNING("invalid font (maxp table length)");
return false;
}
break;
case TRUETYPE_TAG('C','F','F',' '): // PS-style cubic glyph table
foundCFF = true;
break;
default:
break;
}
}
// simple sanity checks
// -- fonts need head, name, maxp tables
if (!foundHead || !foundName || !foundMaxp) {
NS_WARNING("invalid font (missing head/name/maxp table)");
return false;
}
// -- on Windows need OS/2 table
#ifdef XP_WIN
if (!foundOS2) {
NS_WARNING("invalid font (missing OS/2 table)");
return false;
}
#endif
// -- head table data
const HeadTable *headData = reinterpret_cast<const HeadTable*>(aFontData + headOffset);
if (headData->tableVersionNumber != HeadTable::HEAD_VERSION) {
NS_WARNING("invalid font (head table version)");
return false;
}
if (headData->magicNumber != HeadTable::HEAD_MAGIC_NUMBER) {
NS_WARNING("invalid font (head magic number)");
return false;
}
if (headData->checkSumAdjustment != (HeadTable::HEAD_CHECKSUM_CALC_CONST - checksum)) {
NS_WARNING("invalid font (bad checksum)");
// Bug 483459 - warn about a bad checksum but allow the font to be
// used, since a small percentage of fonts don't calculate this
// correctly and font systems aren't fussy about this
// return false;
}
// need glyf or CFF table based on sfnt version
if (sfntVersion == TRUETYPE_TAG('O','T','T','O')) {
if (!foundCFF) {
NS_WARNING("invalid font (missing CFF table)");
return false;
}
} else {
if (!foundGlyphs || !foundLoca) {
NS_WARNING("invalid font (missing glyf or loca table)");
return false;
}
// sanity-check 'loca' offsets
const MaxpTableHeader *maxpData =
reinterpret_cast<const MaxpTableHeader*>(aFontData + maxpOffset);
if (!ValidateLocaTable(aFontData + locaOffset, locaLen, glyfLen,
headData->indexToLocFormat,
maxpData->numGlyphs)) {
NS_WARNING("invalid font (loca table offsets)");
return false;
}
}
// -- name table data
const NameHeader *nameHeader = reinterpret_cast<const NameHeader*>(aFontData + nameOffset);
uint32_t nameCount = nameHeader->count;
// -- sanity check the number of name records
if (uint64_t(nameCount) * sizeof(NameRecord) + uint64_t(nameOffset) > dataLength) {
NS_WARNING("invalid font (name records)");
return false;
}
// -- iterate through name records
const NameRecord *nameRecord = reinterpret_cast<const NameRecord*>
(aFontData + nameOffset + sizeof(NameHeader));
uint64_t nameStringsBase = uint64_t(nameOffset) + uint64_t(nameHeader->stringOffset);
for (i = 0; i < nameCount; i++, nameRecord++) {
uint32_t namelen = nameRecord->length;
uint32_t nameoff = nameRecord->offset; // offset from base of string storage
if (nameStringsBase + uint64_t(nameoff) + uint64_t(namelen) > dataLength) {
NS_WARNING("invalid font (name table strings)");
return false;
}
}
// -- sanity-check the kern table, if present (see bug 487549)
if (foundKern) {
if (!ValidateKernTable(aFontData + kernOffset, kernLen)) {
NS_WARNING("invalid font (kern table)");
return false;
}
}
// everything seems consistent
return true;
}
nsresult
gfxFontUtils::RenameFont(const nsAString& aName, const uint8_t *aFontData,
uint32_t aFontDataLength, FallibleTArray<uint8_t> *aNewFont)

View File

@ -740,8 +740,8 @@ public:
MakeEOTHeader(const uint8_t *aFontData, uint32_t aFontDataLength,
FallibleTArray<uint8_t> *aHeader, FontDataOverlay *aOverlay);
// determine whether a font (which has already passed ValidateSFNTHeaders)
// is CFF format rather than TrueType
// determine whether a font (which has already been sanitized, so is known
// to be a valid sfnt) is CFF format rather than TrueType
static bool
IsCffFont(const uint8_t* aFontData, bool& hasVertical);
@ -751,14 +751,6 @@ public:
static gfxUserFontType
DetermineFontDataType(const uint8_t *aFontData, uint32_t aFontDataLength);
// checks for valid SFNT table structure, returns true if valid
// does *not* guarantee that all font data is valid, though it does
// check that key tables such as 'name' are present and readable.
// XXX to be removed if/when we eliminate the option to disable OTS,
// which does more thorough validation.
static bool
ValidateSFNTHeaders(const uint8_t *aFontData, uint32_t aFontDataLength);
// Read the fullname from the sfnt data (used to save the original name
// prior to renaming the font for installation).
// This is called with sfnt data that has already been validated,

View File

@ -129,7 +129,6 @@ SRGBOverrideObserver::Observe(nsISupports *aSubject,
}
#define GFX_DOWNLOADABLE_FONTS_ENABLED "gfx.downloadable_fonts.enabled"
#define GFX_DOWNLOADABLE_FONTS_SANITIZE "gfx.downloadable_fonts.sanitize"
#define GFX_PREF_HARFBUZZ_SCRIPTS "gfx.font_rendering.harfbuzz.scripts"
#define HARFBUZZ_SCRIPTS_DEFAULT mozilla::unicode::SHAPING_DEFAULT
@ -240,7 +239,6 @@ gfxPlatform::gfxPlatform()
{
mUseHarfBuzzScripts = UNINITIALIZED_VALUE;
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
mDownloadableFontsSanitize = UNINITIALIZED_VALUE;
mFallbackUsesCmaps = UNINITIALIZED_VALUE;
#ifdef MOZ_GRAPHITE
@ -819,17 +817,6 @@ gfxPlatform::DownloadableFontsEnabled()
return mAllowDownloadableFonts;
}
bool
gfxPlatform::SanitizeDownloadedFonts()
{
if (mDownloadableFontsSanitize == UNINITIALIZED_VALUE) {
mDownloadableFontsSanitize =
Preferences::GetBool(GFX_DOWNLOADABLE_FONTS_SANITIZE, true);
}
return mDownloadableFontsSanitize;
}
bool
gfxPlatform::UseCmapsDuringSystemFallback()
{
@ -1619,8 +1606,6 @@ gfxPlatform::FontsPrefsChanged(const char *aPref)
NS_ASSERTION(aPref != nullptr, "null preference");
if (!strcmp(GFX_DOWNLOADABLE_FONTS_ENABLED, aPref)) {
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
} else if (!strcmp(GFX_DOWNLOADABLE_FONTS_SANITIZE, aPref)) {
mDownloadableFontsSanitize = UNINITIALIZED_VALUE;
} else if (!strcmp(GFX_PREF_FALLBACK_USE_CMAPS, aPref)) {
mFallbackUsesCmaps = UNINITIALIZED_VALUE;
#ifdef MOZ_GRAPHITE

View File

@ -315,11 +315,6 @@ public:
*/
bool DownloadableFontsEnabled();
/**
* Whether to sanitize downloaded fonts using the OTS library
*/
bool SanitizeDownloadedFonts();
/**
* True when hinting should be enabled. This setting shouldn't
* change per gecko process, while the process is live. If so the
@ -570,7 +565,6 @@ protected:
}
int8_t mAllowDownloadableFonts;
int8_t mDownloadableFontsSanitize;
#ifdef MOZ_GRAPHITE
int8_t mGraphiteShapingEnabled;
#endif

View File

@ -18,8 +18,6 @@
#include "nsIPrincipal.h"
#include "mozilla/Telemetry.h"
#include "woff.h"
#include "opentype-sanitiser.h"
#include "ots-memory-stream.h"
@ -203,58 +201,6 @@ gfxUserFontSet::FindFontEntry(gfxFontFamily *aFamily,
return nullptr;
}
// Given a buffer of downloaded font data, do any necessary preparation
// to make it into usable OpenType.
// May return the original pointer unchanged, or a newly-allocated
// block (in which case the passed-in block is NS_Free'd).
// aLength is updated if necessary to the new length of the data.
// Returns NULL and NS_Free's the incoming data in case of errors.
static const uint8_t*
PrepareOpenTypeData(const uint8_t* aData, uint32_t* aLength)
{
switch(gfxFontUtils::DetermineFontDataType(aData, *aLength)) {
case GFX_USERFONT_OPENTYPE:
// nothing to do
return aData;
case GFX_USERFONT_WOFF: {
uint32_t status = eWOFF_ok;
uint32_t bufferSize = woffGetDecodedSize(aData, *aLength, &status);
if (WOFF_FAILURE(status)) {
break;
}
uint8_t* decodedData = static_cast<uint8_t*>(NS_Alloc(bufferSize));
if (!decodedData) {
break;
}
woffDecodeToBuffer(aData, *aLength,
decodedData, bufferSize,
aLength, &status);
// replace original data with the decoded version
NS_Free((void*)aData);
aData = decodedData;
if (WOFF_FAILURE(status)) {
// something went wrong, discard the data and return NULL
break;
}
// success, return the decoded data
return aData;
}
// xxx - add support for other wrappers here
default:
NS_WARNING("unknown font format");
break;
}
// discard downloaded data that couldn't be used
NS_Free((void*)aData);
return nullptr;
}
// Based on ots::ExpandingMemoryStream from ots-memory-stream.h,
// adapted to use Mozilla allocators and to allow the final
// memory buffer to be adopted by the client.
@ -666,18 +612,6 @@ gfxUserFontSet::LoadFont(gfxMixedFontFamily *aFamily,
gfxUserFontType fontType =
gfxFontUtils::DetermineFontDataType(aFontData, aLength);
// Save a copy of the metadata block (if present) for nsIDOMFontFace
// to use if required. Ownership of the metadata block will be passed
// to the gfxUserFontData record below.
// NOTE: after the non-OTS codepath using PrepareOpenTypeData is
// removed, we should defer this until after we've created the new
// fontEntry.
nsTArray<uint8_t> metadata;
uint32_t metaOrigLen = 0;
if (fontType == GFX_USERFONT_WOFF) {
CopyWOFFMetadata(aFontData, aLength, &metadata, &metaOrigLen);
}
// Unwrap/decompress/sanitize or otherwise munge the downloaded data
// to make a usable sfnt structure.
@ -686,7 +620,6 @@ gfxUserFontSet::LoadFont(gfxMixedFontFamily *aFamily,
// it can be reported via the nsIDOMFontFace API.
nsAutoString originalFullName;
if (gfxPlatform::GetPlatform()->SanitizeDownloadedFonts()) {
// Call the OTS sanitizer; this will also decode WOFF to sfnt
// if necessary. The original data in aFontData is left unchanged.
uint32_t saneLen;
@ -712,41 +645,17 @@ gfxUserFontSet::LoadFont(gfxMixedFontFamily *aFamily,
LogMessage(aFamily, aProxy, "not usable by platform");
}
}
} else {
// FIXME: this code can be removed once we remove the pref to
// disable the sanitizer; the PrepareOpenTypeData and
// ValidateSFNTHeaders functions will then be obsolete.
aFontData = PrepareOpenTypeData(aFontData, &aLength);
if (aFontData) {
if (gfxFontUtils::ValidateSFNTHeaders(aFontData, aLength)) {
// ValidateSFNTHeaders has checked that we have a valid
// sfnt structure and a usable 'name' table
gfxFontUtils::GetFullNameFromSFNT(aFontData, aLength,
originalFullName);
// Here ownership of aFontData is passed to the platform,
// which will delete it when no longer required
fe = gfxPlatform::GetPlatform()->MakePlatformFont(aProxy,
aFontData,
aLength);
if (!fe) {
LogMessage(aFamily, aProxy, "not usable by platform");
}
aFontData = nullptr; // we must NOT free this!
} else {
// the data was unusable, so just discard it
// (error will be reported below, if logging is enabled)
LogMessage(aFamily, aProxy, "SFNT header or tables invalid");
}
}
}
if (aFontData) {
NS_Free((void*)aFontData);
aFontData = nullptr;
}
if (fe) {
// Save a copy of the metadata block (if present) for nsIDOMFontFace
// to use if required. Ownership of the metadata block will be passed
// to the gfxUserFontData record below.
nsTArray<uint8_t> metadata;
uint32_t metaOrigLen = 0;
if (fontType == GFX_USERFONT_WOFF) {
CopyWOFFMetadata(aFontData, aLength, &metadata, &metaOrigLen);
}
// copy OpenType feature/language settings from the proxy to the
// newly-created font entry
fe->mFeatureSettings.AppendElements(aProxy->mFeatureSettings);
@ -778,6 +687,10 @@ gfxUserFontSet::LoadFont(gfxMixedFontFamily *aFamily,
#endif
}
// The downloaded data can now be discarded; the font entry is using the
// sanitized copy
NS_Free((void*)aFontData);
return fe;
}

View File

@ -1,127 +0,0 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef WOFF_PRIVATE_H_
#define WOFF_PRIVATE_H_
#include "woff.h"
/* private definitions used in the WOFF encoder/decoder functions */
/* create an OT tag from 4 characters */
#define TAG(a,b,c,d) ((a)<<24 | (b)<<16 | (c)<<8 | (d))
#define WOFF_SIGNATURE TAG('w','O','F','F')
#define SFNT_VERSION_CFF TAG('O','T','T','O')
#define SFNT_VERSION_TT 0x00010000
#define SFNT_VERSION_true TAG('t','r','u','e')
#define TABLE_TAG_DSIG TAG('D','S','I','G')
#define TABLE_TAG_head TAG('h','e','a','d')
#define TABLE_TAG_bhed TAG('b','h','e','d')
#define SFNT_CHECKSUM_CALC_CONST 0xB1B0AFBAU /* from the TT/OT spec */
#ifdef WOFF_MOZILLA_CLIENT/* Copies of the NS_SWAP16 and NS_SWAP32 macros; they are defined in
a C++ header in mozilla, so we cannot include that here */
# include "prtypes.h" /* defines IS_LITTLE_ENDIAN / IS_BIG_ENDIAN */
# if defined IS_LITTLE_ENDIAN
# define READ16BE(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
# define READ32BE(x) ((READ16BE((x) & 0xffff) << 16) | (READ16BE((x) >> 16)))
# elif defined IS_BIG_ENDIAN
# define READ16BE(x) (x)
# define READ32BE(x) (x)
# else
# error "Unknown byte order"
# endif
#else
/* These macros to read values as big-endian only work on "real" variables,
not general expressions, because of the use of &(x), but they are
designed to work on both BE and LE machines without the need for a
configure check. For production code, we might want to replace this
with something more efficient. */
/* read a 32-bit BigEndian value */
# define READ32BE(x) ( ( (uint32_t) ((uint8_t*)&(x))[0] << 24 ) + \
( (uint32_t) ((uint8_t*)&(x))[1] << 16 ) + \
( (uint32_t) ((uint8_t*)&(x))[2] << 8 ) + \
(uint32_t) ((uint8_t*)&(x))[3] )
/* read a 16-bit BigEndian value */
# define READ16BE(x) ( ( (uint16_t) ((uint8_t*)&(x))[0] << 8 ) + \
(uint16_t) ((uint8_t*)&(x))[1] )
#endif
#pragma pack(push,1)
typedef struct {
uint32_t version;
uint16_t numTables;
uint16_t searchRange;
uint16_t entrySelector;
uint16_t rangeShift;
} sfntHeader;
typedef struct {
uint32_t tag;
uint32_t checksum;
uint32_t offset;
uint32_t length;
} sfntDirEntry;
typedef struct {
uint32_t signature;
uint32_t flavor;
uint32_t length;
uint16_t numTables;
uint16_t reserved;
uint32_t totalSfntSize;
uint16_t majorVersion;
uint16_t minorVersion;
uint32_t metaOffset;
uint32_t metaCompLen;
uint32_t metaOrigLen;
uint32_t privOffset;
uint32_t privLen;
} woffHeader;
typedef struct {
uint32_t tag;
uint32_t offset;
uint32_t compLen;
uint32_t origLen;
uint32_t checksum;
} woffDirEntry;
typedef struct {
uint32_t version;
uint32_t fontRevision;
uint32_t checkSumAdjustment;
uint32_t magicNumber;
uint16_t flags;
uint16_t unitsPerEm;
uint32_t created[2];
uint32_t modified[2];
int16_t xMin;
int16_t yMin;
int16_t xMax;
int16_t yMax;
uint16_t macStyle;
uint16_t lowestRecPpem;
int16_t fontDirectionHint;
int16_t indexToLocFormat;
int16_t glyphDataFormat;
} sfntHeadTable;
#define HEAD_TABLE_SIZE 54 /* sizeof(sfntHeadTable) may report 56 because of alignment */
typedef struct {
uint32_t offset;
uint16_t oldIndex;
uint16_t newIndex;
} tableOrderRec;
#pragma pack(pop)
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,187 +0,0 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef WOFF_H_
#define WOFF_H_
/* API for the WOFF encoder and decoder */
#include "mozilla/StandardInteger.h"
#include <stdio.h> /* only for FILE, needed for woffPrintStatus */
/* error codes returned in the status parameter of WOFF functions */
enum {
/* Success */
eWOFF_ok = 0,
/* Errors: no valid result returned */
eWOFF_out_of_memory = 1, /* malloc or realloc failed */
eWOFF_invalid = 2, /* invalid input file (e.g., bad offset) */
eWOFF_compression_failure = 3, /* error in zlib call */
eWOFF_bad_signature = 4, /* unrecognized file signature */
eWOFF_buffer_too_small = 5, /* the provided buffer is too small */
eWOFF_bad_parameter = 6, /* bad parameter (e.g., null source ptr) */
eWOFF_illegal_order = 7, /* improperly ordered chunks in WOFF font */
/* Warnings: call succeeded but something odd was noticed.
Multiple warnings may be OR'd together. */
eWOFF_warn_unknown_version = 0x0100, /* unrecognized version of sfnt,
not standard TrueType or CFF */
eWOFF_warn_checksum_mismatch = 0x0200, /* bad checksum, use with caution;
any DSIG will be invalid */
eWOFF_warn_misaligned_table = 0x0400, /* table not long-aligned; fixing,
but DSIG will be invalid */
eWOFF_warn_trailing_data = 0x0800, /* trailing junk discarded,
any DSIG may be invalid */
eWOFF_warn_unpadded_table = 0x1000, /* sfnt not correctly padded,
any DSIG may be invalid */
eWOFF_warn_removed_DSIG = 0x2000, /* removed digital signature
while fixing checksum errors */
eWOFF_warn_no_such_table = 0x4000 /* specified table not present */
};
/* Note: status parameters must be initialized to eWOFF_ok before calling
WOFF functions. If the status parameter contains an error code,
functions will return immediately. */
#define WOFF_SUCCESS(status) (((uint32_t)(status) & 0xff) == eWOFF_ok)
#define WOFF_FAILURE(status) (!WOFF_SUCCESS(status))
#define WOFF_WARNING(status) ((uint32_t)(status) & ~0xff)
#ifdef __cplusplus
extern "C" {
#endif
#ifndef WOFF_DISABLE_ENCODING
/*****************************************************************************
* Returns a new malloc() block containing the encoded data, or NULL on error;
* caller should free() this when finished with it.
* Returns length of the encoded data in woffLen.
* The new WOFF has no metadata or private block;
* see the following functions to update these elements.
*/
const uint8_t * woffEncode(const uint8_t * sfntData, uint32_t sfntLen,
uint16_t majorVersion, uint16_t minorVersion,
uint32_t * woffLen, uint32_t * status);
/*****************************************************************************
* Add the given metadata block to the WOFF font, replacing any existing
* metadata block. The block will be zlib-compressed.
* Metadata is required to be valid XML (use of UTF-8 is recommended),
* though this function does not currently check this.
* The woffData pointer must be a malloc() block (typically from woffEncode);
* it will be freed by this function and a new malloc() block will be returned.
* Returns NULL if an error occurs, in which case the original WOFF is NOT freed.
*/
const uint8_t * woffSetMetadata(const uint8_t * woffData, uint32_t * woffLen,
const uint8_t * metaData, uint32_t metaLen,
uint32_t * status);
/*****************************************************************************
* Add the given private data block to the WOFF font, replacing any existing
* private block. The block will NOT be zlib-compressed.
* Private data may be any arbitrary block of bytes; it may be externally
* compressed by the client if desired.
* The woffData pointer must be a malloc() block (typically from woffEncode);
* it will be freed by this function and a new malloc() block will be returned.
* Returns NULL if an error occurs, in which case the original WOFF is NOT freed.
*/
const uint8_t * woffSetPrivateData(const uint8_t * woffData, uint32_t * woffLen,
const uint8_t * privData, uint32_t privLen,
uint32_t * status);
#endif /* WOFF_DISABLE_ENCODING */
/*****************************************************************************
* Returns the size of buffer needed to decode the font (or zero on error).
*/
uint32_t woffGetDecodedSize(const uint8_t * woffData, uint32_t woffLen,
uint32_t * pStatus);
/*****************************************************************************
* Decodes WOFF font to a caller-supplied buffer of size bufferLen.
* Returns the actual size of the decoded sfnt data in pActualSfntLen
* (must be <= bufferLen, otherwise an error will be returned).
*/
void woffDecodeToBuffer(const uint8_t * woffData, uint32_t woffLen,
uint8_t * sfntData, uint32_t bufferLen,
uint32_t * pActualSfntLen, uint32_t * pStatus);
/*****************************************************************************
* Returns a new malloc() block containing the decoded data, or NULL on error;
* caller should free() this when finished with it.
* Returns length of the decoded data in sfntLen.
*/
const uint8_t * woffDecode(const uint8_t * woffData, uint32_t woffLen,
uint32_t * sfntLen, uint32_t * status);
/*****************************************************************************
* Returns the size of buffer needed for a specific table (or zero on error).
*/
uint32_t woffGetTableSize(const uint8_t * woffData, uint32_t woffLen,
uint32_t tag, uint32_t * pStatus);
/*****************************************************************************
* Gets a table from a WOFF font to a caller-supplied buffer of size bufferLen.
* Returns the actual size of the decoded table in pTableLen
* (must be <= bufferLen, otherwise an error will be returned).
*/
void woffGetTableToBuffer(const uint8_t * woffData, uint32_t woffLen,
uint32_t tag, uint8_t * buffer, uint32_t bufferLen,
uint32_t * pTableLen, uint32_t * pStatus);
/*****************************************************************************
* Returns a new malloc() block containing the metadata from the WOFF font,
* or NULL if an error occurs or no metadata is present.
* Length of the metadata is returned in metaLen.
* The metadata is decompressed before returning.
*/
const uint8_t * woffGetMetadata(const uint8_t * woffData, uint32_t woffLen,
uint32_t * metaLen, uint32_t * status);
/*****************************************************************************
* Returns a new malloc() block containing the private data from the WOFF font,
* or NULL if an error occurs or no private data is present.
* Length of the private data is returned in privLen.
*/
const uint8_t * woffGetPrivateData(const uint8_t * woffData, uint32_t woffLen,
uint32_t * privLen, uint32_t * status);
/*****************************************************************************
* Returns the font version numbers from the WOFF font in the major and minor
* parameters.
* Check the status result to know if the function succeeded.
*/
void woffGetFontVersion(const uint8_t * woffData, uint32_t woffLen,
uint16_t * major, uint16_t * minor,
uint32_t * status);
/*****************************************************************************
* Utility to print warning and/or error status to the specified FILE*.
* The prefix string will be prepended to each line (ok to pass NULL if no
* prefix is wanted).
* (Provides terse English messages only, not intended for end-user display;
* user-friendly tools should map the status codes to their own messages.)
*/
void woffPrintStatus(FILE * f, uint32_t status, const char * prefix);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -211,7 +211,6 @@ pref("gfx.color_management.enablev4", false);
pref("gfx.downloadable_fonts.enabled", true);
pref("gfx.downloadable_fonts.fallback_delay", 3000);
pref("gfx.downloadable_fonts.sanitize", true);
pref("gfx.filter.nearest.force-enabled", false);