Bug 1057488 - Part 4: Update OTS to 5c25bdac8f02080f49fa416ea997ed77e3be0d30. r=jfkthame

--HG--
extra : rebase_source : c78868d91c35ba3f7cf427740d19cfc775df8cc2
This commit is contained in:
Frédéric Wang 2014-08-24 09:52:00 -04:00
parent 3ca9ad3ae3
commit 505ee6f85b
18 changed files with 91 additions and 166 deletions

View File

@ -2,7 +2,7 @@ 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: 97d043dd8977751835ca8d33d773ae8416e456d5
Current revision: 5c25bdac8f02080f49fa416ea997ed77e3be0d30
Upstream files included: LICENSE, src/, include/

View File

@ -708,7 +708,7 @@ bool ExecuteType2CharStringOperator(int32_t op,
return true;
}
OTS_WARNING("Undefined operator: %d (0x%x)", op, op);
//OTS_WARNING("Undefined operator: %d (0x%x)", op, op);
return OTS_FAILURE();
}

View File

@ -748,6 +748,7 @@ bool ots_cmap_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
// the UCS-4 table for non-BMP glyphs. We'll pass the following subtables:
// Platform ID Encoding ID Format
// 0 0 4 (Unicode Default)
// 0 1 4 (Unicode 1.1)
// 0 3 4 (Unicode BMP)
// 0 3 12 (Unicode UCS-4)
// 0 5 14 (Unicode Variation Sequences)
@ -758,8 +759,8 @@ bool ots_cmap_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
// 3 10 13 (MS UCS-4 Fallback mapping)
//
// Note:
// * 0-0-4 table is (usually) written as a 3-1-4 table. If 3-1-4 table
// also exists, the 0-0-4 table is ignored.
// * 0-0-4 and 0-1-4 tables are (usually) written as a 3-1-4 table. If 3-1-4 table
// also exists, the 0-0-4 or 0-1-4 tables are ignored.
// * Unlike 0-0-4 table, 0-3-4 table is written as a 0-3-4 table.
// Some fonts which include 0-5-14 table seems to be required 0-3-4
// table. The 0-3-4 table will be wriiten even if 3-1-4 table also exists.
@ -771,9 +772,9 @@ bool ots_cmap_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
if (subtable_headers[i].platform == 0) {
// Unicode platform
if ((subtable_headers[i].encoding == 0) &&
if ((subtable_headers[i].encoding == 0 || subtable_headers[i].encoding == 1) &&
(subtable_headers[i].format == 4)) {
// parse and output the 0-0-4 table as 3-1-4 table. Sometimes the 0-0-4
// parse and output the 0-0-4 and 0-1-4 tables as 3-1-4 table. Sometimes the 0-0-4
// table actually points to MS symbol data and thus should be parsed as
// 3-0-4 table (e.g., marqueem.ttf and quixotic.ttf). This error will be
// recovered in ots_cmap_serialise().
@ -877,7 +878,7 @@ bool ots_cmap_serialise(OTSStream *out, OpenTypeFile *file) {
// Some fonts don't have 3-0-4 MS Symbol nor 3-1-4 Unicode BMP tables
// (e.g., old fonts for Mac). We don't support them.
if (!have_304 && !have_314 && !have_034 && !have_31012 && !have_31013) {
return OTS_FAILURE();
return OTS_FAILURE_MSG("no supported subtables were found");
}
if (!out->WriteU16(0) ||

View File

@ -38,7 +38,7 @@ bool ots_cvt_should_serialise(OpenTypeFile *file) {
if (!file->glyf) {
return false; // this table is not for CFF fonts.
}
return g_transcode_hints && file->cvt;
return file->cvt;
}
bool ots_cvt_serialise(OTSStream *out, OpenTypeFile *file) {

View File

@ -32,7 +32,7 @@ bool ots_fpgm_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
bool ots_fpgm_should_serialise(OpenTypeFile *file) {
if (!file->glyf) return false; // this table is not for CFF fonts.
return g_transcode_hints && file->fpgm;
return file->fpgm;
}
bool ots_fpgm_serialise(OTSStream *out, OpenTypeFile *file) {

View File

@ -9,10 +9,11 @@
#define TABLE_NAME "gasp"
#define DROP_THIS_TABLE \
#define DROP_THIS_TABLE(...) \
do { \
delete file->gasp; \
file->gasp = 0; \
OTS_FAILURE_MSG_(file, TABLE_NAME ": " __VA_ARGS__); \
OTS_FAILURE_MSG("Table discarded"); \
} while (0)
@ -32,14 +33,12 @@ bool ots_gasp_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
if (gasp->version > 1) {
// Lots of Linux fonts have bad version numbers...
OTS_WARNING("bad version: %u", gasp->version);
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad version: %u", gasp->version);
return true;
}
if (num_ranges == 0) {
OTS_WARNING("num_ranges is zero");
DROP_THIS_TABLE;
DROP_THIS_TABLE("num_ranges is zero");
return true;
}
@ -54,15 +53,13 @@ bool ots_gasp_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
if ((i > 0) && (gasp->gasp_ranges[i - 1].first >= max_ppem)) {
// The records in the gaspRange[] array must be sorted in order of
// increasing rangeMaxPPEM value.
OTS_WARNING("ranges are not sorted");
DROP_THIS_TABLE;
DROP_THIS_TABLE("ranges are not sorted");
return true;
}
if ((i == num_ranges - 1u) && // never underflow.
(max_ppem != 0xffffu)) {
OTS_WARNING("The last record should be 0xFFFF as a sentinel value "
DROP_THIS_TABLE("The last record should be 0xFFFF as a sentinel value "
"for rangeMaxPPEM");
DROP_THIS_TABLE;
return true;
}

View File

@ -112,19 +112,9 @@ bool ParseSimpleGlyph(ots::OpenTypeFile *file, const uint8_t *data,
return OTS_FAILURE_MSG("Glyph header length too high %d", gly_header_length);
}
if (ots::g_transcode_hints) {
glyf->iov.push_back(std::make_pair(
data + gly_offset,
static_cast<size_t>(gly_header_length + bytecode_length)));
} else {
// enqueue two vectors: the glyph data up to the bytecode length, then
// a pointer to a static uint16_t 0 to overwrite the length.
glyf->iov.push_back(std::make_pair(
data + gly_offset,
static_cast<size_t>(gly_header_length - 2)));
glyf->iov.push_back(std::make_pair((const uint8_t*) "\x00\x00",
static_cast<size_t>(2)));
}
glyf->iov.push_back(std::make_pair(
data + gly_offset,
static_cast<size_t>(gly_header_length + bytecode_length)));
if (!table->Skip(bytecode_length)) {
return OTS_FAILURE_MSG("Can't skip bytecode of length %d", bytecode_length);
@ -163,10 +153,7 @@ bool ParseSimpleGlyph(ots::OpenTypeFile *file, const uint8_t *data,
static_cast<size_t>(flags_count_physical + xy_coordinates_length)));
*new_size
= gly_header_length + flags_count_physical + xy_coordinates_length;
if (ots::g_transcode_hints) {
*new_size += bytecode_length;
}
= gly_header_length + flags_count_physical + xy_coordinates_length + bytecode_length;
return true;
}

View File

@ -11,10 +11,11 @@
#define TABLE_NAME "hdmx"
#define DROP_THIS_TABLE \
#define DROP_THIS_TABLE(...) \
do { \
delete file->hdmx; \
file->hdmx = 0; \
OTS_FAILURE_MSG_(file, TABLE_NAME ": " __VA_ARGS__); \
OTS_FAILURE_MSG("Table discarded"); \
} while (0)
@ -31,9 +32,8 @@ bool ots_hdmx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
if ((file->head->flags & 0x14) == 0) {
// http://www.microsoft.com/typography/otspec/recom.htm
OTS_WARNING("the table should not be present when bit 2 and 4 of the "
"head->flags are not set");
DROP_THIS_TABLE;
DROP_THIS_TABLE("the table should not be present when bit 2 and 4 of the "
"head->flags are not set");
return true;
}
@ -44,19 +44,16 @@ bool ots_hdmx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
return OTS_FAILURE_MSG("Failed to read hdmx header");
}
if (hdmx->version != 0) {
OTS_WARNING("bad version: %u", hdmx->version);
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad version: %u", hdmx->version);
return true;
}
if (num_recs <= 0) {
OTS_WARNING("bad num_recs: %d", num_recs);
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad num_recs: %d", num_recs);
return true;
}
const int32_t actual_size_device_record = file->maxp->num_glyphs + 2;
if (hdmx->size_device_record < actual_size_device_record) {
OTS_WARNING("bad hdmx->size_device_record: %d", hdmx->size_device_record);
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad hdmx->size_device_record: %d", hdmx->size_device_record);
return true;
}
@ -76,8 +73,7 @@ bool ots_hdmx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
}
if ((i != 0) &&
(rec.pixel_size <= last_pixel_size)) {
OTS_WARNING("records are not sorted");
DROP_THIS_TABLE;
DROP_THIS_TABLE("records are not sorted");
return true;
}
last_pixel_size = rec.pixel_size;

View File

@ -9,11 +9,11 @@
#define TABLE_NAME "kern"
#define DROP_THIS_TABLE \
#define DROP_THIS_TABLE(msg_) \
do { \
delete file->kern; \
file->kern = 0; \
OTS_FAILURE_MSG("Table discarded"); \
OTS_FAILURE_MSG(msg_ ", table discarded"); \
} while (0)
namespace ots {
@ -31,13 +31,12 @@ bool ots_kern_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
}
if (kern->version > 0) {
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad table version");
return true;
}
if (num_tables == 0) {
OTS_WARNING("num_tables is zero");
DROP_THIS_TABLE;
DROP_THIS_TABLE("num_tables is zero");
return true;
}
@ -71,8 +70,7 @@ bool ots_kern_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
continue;
}
if (subtable.coverage & 0xF0) {
OTS_WARNING("Reserved fields should zero-filled.");
DROP_THIS_TABLE;
DROP_THIS_TABLE("Reserved fields should zero-filled.");
return true;
}
const uint32_t format = (subtable.coverage & 0xFF00) >> 8;
@ -91,8 +89,7 @@ bool ots_kern_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
}
if (!num_pairs) {
OTS_WARNING("Zero length subtable is found.");
DROP_THIS_TABLE;
DROP_THIS_TABLE("Zero length subtable is found.");
return true;
}
@ -101,8 +98,7 @@ bool ots_kern_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
const size_t kFormat0PairSize = 6; // left, right, and value. 2 bytes each.
if (num_pairs > (65536 / kFormat0PairSize)) {
// Some fonts (e.g. calibri.ttf, pykes_peak_zero.ttf) have pairs >= 10923.
OTS_WARNING("Too large subtable.");
DROP_THIS_TABLE;
DROP_THIS_TABLE("Too large subtable.");
return true;
}
unsigned max_pow2 = 0;
@ -137,10 +133,9 @@ bool ots_kern_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
const uint32_t current_pair
= (kerning_pair.left << 16) + kerning_pair.right;
if (j != 0 && current_pair <= last_pair) {
OTS_WARNING("Kerning pairs are not sorted.");
// Many free fonts don't follow this rule, so we don't call OTS_FAILURE
// in order to support these fonts.
DROP_THIS_TABLE;
DROP_THIS_TABLE("Kerning pairs are not sorted.");
return true;
}
last_pair = current_pair;
@ -151,8 +146,7 @@ bool ots_kern_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
}
if (!kern->subtables.size()) {
OTS_WARNING("All subtables are removed.");
DROP_THIS_TABLE;
DROP_THIS_TABLE("All subtables are removed.");
return true;
}

View File

@ -270,7 +270,6 @@ bool ParseClassDefFormat1(const ots::OpenTypeFile *file,
return OTS_FAILURE_MSG("Failed to read starting glyph of class definition");
}
if (start_glyph > num_glyphs) {
OTS_WARNING("bad start glyph ID: %u", start_glyph);
return OTS_FAILURE_MSG("Bad starting glyph %d in class definition", start_glyph);
}
@ -287,7 +286,6 @@ bool ParseClassDefFormat1(const ots::OpenTypeFile *file,
return OTS_FAILURE_MSG("Failed to read class value for glyph %d in class definition", i);
}
if (class_value > num_classes) {
OTS_WARNING("bad class value: %u", class_value);
return OTS_FAILURE_MSG("Bad class value %d for glyph %d in class definition", class_value, i);
}
}

View File

@ -11,10 +11,11 @@
#define TABLE_NAME "LTSH"
#define DROP_THIS_TABLE \
#define DROP_THIS_TABLE(...) \
do { \
delete file->ltsh; \
file->ltsh = 0; \
OTS_FAILURE_MSG_(file, TABLE_NAME ": " __VA_ARGS__); \
OTS_FAILURE_MSG("Table discarded"); \
} while (0)
@ -37,14 +38,12 @@ bool ots_ltsh_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
}
if (ltsh->version != 0) {
OTS_WARNING("bad version: %u", ltsh->version);
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad version: %u", ltsh->version);
return true;
}
if (num_glyphs != file->maxp->num_glyphs) {
OTS_WARNING("bad num_glyphs: %u", num_glyphs);
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad num_glyphs: %u", num_glyphs);
return true;
}

