diff options
author | Colin Cross <ccross@android.com> | 2017-06-06 02:57:05 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-06-06 02:57:05 +0000 |
commit | ad302cbfd89396891e23d8902cea1b8189ac7d58 (patch) | |
tree | a3030d07d2ff89294ce4b6394afc5cbe4f67dbda /cpp/src/sfntly/table/core | |
parent | 9e1ecbca64ce4fc834d032b4d99c8ed1cd79db75 (diff) | |
parent | 3d3aab44bf4341afecf35b10c40b20e85906a1ef (diff) | |
download | sfntly-ad302cbfd89396891e23d8902cea1b8189ac7d58.tar.gz |
Merge remote-tracking branch 'aosp/upstream-master' into master am: d7c3ad1d95 am: fd76129cde
am: 3d3aab44bf
Change-Id: Ib70f9f05aa51a6927735d58dff3b7b339e6ae03a
Diffstat (limited to 'cpp/src/sfntly/table/core')
-rw-r--r-- | cpp/src/sfntly/table/core/font_header_table.cc | 5 | ||||
-rw-r--r-- | cpp/src/sfntly/table/core/font_header_table.h | 1 | ||||
-rw-r--r-- | cpp/src/sfntly/table/core/name_table.cc | 10 | ||||
-rw-r--r-- | cpp/src/sfntly/table/core/os2_table.cc | 2 |
4 files changed, 13 insertions, 5 deletions
diff --git a/cpp/src/sfntly/table/core/font_header_table.cc b/cpp/src/sfntly/table/core/font_header_table.cc index 60015ca..a848afd 100644 --- a/cpp/src/sfntly/table/core/font_header_table.cc +++ b/cpp/src/sfntly/table/core/font_header_table.cc @@ -239,7 +239,10 @@ void FontHeaderTable::Builder::SetFontDirectionHint(int32_t hint) { } int32_t FontHeaderTable::Builder::IndexToLocFormat() { - return down_cast<FontHeaderTable*>(GetTable())->IndexToLocFormat(); + Table* table = GetTable(); + if (!table) + return IndexToLocFormat::kInvalidOffset; + return down_cast<FontHeaderTable*>(table)->IndexToLocFormat(); } void FontHeaderTable::Builder::SetIndexToLocFormat(int32_t format) { diff --git a/cpp/src/sfntly/table/core/font_header_table.h b/cpp/src/sfntly/table/core/font_header_table.h index 841955b..4851775 100644 --- a/cpp/src/sfntly/table/core/font_header_table.h +++ b/cpp/src/sfntly/table/core/font_header_table.h @@ -24,6 +24,7 @@ namespace sfntly { struct IndexToLocFormat { enum { + kInvalidOffset = -1, kShortOffset = 0, kLongOffset = 1 }; diff --git a/cpp/src/sfntly/table/core/name_table.cc b/cpp/src/sfntly/table/core/name_table.cc index 8d2f64f..c9fe468 100644 --- a/cpp/src/sfntly/table/core/name_table.cc +++ b/cpp/src/sfntly/table/core/name_table.cc @@ -469,12 +469,14 @@ int32_t NameTable::NameId(int32_t index) { void NameTable::NameAsBytes(int32_t index, ByteVector* b) { assert(b); - int32_t length = NameLength(index); b->clear(); + + int32_t length = NameLength(index); + if (length <= 0) + return; + b->resize(length); - if (length > 0) { - data_->ReadBytes(NameOffset(index), &((*b)[0]), 0, length); - } + data_->ReadBytes(NameOffset(index), &((*b)[0]), 0, length); } void NameTable::NameAsBytes(int32_t platform_id, diff --git a/cpp/src/sfntly/table/core/os2_table.cc b/cpp/src/sfntly/table/core/os2_table.cc index 7ca9d9a..1fef309 100644 --- a/cpp/src/sfntly/table/core/os2_table.cc +++ b/cpp/src/sfntly/table/core/os2_table.cc @@ -16,6 +16,8 @@ #include "sfntly/table/core/os2_table.h" +#include <algorithm> + namespace sfntly { /****************************************************************************** * Constants |