Bug 1305944 - Update OTS to version 5.1.0. r=jfkthame
authorFrédéric Wang <fred.wang@free.fr>
Wed, 28 Sep 2016 04:05:00 -0400
changeset 315672 edac45c6b83cbe766b9df9274746f43f417f85e9
parent 315671 4dd0aaa71fb047fb7b53895b78e0f8b33a4606a2
child 315673 fc4b39cdfb64b76b6f74b63ebf987dfe0e047f44
push id30753
push usercbook@mozilla.com
push dateThu, 29 Sep 2016 09:45:12 +0000
treeherdermozilla-central@f7d5008ee2ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1305944
milestone52.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
Bug 1305944 - Update OTS to version 5.1.0. r=jfkthame
gfx/ots/README.mozilla
gfx/ots/include/opentype-sanitiser.h
gfx/ots/src/ots.cc
layout/reftests/font-face/reftest.list
layout/reftests/font-face/woff2-totalsfntsize-ref.html
layout/reftests/font-face/woff2-totalsfntsize.html
layout/reftests/fonts/header-totalsfntsize-001.ttf
layout/reftests/fonts/header-totalsfntsize-001.woff2
modules/woff2/README.mozilla
modules/woff2/src/woff2_dec.cc
modules/woff2/src/woff2_dec.h
--- a/gfx/ots/README.mozilla
+++ b/gfx/ots/README.mozilla
@@ -1,11 +1,11 @@
 This is the Sanitiser for OpenType project, from http://code.google.com/p/ots/.
 
 Our reference repository is https://github.com/khaledhosny/ots/.
 
-Current revision: 8d70cffebbfa58f67a5c3ed0e9bc84dccdbc5bc0
+Current revision: ba8417620956a920ed1f05a2f666fb6317fb10cb
 
 Upstream files included: LICENSE, src/, include/
 
 Additional files: README.mozilla, src/moz.build
 
 Additional patch: ots-visibility.patch (bug 711079).
--- a/gfx/ots/include/opentype-sanitiser.h
+++ b/gfx/ots/include/opentype-sanitiser.h
@@ -39,16 +39,18 @@ typedef unsigned __int64 uint64_t;
 #define ntohs(x) _byteswap_ushort (x)
 #define htonl(x) _byteswap_ulong (x)
 #define htons(x) _byteswap_ushort (x)
 #else
 #include <arpa/inet.h>
 #include <stdint.h>
 #endif
 
+#include <sys/types.h>
+
 #include <algorithm>
 #include <cassert>
 #include <cstddef>
 #include <cstring>
 
 #define OTS_TAG(c1,c2,c3,c4) ((uint32_t)((((uint8_t)(c1))<<24)|(((uint8_t)(c2))<<16)|(((uint8_t)(c3))<<8)|((uint8_t)(c4))))
 #define OTS_UNTAG(tag)       ((uint8_t)((tag)>>24)), ((uint8_t)((tag)>>16)), ((uint8_t)((tag)>>8)), ((uint8_t)(tag))
 