View File

@ -384,12 +384,10 @@ bool ParseGlyphAssemblyTable(const ots::OpenTypeFile *file,
return OTS_FAILURE();
}
if (glyph >= num_glyphs) {
OTS_WARNING("bad glyph ID: %u", glyph);
return OTS_FAILURE();
return OTS_FAILURE_MSG("bad glyph ID: %u", glyph);
}
if (part_flags & ~0x00000001) {
OTS_WARNING("unknown part flag: %u", part_flags);
return OTS_FAILURE();
return OTS_FAILURE_MSG("unknown part flag: %u", part_flags);
}
}
@ -435,8 +433,7 @@ bool ParseMathGlyphConstructionTable(const ots::OpenTypeFile *file,
return OTS_FAILURE();
}
if (glyph >= num_glyphs) {
OTS_WARNING("bad glyph ID: %u", glyph);
return OTS_FAILURE();
return OTS_FAILURE_MSG("bad glyph ID: %u", glyph);
}
}
@ -519,8 +516,12 @@ bool ParseMathVariantsTable(const ots::OpenTypeFile *file,
} // namespace
#define DROP_THIS_TABLE \
do { file->math->data = 0; file->math->length = 0; } while (0)
#define DROP_THIS_TABLE(msg_) \
do { \
file->math->data = 0; \
file->math->length = 0; \
OTS_FAILURE_MSG(msg_ ", table discarded"); \
} while (0)
namespace ots {
@ -542,8 +543,7 @@ bool ots_math_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
return OTS_FAILURE();
}
if (version != 0x00010000) {
OTS_WARNING("bad MATH version");
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad MATH version");
return true;
}
@ -562,24 +562,23 @@ bool ots_math_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
offset_math_glyph_info < kMathHeaderSize ||
offset_math_variants >= length ||
offset_math_variants < kMathHeaderSize) {
OTS_WARNING("bad offset in MATH header");
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad offset in MATH header");
return true;
}
if (!ParseMathConstantsTable(file, data + offset_math_constants,
length - offset_math_constants)) {
DROP_THIS_TABLE;
DROP_THIS_TABLE("failed to parse MathConstants table");
return true;
}
if (!ParseMathGlyphInfoTable(file, data + offset_math_glyph_info,
length - offset_math_glyph_info, num_glyphs)) {
DROP_THIS_TABLE;
DROP_THIS_TABLE("failed to parse MathGlyphInfo table");
return true;
}
if (!ParseMathVariantsTable(file, data + offset_math_variants,
length - offset_math_variants, num_glyphs)) {
DROP_THIS_TABLE;
DROP_THIS_TABLE("failed to parse MathVariants table");
return true;
}

