Bug 1922381 - Update OTS to version 9.2.0. r=jfkthame

Differential Revision: https://phabricator.services.mozilla.com/D224378
This commit is contained in:
Ryan VanderMeulen 2024-10-08 16:15:43 +00:00
parent 268b242534
commit 11297ee846
5 changed files with 83 additions and 14 deletions

View File

@ -10,8 +10,8 @@ origin:
url: https://github.com/khaledhosny/ots
release: 27d63ae4d8988619e0a661bf40551c47da47f3fa (2024-07-22T18:00:27Z).
revision: 27d63ae4d8988619e0a661bf40551c47da47f3fa
release: f31e5827277fc4f8af4025e0a951c7cf77e647b2 (2024-10-02T19:09:36Z).
revision: f31e5827277fc4f8af4025e0a951c7cf77e647b2
license: BSD-3-Clause
license-file: LICENSE

View File

@ -1,7 +1,10 @@
diff --git a/src/glat.cc b/src/glat.cc
--- a/src/glat.cc
+++ b/src/glat.cc
@@ -4,9 +4,9 @@
@@ -1,16 +1,16 @@
// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "glat.h"
@ -12,7 +15,15 @@ diff --git a/src/glat.cc b/src/glat.cc
#include <memory>
namespace ots {
@@ -214,16 +214,17 @@ bool OpenTypeGLAT_v3::Parse(const uint8_
// -----------------------------------------------------------------------------
// OpenTypeGLAT_v1
// -----------------------------------------------------------------------------
@@ -212,24 +212,25 @@ bool OpenTypeGLAT_v3::Parse(const uint8_
}
// decompressed table must be <= OTS_MAX_DECOMPRESSED_TABLE_SIZE
if (decompressed_size > OTS_MAX_DECOMPRESSED_TABLE_SIZE) {
return DropGraphite("Decompressed size exceeds %gMB: %gMB",
OTS_MAX_DECOMPRESSED_TABLE_SIZE / (1024.0 * 1024.0),
decompressed_size / (1024.0 * 1024.0));
}
@ -35,10 +46,17 @@ diff --git a/src/glat.cc b/src/glat.cc
return this->Parse(decompressed.get(), decompressed_size, true);
}
default:
return DropGraphite("Unknown compression scheme");
}
if (this->compHead & RESERVED) {
Warning("Nonzero reserved");
diff --git a/src/silf.cc b/src/silf.cc
--- a/src/silf.cc
+++ b/src/silf.cc
@@ -4,9 +4,9 @@
@@ -1,16 +1,16 @@
// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "silf.h"
@ -49,7 +67,15 @@ diff --git a/src/silf.cc b/src/silf.cc
#include <memory>
namespace ots {
@@ -49,16 +49,17 @@ bool OpenTypeSILF::Parse(const uint8_t*
bool OpenTypeSILF::Parse(const uint8_t* data, size_t length,
bool prevent_decompression) {
Buffer table(data, length);
@@ -45,24 +45,25 @@ bool OpenTypeSILF::Parse(const uint8_t*
}
// decompressed table must be <= OTS_MAX_DECOMPRESSED_TABLE_SIZE
if (decompressed_size > OTS_MAX_DECOMPRESSED_TABLE_SIZE) {
return DropGraphite("Decompressed size exceeds %gMB: %gMB",
OTS_MAX_DECOMPRESSED_TABLE_SIZE / (1024.0 * 1024.0),
decompressed_size / (1024.0 * 1024.0));
}
@ -72,3 +98,7 @@ diff --git a/src/silf.cc b/src/silf.cc
return this->Parse(decompressed.get(), decompressed_size, true);
}
default:
return DropGraphite("Unknown compression scheme");
}
}
if (!table.ReadU16(&this->numSub)) {

View File

@ -1,7 +1,12 @@
diff --git a/src/ots.cc b/src/ots.cc
--- a/src/ots.cc
+++ b/src/ots.cc
@@ -14,7 +14,7 @@
@@ -9,17 +9,17 @@
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
@ -10,7 +15,17 @@ diff --git a/src/ots.cc b/src/ots.cc
// The OpenType Font File
// http://www.microsoft.com/typography/otspec/otff.htm
@@ -511,43 +511,9 @@ bool ProcessWOFF(ots::FontFile *header,
#include "avar.h"
#include "cff.h"
#include "cmap.h"
#include "colr.h"
@@ -513,54 +513,19 @@ bool ProcessWOFF(ots::FontFile *header,
}
if (block_end != ots::Round4(length)) {
return OTS_FAILURE_MSG_HDR("File length mismatch (trailing junk?)");
}
return ProcessGeneric(header, font, woff_tag, output, data, length, tables, file);
}
@ -40,6 +55,7 @@ diff --git a/src/ots.cc b/src/ots.cc
-
- std::string buf(decompressed_size, 0);
- woff2::WOFF2StringOut out(&buf);
- out.SetMaxSize(decompressed_size);
- if (!woff2::ConvertWOFF2ToTTF(data, length, &out)) {
- return OTS_FAILURE_MSG_HDR("Failed to convert WOFF 2.0 font to SFNT");
- }
@ -57,4 +73,8 @@ diff --git a/src/ots.cc b/src/ots.cc
}
ots::TableAction GetTableAction(const ots::FontFile *header, uint32_t tag) {
ots::TableAction action = header->context->GetTableAction(tag);
if (action == ots::TABLE_ACTION_DEFAULT) {
action = ots::TABLE_ACTION_DROP;

View File

@ -1,7 +1,10 @@
diff --git a/include/opentype-sanitiser.h b/include/opentype-sanitiser.h
--- a/include/opentype-sanitiser.h
+++ b/include/opentype-sanitiser.h
@@ -4,8 +4,28 @@
@@ -1,15 +1,35 @@
// Copyright (c) 2009-2017 The OTS 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 OPENTYPE_SANITISER_H_
#define OPENTYPE_SANITISER_H_
@ -30,7 +33,15 @@ diff --git a/include/opentype-sanitiser.h b/include/opentype-sanitiser.h
#include <stdlib.h>
typedef signed char int8_t;
typedef unsigned char uint8_t;
@@ -164,9 +184,9 @@ enum TableAction {
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
@@ -170,17 +190,17 @@ class OTSStream {
enum TableAction {
TABLE_ACTION_DEFAULT, // Use OTS's default action for that table
TABLE_ACTION_SANITIZE, // Sanitize the table, potentially dropping it
TABLE_ACTION_PASSTHRU, // Serialize the table unchanged
TABLE_ACTION_DROP // Drop the table
};
@ -41,3 +52,7 @@ diff --git a/include/opentype-sanitiser.h b/include/opentype-sanitiser.h
OTSContext() {}
virtual ~OTSContext() {}
// Process a given OpenType file and write out a sanitized 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.

View File

@ -1145,13 +1145,17 @@ bool ParseConditionTable(const ots::Font *font,
return OTS_FAILURE_MSG("Axis index out of range in condition");
}
// Check min/max values are within range -1.0 .. 1.0 and properly ordered
// Check min/max values are within range -1.0 .. 1.0.
if (filter_range_min_value < -0x4000 || // -1.0 in F2DOT14 format
filter_range_max_value > 0x4000 || // +1.0 in F2DOT14 format
filter_range_min_value > filter_range_max_value) {
filter_range_max_value > 0x4000) { // +1.0 in F2DOT14 format
return OTS_FAILURE_MSG("Invalid filter range in condition");
}
// Warn if range is improperly ordered (and therefore useless).
if (filter_range_min_value > filter_range_max_value) {
OTS_WARNING("Misordered filter range in condition table");
}
return true;
}