--- a/gfx/ots/src/ots.cc
+++ b/gfx/ots/src/ots.cc
@@ -473,27 +473,28 @@ bool ProcessWOFF2(ots::OpenTypeFile *hea
   if (decompressed_size == 0) {
     return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 is set to 0");
   }
   // decompressed font must be <= 30MB
   if (decompressed_size > 30 * 1024 * 1024) {
     return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 font exceeds 30MB");
   }
 
-  std::vector<uint8_t> decompressed_buffer(decompressed_size);
-  if (!woff2::ConvertWOFF2ToTTF(&decompressed_buffer[0], decompressed_size,
-                                data, length)) {
+  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_buffer[0], decompressed_size, index);
+    return ProcessTTC(header, output, decompressed, out.Size(), index);
   } else {
     ots::Font font(header);
-    return ProcessTTF(header, &font, output, &decompressed_buffer[0], decompressed_size);
+    return ProcessTTF(header, &font, output, decompressed, out.Size());
   }
 }
 
 ots::TableAction GetTableAction(ots::OpenTypeFile *header, uint32_t tag) {
   ots::TableAction action = header->context->GetTableAction(tag);
 
   if (action == ots::TABLE_ACTION_DEFAULT) {
     action = ots::TABLE_ACTION_DROP;
--- a/layout/reftests/font-face/reftest.list
+++ b/layout/reftests/font-face/reftest.list
@@ -164,16 +164,17 @@ HTTP(..) == font-redirect.html order-1-r
 # Test for COLR and CPAL support
 HTTP(..) == color-1a.html color-1-ref.html
 HTTP(..) != color-1a.html color-1-notref.html
 HTTP(..) == color-1b.html color-1-ref.html
 HTTP(..) == color-2a.html color-2-ref.html
 HTTP(..) != color-2a.html color-2-notref.html
 
 pref(gfx.downloadable_fonts.woff2.enabled,true) HTTP(..) == woff2-1.html woff2-1-ref.html
+pref(gfx.downloadable_fonts.woff2.enabled,true) HTTP(..) == woff2-totalsfntsize.html woff2-totalsfntsize-ref.html
 
 # sanity tests for reflow behavior with downloadable fonts
 HTTP(..) == reflow-sanity-1.html reflow-sanity-1-ref.html
 HTTP(..) == reflow-sanity-1-data.html reflow-sanity-1-ref.html
 HTTP(..) == reflow-sanity-1.html reflow-sanity-1-data.html
 HTTP(..) == reflow-sanity-delay-1a.html reflow-sanity-1-ref.html
 HTTP(..) == reflow-sanity-delay-1b.html reflow-sanity-1-ref.html
 HTTP(..) == reflow-sanity-delay-1c.html reflow-sanity-1-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/font-face/woff2-totalsfntsize-ref.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "webfont";
+    src: url("../fonts/header-totalsfntsize-001.ttf") format("truetype");
+}
+#container {
+	width: 100px;
+	height: 38px;
+	position: relative;
+    overflow: hidden;
+}
+#test {
+    font: 41px "webfont";
+    position: absolute;
+    width: 41px;
+    height: 41px;
+    left: -1px;
+    top: -1px;
+}
+</style>
+</head>
+<body>
+This test makes sure WOFF2 renders as expected. The test passes if you see the word PASS below.
+<div id="container"><div id="test">P</div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/font-face/woff2-totalsfntsize.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "webfont";
+    src: url("../fonts/header-totalsfntsize-001.woff2") format("woff2");
+}
+#container {
+	width: 100px;
+	height: 38px;
+	position: relative;
+    overflow: hidden;
+}
+#test {
+    font: 41px "webfont";
+    position: absolute;
+    width: 41px;
+    height: 41px;
+    left: -1px;
+    top: -1px;
+}
+</style>
+</head>
+<body>
+This test makes sure WOFF2 renders as expected. The test passes if you see the word PASS below.
+<div id="container"><div id="test">P</div></div>
+</body>
+</html>
new file mode 100644
index 0000000000000000000000000000000000000000..a5aaab21ad4a13deaf646d309b8e1bab2c317905
GIT binary patch
literal 1856
zc$~FWZ%i9y7=P}1cfAG#oU|JL9&v6_p(~9r{%N8c9SN+xj7q18)&hlAXs?t)$kIhv
zvSkd7Q$Mg&mbmCLbwNKYvc(kL7w13x;50ENs~L%#CX3S;=X=cy*5}$A7KaI6d@t|4
zzu)uzp67k;z31L@x!o=>!6X=<WS7GsO<!rr0KgmoYjt(+upc}*c?$6o+MeqR`6BQ>
za|OUqi~M@P@9SruTz(CJD@EQIKtn-VRFHQe-x>(TChq+XK0_WsUJ~+6M1YeKa+7!y
z!oHCIq2Io^iu@?9F&j}vW0?zJ2QW%FFEPMzz%Wdy$K`Oi{i88Vux_7!aBSEY)$BED
zF{tINT47KtxnE~00mQlVA)biEv+BYYQhYZU7{+q{gPOaf`Agap>H*dnok}$18wL!D
z9kxR~a4Z5Accqtky{PDc^cl;$q<|-0;Vi}Bm_UPRnWsq{S7m->#6qUXQ8G;$=`^vB
zbEIkI4WUA?ugYdMK|1KXI!C7jdKEdDO3R2>9CW|=Q#!%ZLZL`ftH>oYsasAFBQZ9l
zXk9h^Fn)d2Zi|z}#5QtXNEg!c<~Vsf(P5;orXBnX0##P7@s8*-id=pqPG%D$LPuc!
z^6BaYBJw0Id{0Ms^+vkWtV|v`d~nP=|7bZau{}{!`*A1P?yM$TJnwkh%39n{wQOzt
znzS9LiqlsT!l{=}Bu-v9JMc?6vHX-G;txY#(Z|27riF{oFMLyW`J-g&+R_eMaH1+f
z#)ZFrr+sEx@O0P1Rn01-gd52&T2M`vE}99@Pk1^aRPZmV-v2R!qL~>XeW(;)ylKF!
zl@))BISxG5(lK^F^3L4IJPUS4tJwU;<P)b7_A?hj0-3#;5wO00#`4oO%pdGc$Wm+u
zy;tb|UC5X$=fH-eh!>kxJ3!84{y~}LOfqvWZ&d*jcsD`Enr&T1|JgRD+FWBduo?6<
zus`zSV@Ypu+bz+c?FYc;mG`}s9cvDELx1K^agM!|^|&1eeX{#!G6D2Mzc_bCww$(?
zTGtdJMHS$Az-8x(;5}W>z+G!k%7PIYqvuuyr8?&FG(7I2UB?340|#_0f(2gE-VkR(
zOBuYWV;0w1)Ug5D;7c8Iu#GY5n1|y`osNY(y9l++;=02_KTzteHk++gtEAQq&Z{1O
zbTp`hrJPFcmTa~h3@EWaB|NT8SQ~b>hI~VQB{pCk4))s7Vy|y%Zjg4j_q2Dp<h|`q
z_XeRo{$7U?j*UtlB{~!g4@!HY%2)(E;KI^#U;(<p52Fx6v@2`bhkOvmU>JN5#k0<e
zrK?@7-~<K2INQ4BecLzZS@$pB&8d2jMR7iujV`TQQHE}`XgJ>*KxGX2vik8g4=Xgl
zPMi&4)FF(iX$H_bjFEe>0CE~Ts+*u0wG!-xc3iz3KT{X3v=@;RbM>HaFXpL5k6~UC
fS`^H12;+n?ZwdAwQ!xKX?t8$N`9S+G-P!&I`2)L+
new file mode 100644
index 0000000000000000000000000000000000000000..738560518b34a9090222230815575e71756230cc
GIT binary patch
literal 980
zc$@*$11tP@Pew9NR8&s@00Yzj2><{9004mi00WEw0000000000000000000000000
z0000Dgf0eP0D)!!HUcCA5CjGVg%<}P8=3}DlnPEl_H)6u)xc&ELg)p9K_XKMSLjZ*
zqB!^=9-hA+b?$qAs*(pQZ7k9tHmrfy7E6b0Xfrp~wwI1xUwu^~{7{Qx7CI$CYuxu<
z#qJ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W0`(o7ZLI7qpuDq#n<EbR|I#7}0002A
CXU7Bp
--- a/modules/woff2/README.mozilla
+++ b/modules/woff2/README.mozilla
@@ -6,16 +6,16 @@ Upstream code can be viewed at
 
 and cloned by
   git clone https://github.com/google/woff2
 
 The in-tree copy is updated by running
   sh update.sh
 from within the modules/woff2 directory.
 
-Current version: [commit afbecce5ff16faf92ce637eab991810f5b66f803].
+Current version: [commit 63b8fb6d0d797f04e77ee825fd8fcf7ea6205aac].
 
 redefine-unique_ptr.patch redefines the class std::unique_ptr to workaround a
 build issue with missing C++11 features.
 See https://bugzilla.mozilla.org/show_bug.cgi?id=1227058
 
 missing-assert-header.patch contains the upstream change from commit
 07cd303dd2959cbf69a6840706c0896e49e42677 adding the missing assert.h header.
--- a/modules/woff2/src/woff2_dec.cc
+++ b/modules/woff2/src/woff2_dec.cc
@@ -927,17 +927,20 @@ bool ReconstructFont(uint8_t* transforme
             return FONT_COMPRESSION_FAILURE();
           }
           // checkSumAdjustment = 0
           StoreU32(transformed_buf + table.src_offset, 8, 0);
         }
         table.dst_offset = dest_offset;
         checksum = ComputeULongSum(transformed_buf + table.src_offset,
                                    table.src_length);
-        out->Write(transformed_buf + table.src_offset, table.src_length);
+        if (PREDICT_FALSE(!out->Write(transformed_buf + table.src_offset,
+            table.src_length))) {
+          return FONT_COMPRESSION_FAILURE();
+        }
       } else {
         if (table.tag == kGlyfTableTag) {
           table.dst_offset = dest_offset;
 
           Table* loca_table = FindTable(&tables, kLocaTableTag);
           if (PREDICT_FALSE(!ReconstructGlyf(transformed_buf + table.src_offset,
               &table, &checksum, loca_table, &loca_checksum, info, out))) {
             return FONT_COMPRESSION_FAILURE();
--- a/modules/woff2/src/woff2_dec.h
+++ b/modules/woff2/src/woff2_dec.h
@@ -24,19 +24,21 @@
 namespace woff2 {
 
 // Compute the size of the final uncompressed font, or 0 on error.
 size_t ComputeWOFF2FinalSize(const uint8_t *data, size_t length);
 
 // Decompresses the font into the target buffer. The result_length should
 // be the same as determined by ComputeFinalSize(). Returns true on successful
 // decompression.
+// DEPRECATED; please prefer the version that takes a WOFF2Out*
 bool ConvertWOFF2ToTTF(uint8_t *result, size_t result_length,
                        const uint8_t *data, size_t length);
 
 // Decompresses the font into out. Returns true on success.
 // Works even if WOFF2Header totalSfntSize is wrong.
+// Please prefer this API.
 bool ConvertWOFF2ToTTF(const uint8_t *data, size_t length,
                        WOFF2Out* out);
 
 } // namespace woff2
 
 #endif  // WOFF2_WOFF2_DEC_H_