Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Unified Diff: src/os2.cc

Issue 658573004: Updating to new OTS repo from https://github.com/khaledhosny/ots.git (Closed) Base URL: https://chromium.googlesource.com/external/ots@master
Patch Set: Adding Colored Emoji changes from external/git repo Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« .gitmodules ('K') | « src/name.cc ('k') | src/ots.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/os2.cc
diff --git a/src/os2.cc b/src/os2.cc
old mode 100644
new mode 100755
index 23688ef289f3b006c41b6515adec7ce2a93351ca..915877e3b0019e8f4e60f88782cf7c8cd81baeb5
--- a/src/os2.cc
+++ b/src/os2.cc
@@ -7,7 +7,9 @@
#include "head.h"
// OS/2 - OS/2 and Windows Metrics
-// http://www.microsoft.com/opentype/otspec/os2.htm
+// http://www.microsoft.com/typography/otspec/os2.htm
+
+#define TABLE_NAME "OS/2"
namespace ots {
@@ -33,11 +35,11 @@ bool ots_os2_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
!table.ReadS16(&os2->strikeout_size) ||
!table.ReadS16(&os2->strikeout_position) ||
!table.ReadS16(&os2->family_class)) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("Failed toi read basic os2 elements");
}
if (os2->version > 4) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("os2 version too high %d", os2->version);
}
// Some linux fonts (e.g., Kedage-t.ttf and LucidaSansDemiOblique.ttf) have
@@ -94,7 +96,7 @@ bool ots_os2_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
for (unsigned i = 0; i < 10; ++i) {
if (!table.ReadU8(&os2->panose[i])) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("Failed to read panose in os2 table");
}
}
@@ -111,7 +113,7 @@ bool ots_os2_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
!table.ReadS16(&os2->typo_linegap) ||
!table.ReadU16(&os2->win_ascent) ||
!table.ReadU16(&os2->win_descent)) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("Failed to read more basic os2 fields");
}
// If bit 6 is set, then bits 0 and 5 must be clear.
@@ -122,7 +124,7 @@ bool ots_os2_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
// the settings of bits 0 and 1 must be reflected in the macStyle bits
// in the 'head' table.
if (!file->head) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("Head table missing from font as needed by os2 table");
}
if ((os2->selection & 0x1) &&
!(file->head->mac_style & 0x2)) {
@@ -146,14 +148,14 @@ bool ots_os2_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
if ((os2->version < 4) &&
(os2->selection & 0x300)) {
// bit 8 and 9 must be unset in OS/2 table versions less than 4.
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("OS2 version %d incompatible with selection %d", os2->version, os2->selection);
}
// mask reserved bits. use only 0..9 bits.
os2->selection &= 0x3ff;
if (os2->first_char_index > os2->last_char_index) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("first char index %d > last char index %d in os2", os2->first_char_index, os2->last_char_index);
}
if (os2->typo_linegap < 0) {
OTS_WARNING("bad linegap: %d", os2->typo_linegap);
@@ -175,7 +177,7 @@ bool ots_os2_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
if (!table.ReadU32(&os2->code_page_range_1) ||
!table.ReadU32(&os2->code_page_range_2)) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("Failed to read codepage ranges");
}
if (os2->version < 2) {
@@ -196,7 +198,7 @@ bool ots_os2_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
!table.ReadU16(&os2->default_char) ||
!table.ReadU16(&os2->break_char) ||
!table.ReadU16(&os2->max_context)) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("Failed to read os2 version 2 information");
}
if (os2->x_height < 0) {
@@ -234,12 +236,12 @@ bool ots_os2_serialise(OTSStream *out, OpenTypeFile *file) {
!out->WriteS16(os2->strikeout_size) ||
!out->WriteS16(os2->strikeout_position) ||
!out->WriteS16(os2->family_class)) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("Failed to write basic OS2 information");
}
for (unsigned i = 0; i < 10; ++i) {
if (!out->Write(&os2->panose[i], 1)) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("Failed to write os2 panose information");
}
}
@@ -256,7 +258,7 @@ bool ots_os2_serialise(OTSStream *out, OpenTypeFile *file) {
!out->WriteS16(os2->typo_linegap) ||
!out->WriteU16(os2->win_ascent) ||
!out->WriteU16(os2->win_descent)) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("Failed to write os2 version 1 information");
}
if (os2->version < 1) {
@@ -265,7 +267,7 @@ bool ots_os2_serialise(OTSStream *out, OpenTypeFile *file) {
if (!out->WriteU32(os2->code_page_range_1) ||
!out->WriteU32(os2->code_page_range_2)) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("Failed to write codepage ranges");
}
if (os2->version < 2) {
@@ -277,7 +279,7 @@ bool ots_os2_serialise(OTSStream *out, OpenTypeFile *file) {
!out->WriteU16(os2->default_char) ||
!out->WriteU16(os2->break_char) ||
!out->WriteU16(os2->max_context)) {
- return OTS_FAILURE();
+ return OTS_FAILURE_MSG("Failed to write os2 version 2 information");
}
return true;
@@ -288,3 +290,5 @@ void ots_os2_free(OpenTypeFile *file) {
}
} // namespace ots
+
+#undef TABLE_NAME
« .gitmodules ('K') | « src/name.cc ('k') | src/ots.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698