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

Unified Diff: third_party/ots/src/kern.cc

Issue 1252363005: Update OTS to revision a7a3b94 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « third_party/ots/src/hmtx.cc ('k') | third_party/ots/src/layout.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/ots/src/kern.cc
diff --git a/third_party/ots/src/kern.cc b/third_party/ots/src/kern.cc
index 744c057db6c19d6f44bcbd7b310b2d90922edb30..d4ae8fcc480fa30255df8f8b0e91769c55210980 100644
--- a/third_party/ots/src/kern.cc
+++ b/third_party/ots/src/kern.cc
@@ -12,17 +12,17 @@
#define DROP_THIS_TABLE(msg_) \
do { \
OTS_FAILURE_MSG(msg_ ", table discarded"); \
- delete file->kern; \
- file->kern = 0; \
+ delete font->kern; \
+ font->kern = 0; \
} while (0)
namespace ots {
-bool ots_kern_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
+bool ots_kern_parse(Font *font, const uint8_t *data, size_t length) {
Buffer table(data, length);
OpenTypeKERN *kern = new OpenTypeKERN;
- file->kern = kern;
+ font->kern = kern;
uint16_t num_tables = 0;
if (!table.ReadU16(&kern->version) ||
@@ -70,7 +70,7 @@ bool ots_kern_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
continue;
}
if (subtable.coverage & 0xF0) {
- DROP_THIS_TABLE("Reserved fields should zero-filled.");
+ DROP_THIS_TABLE("Reserved fields should zero-filled");
return true;
}
const uint32_t format = (subtable.coverage & 0xFF00) >> 8;
@@ -89,7 +89,7 @@ bool ots_kern_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
}
if (!num_pairs) {
- DROP_THIS_TABLE("Zero length subtable is found.");
+ DROP_THIS_TABLE("Zero length subtable is found");
return true;
}
@@ -98,7 +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.
- DROP_THIS_TABLE("Too large subtable.");
+ DROP_THIS_TABLE("Too large subtable");
return true;
}
unsigned max_pow2 = 0;
@@ -135,7 +135,7 @@ bool ots_kern_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
if (j != 0 && current_pair <= last_pair) {
// Many free fonts don't follow this rule, so we don't call OTS_FAILURE
// in order to support these fonts.
- DROP_THIS_TABLE("Kerning pairs are not sorted.");
+ DROP_THIS_TABLE("Kerning pairs are not sorted");
return true;
}
last_pair = current_pair;
@@ -146,20 +146,20 @@ bool ots_kern_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
}
if (!kern->subtables.size()) {
- DROP_THIS_TABLE("All subtables are removed.");
+ DROP_THIS_TABLE("All subtables are removed");
return true;
}
return true;
}
-bool ots_kern_should_serialise(OpenTypeFile *file) {
- if (!file->glyf) return false; // this table is not for CFF fonts.
- return file->kern != NULL;
+bool ots_kern_should_serialise(Font *font) {
+ if (!font->glyf) return false; // this table is not for CFF fonts.
+ return font->kern != NULL;
}
-bool ots_kern_serialise(OTSStream *out, OpenTypeFile *file) {
- const OpenTypeKERN *kern = file->kern;
+bool ots_kern_serialise(OTSStream *out, Font *font) {
+ const OpenTypeKERN *kern = font->kern;
const uint16_t num_subtables = static_cast<uint16_t>(kern->subtables.size());
if (num_subtables != kern->subtables.size() ||
@@ -193,8 +193,13 @@ bool ots_kern_serialise(OTSStream *out, OpenTypeFile *file) {
return true;
}
-void ots_kern_free(OpenTypeFile *file) {
- delete file->kern;
+void ots_kern_reuse(Font *font, Font *other) {
+ font->kern = other->kern;
+ font->kern_reused = true;
+}
+
+void ots_kern_free(Font *font) {
+ delete font->kern;
}
} // namespace ots
« no previous file with comments | « third_party/ots/src/hmtx.cc ('k') | third_party/ots/src/layout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698