author | Frédéric Wang <fred.wang@free.fr> |
Fri, 31 Jan 2014 15:09:09 +0000 | |
changeset 166276 | 587d9ae58de6fadb560708ea6c6dffc169eeb41f |
parent 166275 | b015ee22f28007b78598d78432c6c98b13e77978 |
child 166277 | cd5db3c0a02a7685e2170287e033ca725bae6d96 |
push id | 39152 |
push user | jkew@mozilla.com |
push date | Fri, 31 Jan 2014 15:11:44 +0000 |
treeherder | mozilla-inbound@cd5db3c0a02a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jfkthame |
bugs | 941019 |
milestone | 29.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
gfx/ots/README.mozilla | file | annotate | diff | comparison | revisions | |
gfx/ots/ots-fix-sparc64.patch | file | annotate | diff | comparison | revisions | |
gfx/ots/ots-fix-vc10.patch | file | annotate | diff | comparison | revisions | |
gfx/ots/ots-graphite.patch | file | annotate | diff | comparison | revisions | |
gfx/ots/ots-visibility.patch | file | annotate | diff | comparison | revisions | |
gfx/ots/ots-woff2.patch | file | annotate | diff | comparison | revisions | |
gfx/ots/src/moz.build | file | annotate | diff | comparison | revisions |
--- a/gfx/ots/README.mozilla +++ b/gfx/ots/README.mozilla @@ -1,14 +1,10 @@ This is the Sanitiser for OpenType project, from http://code.google.com/p/ots/. -Current revision: r95 +Our reference repository is https://github.com/khaledhosny/ots/. + +Current revision: d7d831edd171054c7974f5e0dec2fc19bf869574 Applied local patches: - ots-fix-vc10.patch - workaround for VS10 STL wrappers (bug 602558) - - ots-fix-sparc64.patch - fix alignment error on sparc64 (bug 643137) - - ots-graphite.patch - preserve Graphite layout tables (bug 631479) - ots-visibility.patch - make Process function externally visible for Windows DLL (bug 711079) -Patches from https://bugzilla.mozilla.org/show_bug.cgi?id=670901. + ots-woff2 - disable WOFF2 support (bug 941019)
deleted file mode 100644 --- a/gfx/ots/ots-fix-sparc64.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/gfx/ots/include/opentype-sanitiser.h b/gfx/ots/include/opentype-sanitiser.h ---- a/gfx/ots/include/opentype-sanitiser.h -+++ b/gfx/ots/include/opentype-sanitiser.h -@@ -83,18 +83,20 @@ class OTSStream { - if (chksum_buffer_offset_ == 4) { - uint32_t chksum; - std::memcpy(&chksum, chksum_buffer_, 4); - chksum_ += ntohl(chksum); - chksum_buffer_offset_ = 0; - } - - while (length >= 4) { -- chksum_ += ntohl(*reinterpret_cast<const uint32_t*>( -- reinterpret_cast<const uint8_t*>(data) + offset)); -+ uint32_t tmp; -+ std::memcpy(&tmp, reinterpret_cast<const uint8_t *>(data) + offset, -+ sizeof(uint32_t)); -+ chksum_ += ntohl(tmp); - length -= 4; - offset += 4; - } - - if (length) { - if (chksum_buffer_offset_ != 0) return false; // not reached - if (length > 4) return false; // not reached - std::memcpy(chksum_buffer_,
deleted file mode 100644 --- a/gfx/ots/ots-fix-vc10.patch +++ /dev/null @@ -1,60 +0,0 @@ -diff --git a/gfx/ots/src/gasp.h b/gfx/ots/src/gasp.h ---- a/gfx/ots/src/gasp.h -+++ b/gfx/ots/src/gasp.h -@@ -1,15 +1,16 @@ - // Copyright (c) 2009 The Chromium Authors. All rights reserved. - // Use of this source code is governed by a BSD-style license that can be - // found in the LICENSE file. - - #ifndef OTS_GASP_H_ - #define OTS_GASP_H_ - -+#include <new> - #include <utility> // std::pair - #include <vector> - - #include "ots.h" - - namespace ots { - - struct OpenTypeGASP { -diff --git a/gfx/ots/src/glyf.h b/gfx/ots/src/glyf.h ---- a/gfx/ots/src/glyf.h -+++ b/gfx/ots/src/glyf.h -@@ -1,15 +1,16 @@ - // Copyright (c) 2009 The Chromium Authors. All rights reserved. - // Use of this source code is governed by a BSD-style license that can be - // found in the LICENSE file. - - #ifndef OTS_GLYF_H_ - #define OTS_GLYF_H_ - -+#include <new> - #include <utility> // std::pair - #include <vector> - - #include "ots.h" - - namespace ots { - - struct OpenTypeGLYF { -diff --git a/gfx/ots/src/metrics.h b/gfx/ots/src/metrics.h ---- a/gfx/ots/src/metrics.h -+++ b/gfx/ots/src/metrics.h -@@ -1,15 +1,16 @@ - // Copyright (c) 2011 The Chromium Authors. All rights reserved. - // Use of this source code is governed by a BSD-style license that can be - // found in the LICENSE file. - - #ifndef OTS_METRICS_H_ - #define OTS_METRICS_H_ - -+#include <new> - #include <utility> // std::pair - #include <vector> - - #include "ots.h" - - namespace ots { - - struct OpenTypeMetricsHeader {
deleted file mode 100644 --- a/gfx/ots/ots-graphite.patch +++ /dev/null @@ -1,131 +0,0 @@ -diff --git a/gfx/ots/include/opentype-sanitiser.h b/gfx/ots/include/opentype-sanitiser.h ---- a/gfx/ots/include/opentype-sanitiser.h -+++ b/gfx/ots/include/opentype-sanitiser.h -@@ -176,18 +176,20 @@ class OTSStream { - - // ----------------------------------------------------------------------------- - // Process a given OpenType file and write out a sanitised version - // output: a pointer to an object implementing the OTSStream interface. The - // sanitisied output will be written to this. In the even of a failure, - // partial output may have been written. - // input: the OpenType file - // length: the size, in bytes, of |input| -+// preserve_graphite_tables: whether to preserve Graphite Layout tables - // ----------------------------------------------------------------------------- --bool Process(OTSStream *output, const uint8_t *input, size_t length); -+bool Process(OTSStream *output, const uint8_t *input, size_t length, -+ bool preserve_graphite_tables = false); - - // Force to disable debug output even when the library is compiled with - // -DOTS_DEBUG. - void DisableDebugOutput(); - - } // namespace ots - - #endif // OPENTYPE_SANITISER_H_ -diff --git a/gfx/ots/src/ots.cc b/gfx/ots/src/ots.cc ---- a/gfx/ots/src/ots.cc -+++ b/gfx/ots/src/ots.cc -@@ -138,16 +138,27 @@ const struct { - { "GPOS", ots::ots_gpos_parse, ots::ots_gpos_serialise, - ots::ots_gpos_should_serialise, ots::ots_gpos_free, false }, - { "GSUB", ots::ots_gsub_parse, ots::ots_gsub_serialise, - ots::ots_gsub_should_serialise, ots::ots_gsub_free, false }, - { "vhea", ots::ots_vhea_parse, ots::ots_vhea_serialise, - ots::ots_vhea_should_serialise, ots::ots_vhea_free, false }, - { "vmtx", ots::ots_vmtx_parse, ots::ots_vmtx_serialise, - ots::ots_vmtx_should_serialise, ots::ots_vmtx_free, false }, -+ // SILGraphite layout tables - not actually parsed, just copied -+ { "Silf", ots::ots_silf_parse, ots::ots_silf_serialise, -+ ots::ots_silf_should_serialise, ots::ots_silf_free, false }, -+ { "Sill", ots::ots_sill_parse, ots::ots_sill_serialise, -+ ots::ots_sill_should_serialise, ots::ots_sill_free, false }, -+ { "Gloc", ots::ots_gloc_parse, ots::ots_gloc_serialise, -+ ots::ots_gloc_should_serialise, ots::ots_gloc_free, false }, -+ { "Glat", ots::ots_glat_parse, ots::ots_glat_serialise, -+ ots::ots_glat_should_serialise, ots::ots_glat_free, false }, -+ { "Feat", ots::ots_feat_parse, ots::ots_feat_serialise, -+ ots::ots_feat_should_serialise, ots::ots_feat_free, false }, - // TODO(bashi): Support mort, base, and jstf tables. - { 0, NULL, NULL, NULL, NULL, false }, - }; - - bool IsValidVersionTag(uint32_t tag) { - return tag == Tag("\x00\x01\x00\x00") || - // OpenType fonts with CFF data have 'OTTO' tag. - tag == Tag("OTTO") || -@@ -581,22 +592,25 @@ bool ProcessGeneric(ots::OpenTypeFile *h - } // namespace - - namespace ots { - - void DisableDebugOutput() { - g_debug_output = false; - } - --bool Process(OTSStream *output, const uint8_t *data, size_t length) { -+bool Process(OTSStream *output, const uint8_t *data, size_t length, -+ bool preserveGraphite) { - OpenTypeFile header; - if (length < 4) { - return OTS_FAILURE(); - } - -+ header.preserve_graphite = preserveGraphite; -+ - bool result; - if (data[0] == 'w' && data[1] == 'O' && data[2] == 'F' && data[3] == 'F') { - result = ProcessWOFF(&header, output, data, length); - } else { - result = ProcessTTF(&header, output, data, length); - } - - for (unsigned i = 0; ; ++i) { -diff --git a/gfx/ots/src/ots.h b/gfx/ots/src/ots.h ---- a/gfx/ots/src/ots.h -+++ b/gfx/ots/src/ots.h -@@ -178,17 +178,22 @@ class Buffer { - F(maxp, MAXP) \ - F(name, NAME) \ - F(os2, OS2) \ - F(post, POST) \ - F(prep, PREP) \ - F(vdmx, VDMX) \ - F(vorg, VORG) \ - F(vhea, VHEA) \ -- F(vmtx, VMTX) -+ F(vmtx, VMTX) \ -+ F(silf, SILF) \ -+ F(sill, SILL) \ -+ F(glat, GLAT) \ -+ F(gloc, GLOC) \ -+ F(feat, FEAT) - - #define F(name, capname) struct OpenType##capname; - FOR_EACH_TABLE_TYPE - #undef F - - struct OpenTypeFile { - OpenTypeFile() { - #define F(name, capname) name = NULL; -@@ -197,16 +202,20 @@ struct OpenTypeFile { - } - - uint32_t version; - uint16_t num_tables; - uint16_t search_range; - uint16_t entry_selector; - uint16_t range_shift; - -+ // This is used to tell the relevant parsers whether to preserve the -+ // Graphite layout tables (currently _without_ any checking) -+ bool preserve_graphite; -+ - #define F(name, capname) OpenType##capname *name; - FOR_EACH_TABLE_TYPE - #undef F - }; - - #define F(name, capname) \ - bool ots_##name##_parse(OpenTypeFile *f, const uint8_t *d, size_t l); \ - bool ots_##name##_should_serialise(OpenTypeFile *f); \
--- a/gfx/ots/ots-visibility.patch +++ b/gfx/ots/ots-visibility.patch @@ -32,29 +32,57 @@ diff --git a/gfx/ots/include/opentype-sa #if defined(_WIN32) #include <stdlib.h> typedef signed char int8_t; typedef unsigned char uint8_t; typedef short int16_t; typedef unsigned short uint16_t; typedef int int32_t; typedef unsigned int uint32_t; -@@ -178,18 +198,18 @@ class OTSStream { +@@ -182,45 +202,45 @@ class OTSStream { + // ----------------------------------------------------------------------------- // Process a given OpenType file and write out a sanitised version // output: a pointer to an object implementing the OTSStream interface. The // sanitisied output will be written to this. In the even of a failure, // partial output may have been written. // input: the OpenType file // length: the size, in bytes, of |input| - // preserve_graphite_tables: whether to preserve Graphite Layout tables // ----------------------------------------------------------------------------- --bool Process(OTSStream *output, const uint8_t *input, size_t length, -- bool preserve_graphite_tables = false); -+bool OTS_API Process(OTSStream *output, const uint8_t *input, size_t length, -+ bool preserve_graphite_tables = false); +-bool Process(OTSStream *output, const uint8_t *input, size_t length); ++bool OTS_API Process(OTSStream *output, const uint8_t *input, size_t length); + + // Signature of the function to be provided by the client in order to report errors. + // The return type is a boolean so that it can be used within an expression, + // but the actual value is ignored. (Suggested convention is to always return 'false'.) + #ifdef __GCC__ + #define MSGFUNC_FMT_ATTR __attribute__((format(printf, 2, 3))) + #else + #define MSGFUNC_FMT_ATTR + #endif + typedef bool (*MessageFunc)(void *user_data, const char *format, ...) MSGFUNC_FMT_ATTR; + + // Set a callback function that will be called when OTS is reporting an error. +-void SetMessageCallback(MessageFunc func, void *user_data); ++void OTS_API SetMessageCallback(MessageFunc func, void *user_data); + + enum TableAction { + TABLE_ACTION_DEFAULT, // Use OTS's default action for that table + TABLE_ACTION_SANITIZE, // Sanitize the table, potentially droping it + TABLE_ACTION_PASSTHRU, // Serialize the table unchanged + TABLE_ACTION_DROP // Drop the table + }; + + // Signature of the function to be provided by the client to decide what action + // to do for a given table. + typedef TableAction (*TableActionFunc)(uint32_t tag, void *user_data); + + // Set a callback function that will be called when OTS needs to decide what to + // do for a font table. +-void SetTableActionCallback(TableActionFunc func, void *user_data); ++void OTS_API SetTableActionCallback(TableActionFunc func, void *user_data); // Force to disable debug output even when the library is compiled with // -DOTS_DEBUG. void DisableDebugOutput(); - } // namespace ots + // Enable WOFF2 support(experimental). + void EnableWOFF2(); - #endif // OPENTYPE_SANITISER_H_
new file mode 100644 --- /dev/null +++ b/gfx/ots/ots-woff2.patch @@ -0,0 +1,134 @@ +diff --git a/gfx/ots/include/opentype-sanitiser.h b/gfx/ots/include/opentype-sanitiser.h +--- a/gfx/ots/include/opentype-sanitiser.h ++++ b/gfx/ots/include/opentype-sanitiser.h +@@ -236,14 +236,16 @@ typedef TableAction (*TableActionFunc)(u + // Set a callback function that will be called when OTS needs to decide what to + // do for a font table. + void OTS_API SetTableActionCallback(TableActionFunc func, void *user_data); + + // Force to disable debug output even when the library is compiled with + // -DOTS_DEBUG. + void DisableDebugOutput(); + ++#ifdef MOZ_OTS_WOFF2 + // Enable WOFF2 support(experimental). + void EnableWOFF2(); ++#endif + + } // namespace ots + + #endif // OPENTYPE_SANITISER_H_ +diff --git a/gfx/ots/src/ots.cc b/gfx/ots/src/ots.cc +--- a/gfx/ots/src/ots.cc ++++ b/gfx/ots/src/ots.cc +@@ -9,25 +9,29 @@ + + #include <algorithm> + #include <cstdlib> + #include <cstring> + #include <limits> + #include <map> + #include <vector> + ++#ifdef MOZ_OTS_WOFF2 + #include "woff2.h" ++#endif + + // The OpenType Font File + // http://www.microsoft.com/typography/otspec/cmap.htm + + namespace { + + bool g_debug_output = true; ++#ifdef MOZ_OTS_WOFF2 + bool g_enable_woff2 = false; ++#endif + + ots::MessageFunc g_message_func = NULL; + void *g_message_user_data = NULL; + + ots::TableActionFunc g_table_action_func = NULL; + void *g_table_action_user_data = NULL; + + // Generate a message with or without a table tag, when 'header' is the OpenTypeFile pointer +@@ -395,16 +399,17 @@ bool ProcessWOFF(ots::OpenTypeFile *head + } + if (block_end != ots::Round4(length)) { + return OTS_FAILURE_MSG_HDR("file length mismatch (trailing junk?)"); + } + + return ProcessGeneric(header, woff_tag, output, data, length, tables, file); + } + ++#ifdef MOZ_OTS_WOFF2 + bool ProcessWOFF2(ots::OpenTypeFile *header, + ots::OTSStream *output, const uint8_t *data, size_t length) { + size_t decompressed_size = ots::ComputeWOFF2FinalSize(data, length); + if (decompressed_size == 0) { + return OTS_FAILURE(); + } + // decompressed font must be <= 30MB + if (decompressed_size > 30 * 1024 * 1024) { +@@ -413,16 +418,17 @@ bool ProcessWOFF2(ots::OpenTypeFile *hea + + std::vector<uint8_t> decompressed_buffer(decompressed_size); + if (!ots::ConvertWOFF2ToTTF(&decompressed_buffer[0], decompressed_size, + data, length)) { + return OTS_FAILURE(); + } + return ProcessTTF(header, output, &decompressed_buffer[0], decompressed_size); + } ++#endif + + ots::TableAction GetTableAction(uint32_t tag) { + ots::TableAction action = ots::TABLE_ACTION_DEFAULT; + + if (g_table_action_func != NULL) { + action = g_table_action_func(htonl(tag), g_table_action_user_data); + } + +@@ -795,19 +801,21 @@ bool IsValidVersionTag(uint32_t tag) { + tag == Tag("true") || + tag == Tag("typ1"); + } + + void DisableDebugOutput() { + g_debug_output = false; + } + ++#ifdef MOZ_OTS_WOFF2 + void EnableWOFF2() { + g_enable_woff2 = true; + } ++#endif + + void SetMessageCallback(MessageFunc func, void *user_data) { + g_message_func = func; + g_message_user_data = user_data; + } + + void SetTableActionCallback(TableActionFunc func, void *user_data) { + g_table_action_func = func; +@@ -822,20 +830,22 @@ bool Process(OTSStream *output, const ui + + if (length < 4) { + return OTS_FAILURE_MSG_(&header, "file less than 4 bytes"); + } + + bool result; + if (data[0] == 'w' && data[1] == 'O' && data[2] == 'F' && data[3] == 'F') { + result = ProcessWOFF(&header, output, data, length); ++#ifdef MOZ_OTS_WOFF2 + } else if (g_enable_woff2 && + data[0] == 'w' && data[1] == 'O' && data[2] == 'F' && + data[3] == '2') { + result = ProcessWOFF2(&header, output, data, length); ++#endif + } else { + result = ProcessTTF(&header, output, data, length); + } + + for (unsigned i = 0; ; ++i) { + if (table_parsers[i].parse == NULL) break; + table_parsers[i].free(&header); + }
--- a/gfx/ots/src/moz.build +++ b/gfx/ots/src/moz.build @@ -13,52 +13,50 @@ SOURCES += [ # don't unify sources that use a (file-specific) DROP_THIS_TABLE macro 'gasp.cc', 'gdef.cc', 'gpos.cc', 'gsub.cc', 'hdmx.cc', 'kern.cc', 'ltsh.cc', + 'math.cc', 'vdmx.cc', 'vorg.cc', ] UNIFIED_SOURCES += [ 'cff.cc', 'cff_type2_charstring.cc', 'cmap.cc', 'cvt.cc', 'fpgm.cc', 'glyf.cc', - 'graphite.cc', 'head.cc', 'hhea.cc', 'hmtx.cc', 'layout.cc', 'loca.cc', 'maxp.cc', 'metrics.cc', 'name.cc', 'os2.cc', 'ots.cc', 'post.cc', 'prep.cc', - 'svg.cc', 'vhea.cc', 'vmtx.cc', ] MSVC_ENABLE_PGO = True if CONFIG['GKMEDIAS_SHARED_LIBRARY']: NO_VISIBILITY_FLAGS = True FINAL_LIBRARY = 'gkmedias' DEFINES['PACKAGE_VERSION'] = '"moz"' DEFINES['PACKAGE_BUGREPORT'] = '"http://bugzilla.mozilla.org/"' DEFINES['NOMINMAX'] = True -DEFINES['MOZ_OTS_REPORT_ERRORS'] = True if CONFIG['OS_TARGET'] == 'WINNT': DEFINES['OTS_DLL'] = True DEFINES['OTS_DLL_EXPORTS'] = True