| Index: src/loca.cc
|
| diff --git a/src/loca.cc b/src/loca.cc
|
| old mode 100644
|
| new mode 100755
|
| index ad74b267354d3f6d9e41517831b5fe3a364920d5..4b291f028c0848dacbaec63c68db5da5d11bcd40
|
| --- a/src/loca.cc
|
| +++ b/src/loca.cc
|
| @@ -8,7 +8,9 @@
|
| #include "maxp.h"
|
|
|
| // loca - Index to Location
|
| -// http://www.microsoft.com/opentype/otspec/loca.htm
|
| +// http://www.microsoft.com/typography/otspec/loca.htm
|
| +
|
| +#define TABLE_NAME "loca"
|
|
|
| namespace ots {
|
|
|
| @@ -22,7 +24,7 @@ bool ots_loca_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
|
| file->loca = loca;
|
|
|
| if (!file->maxp || !file->head) {
|
| - return OTS_FAILURE();
|
| + return OTS_FAILURE_MSG("maxp or head tables missing from font, needed by loca");
|
| }
|
|
|
| const unsigned num_glyphs = file->maxp->num_glyphs;
|
| @@ -37,10 +39,10 @@ bool ots_loca_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
|
| for (unsigned i = 0; i <= num_glyphs; ++i) {
|
| uint16_t offset = 0;
|
| if (!table.ReadU16(&offset)) {
|
| - return OTS_FAILURE();
|
| + return OTS_FAILURE_MSG("Failed to read offset for glyph %d", i);
|
| }
|
| if (offset < last_offset) {
|
| - return OTS_FAILURE();
|
| + return OTS_FAILURE_MSG("Out of order offset %d < %d for glyph %d", offset, last_offset, i);
|
| }
|
| last_offset = offset;
|
| loca->offsets[i] = offset * 2;
|
| @@ -49,10 +51,10 @@ bool ots_loca_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
|
| for (unsigned i = 0; i <= num_glyphs; ++i) {
|
| uint32_t offset = 0;
|
| if (!table.ReadU32(&offset)) {
|
| - return OTS_FAILURE();
|
| + return OTS_FAILURE_MSG("Failed to read offset for glyph %d", i);
|
| }
|
| if (offset < last_offset) {
|
| - return OTS_FAILURE();
|
| + return OTS_FAILURE_MSG("Out of order offset %d < %d for glyph %d", offset, last_offset, i);
|
| }
|
| last_offset = offset;
|
| loca->offsets[i] = offset;
|
| @@ -71,7 +73,7 @@ bool ots_loca_serialise(OTSStream *out, OpenTypeFile *file) {
|
| const OpenTypeHEAD *head = file->head;
|
|
|
| if (!head) {
|
| - return OTS_FAILURE();
|
| + return OTS_FAILURE_MSG("Missing head table in font needed by loca");
|
| }
|
|
|
| if (head->index_to_loc_format == 0) {
|
| @@ -79,13 +81,13 @@ bool ots_loca_serialise(OTSStream *out, OpenTypeFile *file) {
|
| const uint16_t offset = static_cast<uint16_t>(loca->offsets[i] >> 1);
|
| if ((offset != (loca->offsets[i] >> 1)) ||
|
| !out->WriteU16(offset)) {
|
| - return OTS_FAILURE();
|
| + return OTS_FAILURE_MSG("Failed to write glyph offset for glyph %d", i);
|
| }
|
| }
|
| } else {
|
| for (unsigned i = 0; i < loca->offsets.size(); ++i) {
|
| if (!out->WriteU32(loca->offsets[i])) {
|
| - return OTS_FAILURE();
|
| + return OTS_FAILURE_MSG("Failed to write glyph offset for glyph %d", i);
|
| }
|
| }
|
| }
|
| @@ -98,3 +100,5 @@ void ots_loca_free(OpenTypeFile *file) {
|
| }
|
|
|
| } // namespace ots
|
| +
|
| +#undef TABLE_NAME
|
|
|