Index: src/gasp.cc |
diff --git a/src/gasp.cc b/src/gasp.cc |
old mode 100644 |
new mode 100755 |
index fcabac81ea7c06bf46d0558761cf501123eb757b..91e19e4f15e48ba58a64a9a73efc8740f067b60c |
--- a/src/gasp.cc |
+++ b/src/gasp.cc |
@@ -5,10 +5,17 @@ |
#include "gasp.h" |
// gasp - Grid-fitting And Scan-conversion Procedure |
-// http://www.microsoft.com/opentype/otspec/gasp.htm |
+// http://www.microsoft.com/typography/otspec/gasp.htm |
-#define DROP_THIS_TABLE \ |
- do { delete file->gasp; file->gasp = 0; } while (0) |
+#define TABLE_NAME "gasp" |
+ |
+#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) |
namespace ots { |
@@ -21,19 +28,17 @@ bool ots_gasp_parse(OpenTypeFile *file, const uint8_t *data, size_t length) { |
uint16_t num_ranges = 0; |
if (!table.ReadU16(&gasp->version) || |
!table.ReadU16(&num_ranges)) { |
- return OTS_FAILURE(); |
+ return OTS_FAILURE_MSG("Failed to read table header"); |
} |
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; |
} |
@@ -43,20 +48,18 @@ bool ots_gasp_parse(OpenTypeFile *file, const uint8_t *data, size_t length) { |
uint16_t behavior = 0; |
if (!table.ReadU16(&max_ppem) || |
!table.ReadU16(&behavior)) { |
- return OTS_FAILURE(); |
+ return OTS_FAILURE_MSG("Failed to read subrange %d", i); |
} |
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; |
} |
@@ -88,13 +91,13 @@ bool ots_gasp_serialise(OTSStream *out, OpenTypeFile *file) { |
if (num_ranges != gasp->gasp_ranges.size() || |
!out->WriteU16(gasp->version) || |
!out->WriteU16(num_ranges)) { |
- return OTS_FAILURE(); |
+ return OTS_FAILURE_MSG("failed to write gasp header"); |
} |
for (uint16_t i = 0; i < num_ranges; ++i) { |
if (!out->WriteU16(gasp->gasp_ranges[i].first) || |
!out->WriteU16(gasp->gasp_ranges[i].second)) { |
- return OTS_FAILURE(); |
+ return OTS_FAILURE_MSG("Failed to write gasp subtable %d", i); |
} |
} |
@@ -106,3 +109,6 @@ void ots_gasp_free(OpenTypeFile *file) { |
} |
} // namespace ots |
+ |
+#undef TABLE_NAME |
+#undef DROP_THIS_TABLE |