Commit d58b8efd authored by Zhuoyu Qian's avatar Zhuoyu Qian Committed by Commit Bot

Rename OpenType namepsace to open_type

https://google.github.io/styleguide/cppguide.html#Namespace_Names
> Namespace names are all lower-case.

This CL has no behavior changes.

Bug: 889726
Change-Id: If5aaa97534ba38f112ae58974e93f16ecbd2cd92
Reviewed-on: https://chromium-review.googlesource.com/c/1301693Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Zhuoyu Qian <zhuoyu.qian@samsung.com>
Cr-Commit-Position: refs/heads/master@{#603424}
parent 142ae7f8
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink { namespace blink {
namespace OpenType { namespace open_type {
struct Int16 { struct Int16 {
DISALLOW_NEW(); DISALLOW_NEW();
...@@ -101,6 +101,6 @@ struct TableBase { ...@@ -101,6 +101,6 @@ struct TableBase {
} }
}; };
} // namespace OpenType } // namespace open_type
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_OPENTYPE_OPEN_TYPE_TYPES_H_ #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_OPENTYPE_OPEN_TYPE_TYPES_H_
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
namespace blink { namespace blink {
namespace OpenType { namespace open_type {
// The input characters are big-endian (first is most significant). // The input characters are big-endian (first is most significant).
#define OT_MAKE_TAG(ch1, ch2, ch3, ch4) \ #define OT_MAKE_TAG(ch1, ch2, ch3, ch4) \
...@@ -50,46 +50,46 @@ const SkFontTableTag kVORGTag = OT_MAKE_TAG('V', 'O', 'R', 'G'); ...@@ -50,46 +50,46 @@ const SkFontTableTag kVORGTag = OT_MAKE_TAG('V', 'O', 'R', 'G');
struct HheaTable { struct HheaTable {
DISALLOW_NEW(); DISALLOW_NEW();
OpenType::Fixed version; open_type::Fixed version;
OpenType::Int16 ascender; open_type::Int16 ascender;
OpenType::Int16 descender; open_type::Int16 descender;
OpenType::Int16 line_gap; open_type::Int16 line_gap;
OpenType::Int16 advance_width_max; open_type::Int16 advance_width_max;
OpenType::Int16 min_left_side_bearing; open_type::Int16 min_left_side_bearing;
OpenType::Int16 min_right_side_bearing; open_type::Int16 min_right_side_bearing;
OpenType::Int16 x_max_extent; open_type::Int16 x_max_extent;
OpenType::Int16 caret_slope_rise; open_type::Int16 caret_slope_rise;
OpenType::Int16 caret_slope_run; open_type::Int16 caret_slope_run;
OpenType::Int16 caret_offset; open_type::Int16 caret_offset;
OpenType::Int16 reserved[4]; open_type::Int16 reserved[4];
OpenType::Int16 metric_data_format; open_type::Int16 metric_data_format;
OpenType::UInt16 number_of_h_metrics; open_type::UInt16 number_of_h_metrics;
}; };
struct VheaTable { struct VheaTable {
DISALLOW_NEW(); DISALLOW_NEW();
OpenType::Fixed version; open_type::Fixed version;
OpenType::Int16 ascent; open_type::Int16 ascent;
OpenType::Int16 descent; open_type::Int16 descent;
OpenType::Int16 line_gap; open_type::Int16 line_gap;
OpenType::Int16 advance_height_max; open_type::Int16 advance_height_max;
OpenType::Int16 min_top_side_bearing; open_type::Int16 min_top_side_bearing;
OpenType::Int16 min_bottom_side_bearing; open_type::Int16 min_bottom_side_bearing;
OpenType::Int16 y_max_extent; open_type::Int16 y_max_extent;
OpenType::Int16 caret_slope_rise; open_type::Int16 caret_slope_rise;
OpenType::Int16 caret_slope_run; open_type::Int16 caret_slope_run;
OpenType::Int16 caret_offset; open_type::Int16 caret_offset;
OpenType::Int16 reserved[4]; open_type::Int16 reserved[4];
OpenType::Int16 metric_data_format; open_type::Int16 metric_data_format;
OpenType::UInt16 num_of_long_ver_metrics; open_type::UInt16 num_of_long_ver_metrics;
}; };
struct HmtxTable { struct HmtxTable {
DISALLOW_NEW(); DISALLOW_NEW();
struct Entry { struct Entry {
DISALLOW_NEW(); DISALLOW_NEW();
OpenType::UInt16 advance_width; open_type::UInt16 advance_width;
OpenType::Int16 lsb; open_type::Int16 lsb;
} entries[1]; } entries[1];
}; };
...@@ -97,21 +97,21 @@ struct VmtxTable { ...@@ -97,21 +97,21 @@ struct VmtxTable {
DISALLOW_NEW(); DISALLOW_NEW();
struct Entry { struct Entry {
DISALLOW_NEW(); DISALLOW_NEW();
OpenType::UInt16 advance_height; open_type::UInt16 advance_height;
OpenType::Int16 top_side_bearing; open_type::Int16 top_side_bearing;
} entries[1]; } entries[1];
}; };
struct VORGTable { struct VORGTable {
DISALLOW_NEW(); DISALLOW_NEW();
OpenType::UInt16 major_version; open_type::UInt16 major_version;
OpenType::UInt16 minor_version; open_type::UInt16 minor_version;
OpenType::Int16 default_vert_origin_y; open_type::Int16 default_vert_origin_y;
OpenType::UInt16 num_vert_origin_y_metrics; open_type::UInt16 num_vert_origin_y_metrics;
struct VertOriginYMetrics { struct VertOriginYMetrics {
DISALLOW_NEW(); DISALLOW_NEW();
OpenType::UInt16 glyph_index; open_type::UInt16 glyph_index;
OpenType::Int16 vert_origin_y; open_type::Int16 vert_origin_y;
} vert_origin_y_metrics[1]; } vert_origin_y_metrics[1];
size_t RequiredSize() const { size_t RequiredSize() const {
...@@ -122,7 +122,7 @@ struct VORGTable { ...@@ -122,7 +122,7 @@ struct VORGTable {
#pragma pack() #pragma pack()
} // namespace OpenType } // namespace open_type
OpenTypeVerticalData::OpenTypeVerticalData(sk_sp<SkTypeface> typeface) OpenTypeVerticalData::OpenTypeVerticalData(sk_sp<SkTypeface> typeface)
: default_vert_origin_y_(0), : default_vert_origin_y_(0),
...@@ -146,9 +146,9 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) { ...@@ -146,9 +146,9 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) {
// Load hhea and hmtx to get x-component of vertical origins. // Load hhea and hmtx to get x-component of vertical origins.
// If these tables are missing, it's not an OpenType font. // If these tables are missing, it's not an OpenType font.
Vector<char> buffer; Vector<char> buffer;
CopyOpenTypeTable(typeface, OpenType::kHheaTag, buffer); CopyOpenTypeTable(typeface, open_type::kHheaTag, buffer);
const OpenType::HheaTable* hhea = const open_type::HheaTable* hhea =
OpenType::ValidateTable<OpenType::HheaTable>(buffer); open_type::ValidateTable<open_type::HheaTable>(buffer);
if (!hhea) if (!hhea)
return; return;
uint16_t count_hmtx_entries = hhea->number_of_h_metrics; uint16_t count_hmtx_entries = hhea->number_of_h_metrics;
...@@ -157,9 +157,10 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) { ...@@ -157,9 +157,10 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) {
return; return;
} }
CopyOpenTypeTable(typeface, OpenType::kHmtxTag, buffer); CopyOpenTypeTable(typeface, open_type::kHmtxTag, buffer);
const OpenType::HmtxTable* hmtx = const open_type::HmtxTable* hmtx =
OpenType::ValidateTable<OpenType::HmtxTable>(buffer, count_hmtx_entries); open_type::ValidateTable<open_type::HmtxTable>(buffer,
count_hmtx_entries);
if (!hmtx) { if (!hmtx) {
DLOG(ERROR) << "hhea exists but hmtx does not (or broken)"; DLOG(ERROR) << "hhea exists but hmtx does not (or broken)";
return; return;
...@@ -170,9 +171,9 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) { ...@@ -170,9 +171,9 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) {
// Load vhea first. This table is required for fonts that support vertical // Load vhea first. This table is required for fonts that support vertical
// flow. // flow.
CopyOpenTypeTable(typeface, OpenType::kVheaTag, buffer); CopyOpenTypeTable(typeface, open_type::kVheaTag, buffer);
const OpenType::VheaTable* vhea = const open_type::VheaTable* vhea =
OpenType::ValidateTable<OpenType::VheaTable>(buffer); open_type::ValidateTable<open_type::VheaTable>(buffer);
if (!vhea) if (!vhea)
return; return;
uint16_t count_vmtx_entries = vhea->num_of_long_ver_metrics; uint16_t count_vmtx_entries = vhea->num_of_long_ver_metrics;
...@@ -182,9 +183,9 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) { ...@@ -182,9 +183,9 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) {
} }
// Load VORG. This table is optional. // Load VORG. This table is optional.
CopyOpenTypeTable(typeface, OpenType::kVORGTag, buffer); CopyOpenTypeTable(typeface, open_type::kVORGTag, buffer);
const OpenType::VORGTable* vorg = const open_type::VORGTable* vorg =
OpenType::ValidateTable<OpenType::VORGTable>(buffer); open_type::ValidateTable<open_type::VORGTable>(buffer);
if (vorg && buffer.size() >= vorg->RequiredSize()) { if (vorg && buffer.size() >= vorg->RequiredSize()) {
default_vert_origin_y_ = vorg->default_vert_origin_y; default_vert_origin_y_ = vorg->default_vert_origin_y;
uint16_t count_vert_origin_y_metrics = vorg->num_vert_origin_y_metrics; uint16_t count_vert_origin_y_metrics = vorg->num_vert_origin_y_metrics;
...@@ -193,7 +194,7 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) { ...@@ -193,7 +194,7 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) {
vert_origin_y_.Set(0, default_vert_origin_y_); vert_origin_y_.Set(0, default_vert_origin_y_);
} else { } else {
for (uint16_t i = 0; i < count_vert_origin_y_metrics; ++i) { for (uint16_t i = 0; i < count_vert_origin_y_metrics; ++i) {
const OpenType::VORGTable::VertOriginYMetrics& metrics = const open_type::VORGTable::VertOriginYMetrics& metrics =
vorg->vert_origin_y_metrics[i]; vorg->vert_origin_y_metrics[i];
vert_origin_y_.Set(metrics.glyph_index, metrics.vert_origin_y); vert_origin_y_.Set(metrics.glyph_index, metrics.vert_origin_y);
} }
...@@ -202,9 +203,10 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) { ...@@ -202,9 +203,10 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) {
// Load vmtx then. This table is required for fonts that support vertical // Load vmtx then. This table is required for fonts that support vertical
// flow. // flow.
CopyOpenTypeTable(typeface, OpenType::kVmtxTag, buffer); CopyOpenTypeTable(typeface, open_type::kVmtxTag, buffer);
const OpenType::VmtxTable* vmtx = const open_type::VmtxTable* vmtx =
OpenType::ValidateTable<OpenType::VmtxTable>(buffer, count_vmtx_entries); open_type::ValidateTable<open_type::VmtxTable>(buffer,
count_vmtx_entries);
if (!vmtx) { if (!vmtx) {
DLOG(ERROR) << "vhea exists but vmtx does not (or broken)"; DLOG(ERROR) << "vhea exists but vmtx does not (or broken)";
return; return;
...@@ -219,20 +221,20 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) { ...@@ -219,20 +221,20 @@ void OpenTypeVerticalData::LoadMetrics(sk_sp<SkTypeface> typeface) {
return; return;
wtf_size_t size_extra = wtf_size_t size_extra =
buffer.size() - sizeof(OpenType::VmtxTable::Entry) * count_vmtx_entries; buffer.size() - sizeof(open_type::VmtxTable::Entry) * count_vmtx_entries;
if (size_extra % sizeof(OpenType::Int16)) { if (size_extra % sizeof(open_type::Int16)) {
DLOG(ERROR) << "vmtx has incorrect tsb count"; DLOG(ERROR) << "vmtx has incorrect tsb count";
return; return;
} }
wtf_size_t count_top_side_bearings = wtf_size_t count_top_side_bearings =
count_vmtx_entries + size_extra / sizeof(OpenType::Int16); count_vmtx_entries + size_extra / sizeof(open_type::Int16);
top_side_bearings_.resize(count_top_side_bearings); top_side_bearings_.resize(count_top_side_bearings);
wtf_size_t i; wtf_size_t i;
for (i = 0; i < count_vmtx_entries; ++i) for (i = 0; i < count_vmtx_entries; ++i)
top_side_bearings_[i] = vmtx->entries[i].top_side_bearing; top_side_bearings_[i] = vmtx->entries[i].top_side_bearing;
if (i < count_top_side_bearings) { if (i < count_top_side_bearings) {
const OpenType::Int16* p_top_side_bearings_extra = const open_type::Int16* p_top_side_bearings_extra =
reinterpret_cast<const OpenType::Int16*>( reinterpret_cast<const open_type::Int16*>(
&vmtx->entries[count_vmtx_entries]); &vmtx->entries[count_vmtx_entries]);
for (; i < count_top_side_bearings; ++i, ++p_top_side_bearings_extra) for (; i < count_top_side_bearings; ++i, ++p_top_side_bearings_extra)
top_side_bearings_[i] = *p_top_side_bearings_extra; top_side_bearings_[i] = *p_top_side_bearings_extra;
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
namespace blink { namespace blink {
struct TestTable : OpenType::TableBase { struct TestTable : open_type::TableBase {
OpenType::Fixed version; open_type::Fixed version;
OpenType::Int16 ascender; open_type::Int16 ascender;
template <typename T> template <typename T>
const T* ValidateOffset(const Vector<char>& buffer, uint16_t offset) const { const T* ValidateOffset(const Vector<char>& buffer, uint16_t offset) const {
...@@ -40,21 +40,21 @@ struct TestTable : OpenType::TableBase { ...@@ -40,21 +40,21 @@ struct TestTable : OpenType::TableBase {
TEST(OpenTypeVerticalDataTest, ValidateTableTest) { TEST(OpenTypeVerticalDataTest, ValidateTableTest) {
Vector<char> buffer(sizeof(TestTable)); Vector<char> buffer(sizeof(TestTable));
const TestTable* table = OpenType::ValidateTable<TestTable>(buffer); const TestTable* table = open_type::ValidateTable<TestTable>(buffer);
EXPECT_TRUE(table); EXPECT_TRUE(table);
buffer = Vector<char>(sizeof(TestTable) - 1); buffer = Vector<char>(sizeof(TestTable) - 1);
table = OpenType::ValidateTable<TestTable>(buffer); table = open_type::ValidateTable<TestTable>(buffer);
EXPECT_FALSE(table); EXPECT_FALSE(table);
buffer = Vector<char>(sizeof(TestTable) + 1); buffer = Vector<char>(sizeof(TestTable) + 1);
table = OpenType::ValidateTable<TestTable>(buffer); table = open_type::ValidateTable<TestTable>(buffer);
EXPECT_TRUE(table); EXPECT_TRUE(table);
} }
TEST(OpenTypeVerticalDataTest, ValidateOffsetTest) { TEST(OpenTypeVerticalDataTest, ValidateOffsetTest) {
Vector<char> buffer(sizeof(TestTable)); Vector<char> buffer(sizeof(TestTable));
const TestTable* table = OpenType::ValidateTable<TestTable>(buffer); const TestTable* table = open_type::ValidateTable<TestTable>(buffer);
ASSERT_TRUE(table); ASSERT_TRUE(table);
// Test overflow // Test overflow
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment