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

Unified Diff: third_party/ots/src/name.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/metrics.cc ('k') | third_party/ots/src/os2.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/ots/src/name.cc
diff --git a/third_party/ots/src/name.cc b/third_party/ots/src/name.cc
index 2ea10dc8e67d2ffb93fbbf5d6f45e9bc05c5c82b..a0dd1eaf5d510e8753394d1b279f210e19a7c02c 100644
--- a/third_party/ots/src/name.cc
+++ b/third_party/ots/src/name.cc
@@ -7,8 +7,6 @@
#include <algorithm>
#include <cstring>
-#include "cff.h"
-
// name - Naming Table
// http://www.microsoft.com/typography/otspec/name.htm
@@ -58,11 +56,11 @@ void AssignToUtf16BeFromAscii(std::string* target,
namespace ots {
-bool ots_name_parse(OpenTypeFile* file, const uint8_t* data, size_t length) {
+bool ots_name_parse(Font *font, const uint8_t* data, size_t length) {
Buffer table(data, length);
OpenTypeNAME* name = new OpenTypeNAME;
- file->name = name;
+ font->name = name;
uint16_t format = 0;
if (!table.ReadU16(&format) || format > 1) {
@@ -141,15 +139,11 @@ bool ots_name_parse(OpenTypeFile* file, const uint8_t* data, size_t length) {
if (rec.name_id == 6) {
// PostScript name: check that it is valid, if not then discard it
if (rec.platform_id == 1) {
- if (file->cff && !file->cff->name.empty()) {
- rec.text = file->cff->name;
- } else if (!CheckPsNameAscii(rec.text)) {
+ if (!CheckPsNameAscii(rec.text)) {
continue;
}
} else if (rec.platform_id == 0 || rec.platform_id == 3) {
- if (file->cff && !file->cff->name.empty()) {
- AssignToUtf16BeFromAscii(&rec.text, file->cff->name);
- } else if (!CheckPsNameUtf16Be(rec.text)) {
+ if (!CheckPsNameUtf16Be(rec.text)) {
continue;
}
}
@@ -210,12 +204,6 @@ bool ots_name_parse(OpenTypeFile* file, const uint8_t* data, size_t length) {
"1.000",
"OTS-derived-font"
};
- // The spec says that "In CFF OpenType fonts, these two name strings, when
- // translated to ASCII, must also be identical to the font name as stored in
- // the CFF's Name INDEX." And actually, Mac OS X's font parser requires that.
- if (file->cff && !file->cff->name.empty()) {
- kStdNames[6] = file->cff->name.c_str();
- }
// scan the names to check whether the required "standard" ones are present;
// if not, we'll add our fixed versions here
@@ -241,18 +229,17 @@ bool ots_name_parse(OpenTypeFile* file, const uint8_t* data, size_t length) {
if (kStdNames[i] == NULL) {
continue;
}
- if (!mac_name[i]) {
- NameRecord rec(1 /* platform_id */, 0 /* encoding_id */,
- 0 /* language_id */ , i /* name_id */);
- rec.text.assign(kStdNames[i]);
- name->names.push_back(rec);
- sort_required = true;
- }
- if (!win_name[i]) {
- NameRecord rec(3 /* platform_id */, 1 /* encoding_id */,
- 1033 /* language_id */ , i /* name_id */);
- AssignToUtf16BeFromAscii(&rec.text, std::string(kStdNames[i]));
- name->names.push_back(rec);
+ if (!mac_name[i] && !win_name[i]) {
+ NameRecord mac_rec(1 /* platform_id */, 0 /* encoding_id */,
+ 0 /* language_id */ , i /* name_id */);
+ mac_rec.text.assign(kStdNames[i]);
+
+ NameRecord win_rec(3 /* platform_id */, 1 /* encoding_id */,
+ 1033 /* language_id */ , i /* name_id */);
+ AssignToUtf16BeFromAscii(&win_rec.text, std::string(kStdNames[i]));
+
+ name->names.push_back(mac_rec);
+ name->names.push_back(win_rec);
sort_required = true;
}
}
@@ -264,12 +251,12 @@ bool ots_name_parse(OpenTypeFile* file, const uint8_t* data, size_t length) {
return true;
}
-bool ots_name_should_serialise(OpenTypeFile* file) {
- return file->name != NULL;
+bool ots_name_should_serialise(Font *font) {
+ return font->name != NULL;
}
-bool ots_name_serialise(OTSStream* out, OpenTypeFile* file) {
- const OpenTypeNAME* name = file->name;
+bool ots_name_serialise(OTSStream* out, Font *font) {
+ const OpenTypeNAME* name = font->name;
uint16_t name_count = static_cast<uint16_t>(name->names.size());
uint16_t lang_tag_count = static_cast<uint16_t>(name->lang_tags.size());
@@ -331,8 +318,13 @@ bool ots_name_serialise(OTSStream* out, OpenTypeFile* file) {
return true;
}
-void ots_name_free(OpenTypeFile* file) {
- delete file->name;
+void ots_name_reuse(Font *font, Font *other) {
+ font->name = other->name;
+ font->name_reused = true;
+}
+
+void ots_name_free(Font *font) {
+ delete font->name;
}
} // namespace
« no previous file with comments | « third_party/ots/src/metrics.cc ('k') | third_party/ots/src/os2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698