View File

@ -93,26 +93,14 @@ bool ots_maxp_serialise(OTSStream *out, OpenTypeFile *file) {
return OTS_FAILURE_MSG("Failed to write maxp");
}
if (g_transcode_hints) {
if (!out->WriteU16(maxp->max_zones) ||
!out->WriteU16(maxp->max_t_points) ||
!out->WriteU16(maxp->max_storage) ||
!out->WriteU16(maxp->max_fdefs) ||
!out->WriteU16(maxp->max_idefs) ||
!out->WriteU16(maxp->max_stack) ||
!out->WriteU16(maxp->max_size_glyf_instructions)) {
return OTS_FAILURE_MSG("Failed to write more maxp");
}
} else {
if (!out->WriteU16(1) || // max zones
!out->WriteU16(0) || // max twilight points
!out->WriteU16(0) || // max storage
!out->WriteU16(0) || // max function defs
!out->WriteU16(0) || // max instruction defs
!out->WriteU16(0) || // max stack elements
!out->WriteU16(0)) { // max instruction byte count
return OTS_FAILURE_MSG("Failed to write more maxp");
}
if (!out->WriteU16(maxp->max_zones) ||
!out->WriteU16(maxp->max_t_points) ||
!out->WriteU16(maxp->max_storage) ||
!out->WriteU16(maxp->max_fdefs) ||
!out->WriteU16(maxp->max_idefs) ||
!out->WriteU16(maxp->max_stack) ||
!out->WriteU16(maxp->max_size_glyf_instructions)) {
return OTS_FAILURE_MSG("Failed to write more maxp");
}
if (!out->WriteU16(maxp->max_c_components) ||

View File

@ -199,7 +199,7 @@ bool ProcessTTF(ots::OpenTypeFile *header,
// Don't call ots_failure() here since ~25% of fonts (250+ fonts) in
// http://www.princexml.com/fonts/ have unexpected search_range value.
if (header->search_range != expected_search_range) {
OTS_WARNING("bad search range");
OTS_FAILURE_MSG_HDR("bad search range");
header->search_range = expected_search_range; // Fix the value.
}
@ -214,7 +214,7 @@ bool ProcessTTF(ots::OpenTypeFile *header,
const uint32_t expected_range_shift
= 16 * header->num_tables - header->search_range;
if (header->range_shift != expected_range_shift) {
OTS_WARNING("bad range shift");
OTS_FAILURE_MSG_HDR("bad range shift");
header->range_shift = expected_range_shift; // the same as above.
}
@ -839,18 +839,6 @@ bool Failure(const char *f, int l, const char *fn) {
}
return false;
}
void Warning(const char *f, int l, const char *format, ...) {
if (g_debug_output) {
std::fprintf(stderr, "WARNING at %s:%d: ", f, l);
std::va_list va;
va_start(va, format);
std::vfprintf(stderr, format, va);
va_end(va);
std::fprintf(stderr, "\n");
std::fflush(stderr);
}
}
#endif
} // namespace ots

View File

@ -29,48 +29,33 @@ namespace ots {
bool Failure(const char *f, int l, const char *fn);
#endif
#if defined(_MSC_VER)
// MSVC supports C99 style variadic macros.
#define OTS_WARNING(format, ...)
#else
// GCC
#if defined(OTS_DEBUG)
#define OTS_WARNING(format, args...) \
ots::Warning(__FILE__, __LINE__, format, ##args)
void Warning(const char *f, int l, const char *format, ...)
__attribute__((format(printf, 3, 4)));
#else
#define OTS_WARNING(format, args...)
#endif
#endif
// All OTS_FAILURE_* macros ultimately evaluate to 'false', just like the original
// message-less OTS_FAILURE(), so that the current parser will return 'false' as
// its result (indicating a failure).
// If a message_func pointer has been provided, this will be called before returning
// the 'false' status.
#if defined(_MSC_VER) || !defined(OTS_DEBUG)
#define OTS_MESSAGE_(otf_,...) \
(otf_)->context->Message(__VA_ARGS__)
#else
#define OTS_MESSAGE_(otf_,...) \
OTS_FAILURE(), \
(otf_)->context->Message(__VA_ARGS__)
#endif
// Generate a simple message
#define OTS_FAILURE_MSG_(otf_,...) \
((otf_)->context->Message(__VA_ARGS__), false)
(OTS_MESSAGE_(otf_,__VA_ARGS__), false)
// Generate a message with an associated table tag
#define OTS_FAILURE_MSG_TAG_(otf_,msg_,tag_) \
((otf_)->context->Message("%4.4s: %s", tag_, msg_), false)
(OTS_MESSAGE_(otf_,"%4.4s: %s", tag_, msg_), false)
// Convenience macro for use in files that only handle a single table tag,
// defined as TABLE_NAME at the top of the file; the 'file' variable is
// expected to be the current OpenTypeFile pointer.
#define OTS_FAILURE_MSG(...) OTS_FAILURE_MSG_(file, TABLE_NAME ": " __VA_ARGS__)
// Define OTS_NO_TRANSCODE_HINTS (i.e., g++ -DOTS_NO_TRANSCODE_HINTS) if you
// want to omit TrueType hinting instructions and variables in glyf, fpgm, prep,
// and cvt tables.
#if defined(OTS_NO_TRANSCODE_HINTS)
const bool g_transcode_hints = false;
#else
const bool g_transcode_hints = true;
#endif
#define OTS_WARNING OTS_FAILURE_MSG
// -----------------------------------------------------------------------------
// Buffer helper class

View File

@ -32,7 +32,7 @@ bool ots_prep_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
bool ots_prep_should_serialise(OpenTypeFile *file) {
if (!file->glyf) return false; // this table is not for CFF fonts.
return g_transcode_hints && file->prep;
return file->prep;
}
bool ots_prep_serialise(OTSStream *out, OpenTypeFile *file) {

View File

@ -9,10 +9,11 @@
#define TABLE_NAME "VDMX"
#define DROP_THIS_TABLE \
#define DROP_THIS_TABLE(...) \
do { \
delete file->vdmx; \
file->vdmx = 0; \
OTS_FAILURE_MSG_(file, TABLE_NAME ": " __VA_ARGS__); \
OTS_FAILURE_MSG("Table discarded"); \
} while (0)
@ -30,8 +31,7 @@ bool ots_vdmx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
}
if (vdmx->version > 1) {
OTS_WARNING("bad version: %u", vdmx->version);
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad version: %u", vdmx->version);
return true; // continue transcoding
}
@ -47,14 +47,12 @@ bool ots_vdmx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
}
if (rec.charset > 1) {
OTS_WARNING("bad charset: %u", rec.charset);
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad charset: %u", rec.charset);
return true;
}
if (rec.y_start_ratio > rec.y_end_ratio) {
OTS_WARNING("bad y ratio");
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad y ratio");
return true;
}
@ -65,8 +63,7 @@ bool ots_vdmx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
(rec.y_start_ratio == 0) &&
(rec.y_end_ratio == 0)) {
// workaround for fonts which have 2 or more {0, 0, 0} terminators.
OTS_WARNING("superfluous terminator found");
DROP_THIS_TABLE;
DROP_THIS_TABLE("superfluous terminator found");
return true;
}
@ -105,16 +102,14 @@ bool ots_vdmx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
return OTS_FAILURE_MSG("Failed to read reacord %d group %d", i, j);
}
if (vt.y_max < vt.y_min) {
OTS_WARNING("bad y min/max");
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad y min/max");
return true;
}
// This table must appear in sorted order (sorted by yPelHeight),
// but need not be continuous.
if ((j != 0) && (group.entries[j - 1].y_pel_height >= vt.y_pel_height)) {
OTS_WARNING("the table is not sorted");
DROP_THIS_TABLE;
DROP_THIS_TABLE("the table is not sorted");
return true;
}

View File

@ -11,10 +11,11 @@
#define TABLE_NAME "VORG"
#define DROP_THIS_TABLE \
#define DROP_THIS_TABLE(...) \
do { \
delete file->vorg; \
file->vorg = 0; \
OTS_FAILURE_MSG_(file, TABLE_NAME ": " __VA_ARGS__); \
OTS_FAILURE_MSG("Table discarded"); \
} while (0)
@ -33,13 +34,11 @@ bool ots_vorg_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
return OTS_FAILURE_MSG("Failed to read header");
}
if (vorg->major_version != 1) {
OTS_WARNING("bad major version: %u", vorg->major_version);
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad major version: %u", vorg->major_version);
return true;
}
if (vorg->minor_version != 0) {
OTS_WARNING("bad minor version: %u", vorg->minor_version);
DROP_THIS_TABLE;
DROP_THIS_TABLE("bad minor version: %u", vorg->minor_version);
return true;
}
@ -58,8 +57,7 @@ bool ots_vorg_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
return OTS_FAILURE_MSG("Failed to read record %d", i);
}
if ((i != 0) && (rec.glyph_index <= last_glyph_index)) {
OTS_WARNING("the table is not sorted");
DROP_THIS_TABLE;
DROP_THIS_TABLE("the table is not sorted");
return true;
}
last_glyph_index = rec.glyph_index;