summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarthurhsu@google.com <arthurhsu@google.com@672e30a5-4c29-85ac-ac6d-611c735e0a51>2011-09-08 21:42:50 +0000
committerarthurhsu@google.com <arthurhsu@google.com@672e30a5-4c29-85ac-ac6d-611c735e0a51>2011-09-08 21:42:50 +0000
commit6b8e073e978eed96605da6f92d6db740a39864ba (patch)
tree4f024b418eda492f9cfe8e8f2603c7dfbd00c00d
parentb54cce09c1fc2b09e2adae43d7eb017b47b0cccf (diff)
downloadsrc-6b8e073e978eed96605da6f92d6db740a39864ba.tar.gz
Advance C++ port to Sep 1 11 snapshot
Update test font to use OFL-compliant fonts git-svn-id: http://sfntly.googlecode.com/svn/trunk/cpp/src@71 672e30a5-4c29-85ac-ac6d-611c735e0a51
-rw-r--r--sfntly/data/readable_font_data.cc23
-rw-r--r--sfntly/data/readable_font_data.h21
-rw-r--r--sfntly/data/writable_font_data.cc17
-rw-r--r--sfntly/data/writable_font_data.h16
-rw-r--r--sfntly/font.cc22
-rw-r--r--sfntly/font.h2
-rw-r--r--sfntly/table/bitmap/bitmap_glyph.cc66
-rw-r--r--sfntly/table/bitmap/bitmap_glyph.h102
-rw-r--r--sfntly/table/bitmap/bitmap_size_table.cc147
-rw-r--r--sfntly/table/bitmap/bitmap_size_table.h68
-rw-r--r--sfntly/table/bitmap/composite_bitmap_glyph.cc89
-rw-r--r--sfntly/table/bitmap/composite_bitmap_glyph.h65
-rw-r--r--sfntly/table/bitmap/ebdt_table.cc109
-rw-r--r--sfntly/table/bitmap/ebdt_table.h67
-rw-r--r--sfntly/table/bitmap/eblc_table.cc119
-rw-r--r--sfntly/table/bitmap/eblc_table.h154
-rw-r--r--sfntly/table/bitmap/index_sub_table.cc137
-rw-r--r--sfntly/table/bitmap/index_sub_table.h64
-rw-r--r--sfntly/table/bitmap/index_sub_table_format1.cc67
-rw-r--r--sfntly/table/bitmap/index_sub_table_format1.h49
-rw-r--r--sfntly/table/bitmap/index_sub_table_format2.cc64
-rw-r--r--sfntly/table/bitmap/index_sub_table_format2.h51
-rw-r--r--sfntly/table/bitmap/index_sub_table_format3.cc67
-rw-r--r--sfntly/table/bitmap/index_sub_table_format3.h49
-rw-r--r--sfntly/table/bitmap/index_sub_table_format4.cc88
-rw-r--r--sfntly/table/bitmap/index_sub_table_format4.h49
-rw-r--r--sfntly/table/bitmap/index_sub_table_format5.cc65
-rw-r--r--sfntly/table/bitmap/index_sub_table_format5.h46
-rw-r--r--sfntly/table/bitmap/simple_bitmap_glyph.cc28
-rw-r--r--sfntly/table/bitmap/simple_bitmap_glyph.h33
-rw-r--r--sfntly/table/core/font_header_table.cc4
-rw-r--r--sfntly/table/core/font_header_table.h4
-rw-r--r--sfntly/table/core/horizontal_header_table.cc4
-rw-r--r--sfntly/table/core/horizontal_header_table.h4
-rw-r--r--sfntly/table/core/horizontal_metrics_table.cc8
-rw-r--r--sfntly/table/core/horizontal_metrics_table.h4
-rw-r--r--sfntly/table/core/maximum_profile_table.cc4
-rw-r--r--sfntly/table/core/maximum_profile_table.h4
-rw-r--r--sfntly/table/core/os2_table.cc21
-rw-r--r--sfntly/table/core/os2_table.h8
-rw-r--r--sfntly/table/font_data_table.cc27
-rw-r--r--sfntly/table/header.cc66
-rw-r--r--sfntly/table/header.h108
-rw-r--r--sfntly/table/table.cc134
-rw-r--r--sfntly/table/table.h125
-rw-r--r--sfntly/table/table_based_table_builder.cc93
-rw-r--r--sfntly/table/table_based_table_builder.h59
-rw-r--r--sfntly/tag.cc11
-rw-r--r--sfntly/tag.h24
-rw-r--r--test/bitmap_table_test.cc98
-rw-r--r--test/file_io_test.cc19
-rw-r--r--test/font_parsing_test.cc22
-rw-r--r--test/otf_basic_editing_test.cc2
-rw-r--r--test/test_data.cc57
-rw-r--r--test/test_data.h9
-rw-r--r--test/verify_glyf.cc2
-rw-r--r--test/verify_hhea.cc14
-rw-r--r--test/verify_hmtx.cc202
-rw-r--r--test/verify_loca.cc212
-rw-r--r--test/verify_maxp.cc14
-rw-r--r--test/verify_name.cc26
-rw-r--r--test/verify_os2.cc18
62 files changed, 2546 insertions, 805 deletions
diff --git a/sfntly/data/readable_font_data.cc b/sfntly/data/readable_font_data.cc
index 6ceb38c..ec67757 100644
--- a/sfntly/data/readable_font_data.cc
+++ b/sfntly/data/readable_font_data.cc
@@ -191,6 +191,29 @@ int32_t ReadableFontData::SearchUShort(int32_t start_index,
return -1;
}
+int32_t ReadableFontData::SearchUShort(int32_t start_index,
+ int32_t start_offset,
+ int32_t length,
+ int32_t key) {
+ int32_t location = 0;
+ int32_t bottom = 0;
+ int32_t top = length;
+ while (top != bottom) {
+ location = (top + bottom) / 2;
+ int32_t location_start = ReadUShort(start_index + location * start_offset);
+ if (key < location_start) {
+ // location is below current location
+ top = location;
+ } else if (key > location_start) {
+ // location is above current location
+ bottom = location + 1;
+ } else {
+ return location;
+ }
+ }
+ return -1;
+}
+
int32_t ReadableFontData::SearchULong(int32_t start_index,
int32_t start_offset,
int32_t end_index,
diff --git a/sfntly/data/readable_font_data.h b/sfntly/data/readable_font_data.h
index 34d7179..a0d341f 100644
--- a/sfntly/data/readable_font_data.h
+++ b/sfntly/data/readable_font_data.h
@@ -181,11 +181,9 @@ class ReadableFontData : public FontData,
virtual int32_t CopyTo(ByteArray* ba);
// Search for the key value in the range tables provided.
- //
- // The search looks through the start-end pairs looking for the key value. It
+ // The search looks through the start-end pairs looking for the key value. It
// is assumed that the start-end pairs are both represented by UShort values,
// ranges do not overlap, and are monotonically increasing.
- //
// @param startIndex the position to read the first start value from
// @param startOffset the offset between subsequent start values
// @param endIndex the position to read the first end value from
@@ -201,13 +199,26 @@ class ReadableFontData : public FontData,
int32_t length,
int32_t key);
+ // Search for the key value in the table provided.
+ // The search looks through the values looking for the key value. It is
+ // assumed that the are represented by UShort values and are monotonically
+ // increasing.
+ // @param startIndex the position to read the first start value from
+ // @param startOffset the offset between subsequent start values
+ // @param length the number of start-end pairs
+ // @param key the value to search for
+ // @return the index of the start-end pairs in which the key was found; -1
+ // otherwise
+ int32_t SearchUShort(int32_t start_index,
+ int32_t start_offset,
+ int32_t length,
+ int32_t key);
+
// Search for the key value in the range tables provided.
- //
// The search looks through the start-end pairs looking for the key value. It
// is assumed that the start-end pairs are both represented by ULong values
// that can be represented within 31 bits, ranges do not overlap, and are
// monotonically increasing.
- //
// @param startIndex the position to read the first start value from
// @param startOffset the offset between subsequent start values
// @param endIndex the position to read the first end value from
diff --git a/sfntly/data/writable_font_data.cc b/sfntly/data/writable_font_data.cc
index c690956..0b271a3 100644
--- a/sfntly/data/writable_font_data.cc
+++ b/sfntly/data/writable_font_data.cc
@@ -71,6 +71,23 @@ int32_t WritableFontData::WriteBytes(int32_t index, ByteVector* b) {
return WriteBytes(index, &((*b)[0]), 0, b->size());
}
+int32_t WritableFontData::WriteBytesPad(int32_t index,
+ ByteVector* b,
+ int32_t offset,
+ int32_t length,
+ byte_t pad) {
+ int32_t written =
+ array_->Put(BoundOffset(index),
+ &((*b)[0]),
+ offset,
+ BoundLength(index,
+ std::min<int32_t>(length, b->size() - offset)));
+ for (; written < length; written++) {
+ array_->Put(written + index, pad);
+ }
+ return written;
+}
+
int32_t WritableFontData::WriteChar(int32_t index, byte_t c) {
return WriteByte(index, c);
}
diff --git a/sfntly/data/writable_font_data.h b/sfntly/data/writable_font_data.h
index 7fac998..9a9bd7b 100644
--- a/sfntly/data/writable_font_data.h
+++ b/sfntly/data/writable_font_data.h
@@ -69,6 +69,22 @@ class WritableFontData : public ReadableFontData {
// the FontData's range
virtual int32_t WriteBytes(int32_t index, ByteVector* b);
+ // Write the bytes from the array and pad if necessary.
+ // Write to the length given using the byte array provided and if there are
+ // not enough bytes in the array then pad to the requested length using the
+ // pad byte specified.
+ // @param index index into the font data
+ // @param b the source for the bytes to be written
+ // @param offset offset in the byte array
+ // @param length the length of the bytes to be written
+ // @param pad the padding byte to be used if necessary
+ // @return the number of bytes actually written
+ virtual int32_t WriteBytesPad(int32_t index,
+ ByteVector* b,
+ int32_t offset,
+ int32_t length,
+ byte_t pad);
+
// Write the CHAR at the given index.
// @param index index into the font data
// @param c the CHAR
diff --git a/sfntly/font.cc b/sfntly/font.cc
index e5e4401..524932b 100644
--- a/sfntly/font.cc
+++ b/sfntly/font.cc
@@ -99,9 +99,9 @@ void Font::BuildTableHeadersForSerialization(IntegerList* table_ordering,
}
TablePtr table = tables_[*tag];
if (table != NULL) {
- TableHeaderPtr header =
- new Table::Header(*tag, table->CalculatedChecksum(), table_offset,
- table->header()->length());
+ HeaderPtr header =
+ new Header(*tag, table->CalculatedChecksum(), table_offset,
+ table->header()->length());
table_headers->push_back(header);
table_offset += (table->DataLength() + 3) & ~3;
}
@@ -283,7 +283,7 @@ Table::Builder* Font::Builder::GetTableBuilder(int32_t tag) {
}
Table::Builder* Font::Builder::NewTableBuilder(int32_t tag) {
- TableHeaderPtr header = new Table::Header(tag);
+ HeaderPtr header = new Header(tag);
TableBuilderPtr builder;
builder.Attach(Table::Builder::GetBuilder(header, NULL));
table_builders_.insert(TableBuilderEntry(header->tag(), builder));
@@ -304,7 +304,7 @@ Table::Builder* Font::Builder::NewTableBuilder(int32_t tag,
return NULL;
}
#endif
- TableHeaderPtr header = new Table::Header(tag, data->Length());
+ HeaderPtr header = new Header(tag, data->Length());
TableBuilderPtr builder;
builder.Attach(Table::Builder::GetBuilder(header, data));
table_builders_.insert(TableBuilderEntry(tag, builder));
@@ -361,7 +361,7 @@ void Font::Builder::BuildAllTableBuilders(DataBlockMap* table_data,
}
CALLER_ATTACH
-Table::Builder* Font::Builder::GetTableBuilder(Table::Header* header,
+Table::Builder* Font::Builder::GetTableBuilder(Header* header,
WritableFontData* data) {
return Table::Builder::GetBuilder(header, data);
}
@@ -375,7 +375,7 @@ void Font::Builder::BuildTablesFromBuilders(Font* font,
// Now build all the tables.
for (TableBuilderMap::iterator builder = builder_map->begin(),
builder_end = builder_map->end();
- builder != builder_end; ++builder) {
+ builder != builder_end; ++builder) {
TablePtr table;
if (builder->second && builder->second->ReadyToBuild()) {
#if !defined (SFNTLY_NO_EXCEPTION)
@@ -393,10 +393,6 @@ void Font::Builder::BuildTablesFromBuilders(Font* font,
#endif
}
if (table == NULL) {
-#if defined (SFNTLY_DEBUG)
- fprintf(stderr, "Aborting table construction: %s\n",
- builder_string.c_str());
-#endif
table_map->clear();
#if !defined (SFNTLY_NO_EXCEPTION)
std::string builder_string = "Unable to build table - ";
@@ -496,7 +492,7 @@ void Font::Builder::ReadHeader(FontInputStream* is,
int64_t checksum = is->ReadULong();
int32_t offset = is->ReadULongAsInt();
int32_t length = is->ReadULongAsInt();
- TableHeaderPtr table = new Table::Header(tag, checksum, offset, length);
+ HeaderPtr table = new Header(tag, checksum, offset, length);
records->insert(table);
}
}
@@ -519,7 +515,7 @@ void Font::Builder::ReadHeader(ReadableFontData* fd,
int64_t checksum = fd->ReadULong(table_offset + Offset::kTableCheckSum);
int32_t offset = fd->ReadULongAsInt(table_offset + Offset::kTableOffset);
int32_t length = fd->ReadULongAsInt(table_offset + Offset::kTableLength);
- TableHeaderPtr table = new Table::Header(tag, checksum, offset, length);
+ HeaderPtr table = new Header(tag, checksum, offset, length);
records->insert(table);
}
}
diff --git a/sfntly/font.h b/sfntly/font.h
index 1a714a6..dd31c13 100644
--- a/sfntly/font.h
+++ b/sfntly/font.h
@@ -199,7 +199,7 @@ class Font : public RefCounted<Font> {
void BuildAllTableBuilders(DataBlockMap* table_data,
TableBuilderMap* builder_map);
CALLER_ATTACH Table::Builder*
- GetTableBuilder(Table::Header* header, WritableFontData* data);
+ GetTableBuilder(Header* header, WritableFontData* data);
void BuildTablesFromBuilders(Font* font,
TableBuilderMap* builder_map,
TableMap* tables);
diff --git a/sfntly/table/bitmap/bitmap_glyph.cc b/sfntly/table/bitmap/bitmap_glyph.cc
new file mode 100644
index 0000000..82d78b3
--- /dev/null
+++ b/sfntly/table/bitmap/bitmap_glyph.cc
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 = the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/bitmap_glyph.h"
+
+namespace sfntly {
+/******************************************************************************
+ * BitmapGlyph class
+ ******************************************************************************/
+BitmapGlyph::~BitmapGlyph() {
+}
+
+BitmapGlyph::BitmapGlyph(ReadableFontData* data, int32_t format)
+ : SubTable(data), format_(format) {
+}
+
+/******************************************************************************
+ * BitmapGlyph::Builder class
+ ******************************************************************************/
+BitmapGlyph::Builder::~Builder() {
+}
+
+BitmapGlyph::Builder::Builder(WritableFontData* data)
+ : SubTable::Builder(data) {
+}
+
+BitmapGlyph::Builder::Builder(ReadableFontData* data)
+ : SubTable::Builder(data) {
+}
+
+CALLER_ATTACH
+FontDataTable* BitmapGlyph::Builder::SubBuildTable(ReadableFontData* data) {
+ UNREFERENCED_PARAMETER(data);
+ return NULL;
+}
+
+void BitmapGlyph::Builder::SubDataSet() {
+}
+
+int32_t BitmapGlyph::Builder::SubDataSizeToSerialize() {
+ return 0;
+}
+
+bool BitmapGlyph::Builder::SubReadyToSerialize() {
+ return false;
+}
+
+int32_t BitmapGlyph::Builder::SubSerialize(WritableFontData* new_data) {
+ UNREFERENCED_PARAMETER(new_data);
+ return 0;
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/bitmap_glyph.h b/sfntly/table/bitmap/bitmap_glyph.h
new file mode 100644
index 0000000..47afbe1
--- /dev/null
+++ b/sfntly/table/bitmap/bitmap_glyph.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 = the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_BITMAP_GLYPH_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_BITMAP_GLYPH_H_
+
+#include "sfntly/table/subtable.h"
+
+namespace sfntly {
+
+class BitmapGlyph : public SubTable {
+ public:
+ struct Offset {
+ enum {
+ // header
+ kVersion = 0,
+
+ kSmallGlyphMetricsLength = 5,
+ kBigGlyphMetricsLength = 8,
+ // format 1
+ kGlyphFormat1_imageData = kSmallGlyphMetricsLength,
+
+ // format 2
+ kGlyphFormat2_imageData = kSmallGlyphMetricsLength,
+
+ // format 3
+
+ // format 4
+
+ // format 5
+ kGlyphFormat5_imageData = 0,
+
+ // format 6
+ kGlyphFormat6_imageData = kBigGlyphMetricsLength,
+
+ // format 7
+ kGlyphFormat7_imageData = kBigGlyphMetricsLength,
+
+ // format 8
+ kGlyphFormat8_numComponents = kSmallGlyphMetricsLength + 1,
+ kGlyphFormat8_componentArray = kGlyphFormat8_numComponents +
+ DataSize::kUSHORT,
+
+ // format 9
+ kGlyphFormat9_numComponents = kBigGlyphMetricsLength,
+ kGlyphFormat9_componentArray = kGlyphFormat9_numComponents +
+ DataSize::kUSHORT,
+
+ // ebdtComponent
+ kEbdtComponentLength = DataSize::kUSHORT + 2 * DataSize::kCHAR,
+ kEbdtComponent_glyphCode = 0,
+ kEbdtComponent_xOffset = 2,
+ kEbdtComponent_yOffset = 3,
+ };
+ };
+
+ // TODO(stuartg): builder is not functional at all
+ // - need to add subclasses for each type of bitmap glyph
+ class Builder : public SubTable::Builder {
+ public:
+ virtual ~Builder();
+
+ protected:
+ Builder(WritableFontData* data);
+ Builder(ReadableFontData* data);
+
+ virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data);
+ virtual void SubDataSet();
+ virtual int32_t SubDataSizeToSerialize();
+ virtual bool SubReadyToSerialize();
+ virtual int32_t SubSerialize(WritableFontData* new_data);
+ };
+
+ virtual ~BitmapGlyph();
+ int32_t format() { return format_; }
+
+ // UNIMPLEMENTED: toString()
+
+ protected:
+ BitmapGlyph(ReadableFontData* data, int32_t format);
+
+ private:
+ int32_t format_;
+};
+typedef Ptr<BitmapGlyph> BitmapGlyphPtr;
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_BITMAP_GLYPH_H_
diff --git a/sfntly/table/bitmap/bitmap_size_table.cc b/sfntly/table/bitmap/bitmap_size_table.cc
new file mode 100644
index 0000000..2b5b9bb
--- /dev/null
+++ b/sfntly/table/bitmap/bitmap_size_table.cc
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 = the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/bitmap_size_table.h"
+
+#include "sfntly/table/bitmap/eblc_table.h"
+
+namespace sfntly {
+
+BitmapSizeTable::BitmapSizeTable(ReadableFontData* data,
+ ReadableFontData* master_data)
+ : SubTable(data) {
+ master_data_ = master_data;
+}
+
+BitmapSizeTable::~BitmapSizeTable() {
+}
+
+int32_t BitmapSizeTable::IndexSubTableArrayOffset() {
+ return data_->ReadULongAsInt(
+ EblcTable::Offset::kBitmapSizeTable_indexSubTableArrayOffset);
+}
+
+int32_t BitmapSizeTable::IndexTableSize() {
+ return data_->ReadULongAsInt(
+ EblcTable::Offset::kBitmapSizeTable_indexTableSize);
+}
+
+int32_t BitmapSizeTable::NumberOfIndexSubTables() {
+ return data_->ReadULongAsInt(
+ EblcTable::Offset::kBitmapSizeTable_numberOfIndexSubTables);
+}
+
+int32_t BitmapSizeTable::ColorRef() {
+ return data_->ReadULongAsInt(EblcTable::Offset::kBitmapSizeTable_colorRef);
+}
+
+int32_t BitmapSizeTable::StartGlyphIndex() {
+ return data_->ReadUShort(EblcTable::Offset::kBitmapSizeTable_startGlyphIndex);
+}
+
+int32_t BitmapSizeTable::EndGlyphIndex() {
+ return data_->ReadUShort(EblcTable::Offset::kBitmapSizeTable_endGlyphIndex);
+}
+
+int32_t BitmapSizeTable::PpemX() {
+ return data_->ReadByte(EblcTable::Offset::kBitmapSizeTable_ppemX);
+}
+
+int32_t BitmapSizeTable::PpemY() {
+ return data_->ReadByte(EblcTable::Offset::kBitmapSizeTable_ppemY);
+}
+
+int32_t BitmapSizeTable::BitDepth() {
+ return data_->ReadByte(EblcTable::Offset::kBitmapSizeTable_bitDepth);
+}
+
+int32_t BitmapSizeTable::FlagsAsInt() {
+ return data_->ReadChar(EblcTable::Offset::kBitmapSizeTable_flags);
+}
+
+IndexSubTable* BitmapSizeTable::GetIndexSubTable(int32_t index) {
+ IndexSubTableList* subtable_list = GetIndexSubTableList();
+ if (index >= 0 && (size_t)index < subtable_list->size()) {
+ return (*subtable_list)[index];
+ }
+ return NULL;
+}
+
+int32_t BitmapSizeTable::GlyphOffset(int32_t glyph_id) {
+ IndexSubTable* subtable = SearchIndexSubTables(glyph_id);
+ if (subtable == NULL) {
+ return -1;
+ }
+ return subtable->GlyphOffset(glyph_id);
+}
+
+int32_t BitmapSizeTable::GlyphLength(int32_t glyph_id) {
+ IndexSubTable* subtable = SearchIndexSubTables(glyph_id);
+ if (subtable == NULL) {
+ return -1;
+ }
+ return subtable->GlyphLength(glyph_id);
+}
+
+int32_t BitmapSizeTable::GlyphFormat(int32_t glyph_id) {
+ IndexSubTable* subtable = SearchIndexSubTables(glyph_id);
+ if (subtable == NULL) {
+ return -1;
+ }
+ return subtable->image_format();
+}
+
+IndexSubTable* BitmapSizeTable::SearchIndexSubTables(int32_t glyph_id) {
+ IndexSubTableList* subtable_list = GetIndexSubTableList();
+ int32_t index = 0;
+ int32_t bottom = 0;
+ int32_t top = subtable_list->size();
+ while (top != bottom) {
+ index = (top + bottom) / 2;
+ IndexSubTable* subtable = (*subtable_list)[index];
+ if (glyph_id < subtable->first_glyph_index()) {
+ // Location beow current location
+ top = index;
+ } else {
+ if (glyph_id <= subtable->last_glyph_index()) {
+ return subtable;
+ } else {
+ bottom = index + 1;
+ }
+ }
+ }
+ return NULL;
+}
+
+CALLER_ATTACH
+IndexSubTable* BitmapSizeTable::CreateIndexSubTable(int32_t index) {
+ return IndexSubTable::CreateIndexSubTable(master_data_,
+ IndexSubTableArrayOffset(),
+ index);
+}
+
+IndexSubTableList* BitmapSizeTable::GetIndexSubTableList() {
+ if (atomic_subtables.empty()) {
+ for (int32_t i = 0; i < NumberOfIndexSubTables(); ++i) {
+ IndexSubTablePtr table;
+ table.Attach(CreateIndexSubTable(i));
+ atomic_subtables.push_back(table);
+ }
+ }
+ return &atomic_subtables;
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/bitmap_size_table.h b/sfntly/table/bitmap/bitmap_size_table.h
new file mode 100644
index 0000000..3b8e30c
--- /dev/null
+++ b/sfntly/table/bitmap/bitmap_size_table.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 = the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_BITMAP_SIZE_TABLE_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_BITMAP_SIZE_TABLE_H_
+
+#include <vector>
+
+#include "sfntly/table/bitmap/index_sub_table.h"
+
+namespace sfntly {
+
+class BitmapSizeTable : public SubTable,
+ public RefCounted<BitmapSizeTable> {
+ public:
+ // Note: C++ port take two ReadableFontData. The first is sliced data, and
+ // the second is unsliced data. The second one is used to correctly
+ // construct index sub tables since Java version calculate the offset
+ // based on unsliced data.
+ BitmapSizeTable(ReadableFontData* data,
+ ReadableFontData* master_data);
+ virtual ~BitmapSizeTable();
+
+ int32_t IndexSubTableArrayOffset();
+ int32_t IndexTableSize();
+ int32_t NumberOfIndexSubTables();
+ int32_t ColorRef();
+ int32_t StartGlyphIndex();
+ int32_t EndGlyphIndex();
+ int32_t PpemX();
+ int32_t PpemY();
+ int32_t BitDepth();
+ int32_t FlagsAsInt();
+
+ // Note: renamed from indexSubTable()
+ IndexSubTable* GetIndexSubTable(int32_t index);
+
+ int32_t GlyphOffset(int32_t glyph_id);
+ int32_t GlyphLength(int32_t glyph_id);
+ int32_t GlyphFormat(int32_t glyph_id);
+
+ private:
+ IndexSubTable* SearchIndexSubTables(int32_t glyph_id);
+ CALLER_ATTACH IndexSubTable* CreateIndexSubTable(int32_t index);
+ IndexSubTableList* GetIndexSubTableList();
+
+ ReadableFontDataPtr master_data_;
+ IndexSubTableList atomic_subtables;
+};
+typedef Ptr<BitmapSizeTable> BitmapSizeTablePtr;
+typedef std::vector<BitmapSizeTablePtr> BitmapSizeTableList;
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_BITMAP_SIZE_TABLE_H_
diff --git a/sfntly/table/bitmap/composite_bitmap_glyph.cc b/sfntly/table/bitmap/composite_bitmap_glyph.cc
new file mode 100644
index 0000000..bd680e4
--- /dev/null
+++ b/sfntly/table/bitmap/composite_bitmap_glyph.cc
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 = the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/composite_bitmap_glyph.h"
+
+namespace sfntly {
+/******************************************************************************
+ * CompositeBitmapGlyph class
+ ******************************************************************************/
+CompositeBitmapGlyph::CompositeBitmapGlyph(ReadableFontData* data,
+ int32_t format)
+ : BitmapGlyph(data, format) {
+ Initialize(format);
+}
+
+CompositeBitmapGlyph::~CompositeBitmapGlyph() {
+}
+
+int32_t CompositeBitmapGlyph::NumComponents() {
+ return data_->ReadUShort(num_components_offset_);
+}
+
+CompositeBitmapGlyph::Component CompositeBitmapGlyph::GetComponent(
+ int32_t component_num) const {
+ int32_t component_offset = component_array_offset_ +
+ component_num * Offset::kEbdtComponentLength;
+ return CompositeBitmapGlyph::Component(
+ data_->ReadUShort(component_offset + Offset::kEbdtComponent_glyphCode),
+ data_->ReadChar(component_offset + Offset::kEbdtComponent_xOffset),
+ data_->ReadChar(component_offset + Offset::kEbdtComponent_yOffset));
+}
+
+void CompositeBitmapGlyph::Initialize(int32_t format) {
+ if (format == 8) {
+ num_components_offset_ = Offset::kGlyphFormat8_numComponents;
+ component_array_offset_ = Offset::kGlyphFormat8_componentArray;
+ } else if (format == 9) {
+ num_components_offset_ = Offset::kGlyphFormat9_numComponents;
+ component_array_offset_ = Offset::kGlyphFormat9_componentArray;
+ } else {
+#if !defined (SFNTLY_NO_EXCEPTION)
+ throw IllegalStateException("Attempt to create a Composite Bitmap Glyph "
+ "with a non-composite format.");
+#endif
+ }
+}
+
+/******************************************************************************
+ * CompositeBitmapGlyph::Component class
+ ******************************************************************************/
+CompositeBitmapGlyph::Component::Component(const Component& rhs)
+ : glyph_code_(rhs.glyph_code_),
+ x_offset_(rhs.x_offset_),
+ y_offset_(rhs.y_offset_) {
+}
+
+bool CompositeBitmapGlyph::Component::operator==(
+ const CompositeBitmapGlyph::Component& rhs) {
+ return glyph_code_ == rhs.glyph_code_;
+}
+
+CompositeBitmapGlyph::Component& CompositeBitmapGlyph::Component::operator=(
+ const CompositeBitmapGlyph::Component& rhs) {
+ glyph_code_ = rhs.glyph_code_;
+ x_offset_ = rhs.x_offset_;
+ y_offset_ = rhs.y_offset_;
+ return *this;
+}
+
+CompositeBitmapGlyph::Component::Component(int32_t glyph_code,
+ int32_t x_offset,
+ int32_t y_offset)
+ : glyph_code_(glyph_code), x_offset_(x_offset), y_offset_(y_offset) {
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/composite_bitmap_glyph.h b/sfntly/table/bitmap/composite_bitmap_glyph.h
new file mode 100644
index 0000000..0521213
--- /dev/null
+++ b/sfntly/table/bitmap/composite_bitmap_glyph.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 = the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_COMPOSITE_BITMAP_GLYPH_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_COMPOSITE_BITMAP_GLYPH_H_
+
+#include "sfntly/table/bitmap/bitmap_glyph.h"
+
+namespace sfntly {
+
+class CompositeBitmapGlyph : public BitmapGlyph,
+ public RefCounted<CompositeBitmapGlyph> {
+ public:
+ class Component {
+ public:
+ Component(const Component& rhs);
+
+ int32_t glyph_code() { return glyph_code_; }
+ int32_t x_offset() { return x_offset_; }
+ int32_t y_offset() { return y_offset_; }
+
+ // UNIMPLEMENTED: int hashCode()
+ bool operator==(const Component& rhs);
+ Component& operator=(const Component& rhs);
+
+ protected:
+ Component(int32_t glyph_code, int32_t x_offset, int32_t y_offset);
+
+ private:
+ int32_t glyph_code_;
+ int32_t x_offset_;
+ int32_t y_offset_;
+
+ friend class CompositeBitmapGlyph;
+ };
+
+ CompositeBitmapGlyph(ReadableFontData* data, int32_t format);
+ virtual ~CompositeBitmapGlyph();
+ int32_t NumComponents();
+ // Note: returned immutable object over stack.
+ Component GetComponent(int32_t component_num) const;
+
+ private:
+ void Initialize(int32_t format);
+
+ int32_t num_components_offset_;
+ int32_t component_array_offset_;
+};
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_COMPOSITE_BITMAP_GLYPH_H_
diff --git a/sfntly/table/bitmap/ebdt_table.cc b/sfntly/table/bitmap/ebdt_table.cc
new file mode 100644
index 0000000..a131f5a
--- /dev/null
+++ b/sfntly/table/bitmap/ebdt_table.cc
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/ebdt_table.h"
+
+#include "sfntly/table/bitmap/composite_bitmap_glyph.h"
+#include "sfntly/table/bitmap/simple_bitmap_glyph.h"
+
+namespace sfntly {
+/******************************************************************************
+ * EbdtTable class
+ ******************************************************************************/
+EbdtTable::~EbdtTable() {
+}
+
+int32_t EbdtTable::Version() {
+ return data_->ReadFixed(Offset::kVersion);
+}
+
+CALLER_ATTACH
+BitmapGlyph* EbdtTable::Glyph(int32_t offset, int32_t length, int32_t format) {
+ ReadableFontDataPtr new_data;
+ new_data.Attach(down_cast<ReadableFontData*>(data_->Slice(offset, length)));
+ BitmapGlyphPtr glyph;
+ switch (format) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ glyph = new SimpleBitmapGlyph(new_data, format);
+ break;
+ case 8:
+ case 9:
+ glyph = new CompositeBitmapGlyph(new_data, format);
+ break;
+ default:
+ assert(false);
+ break;
+ }
+ return glyph.Detach();
+}
+
+EbdtTable::EbdtTable(Header* header, ReadableFontData* data)
+ : SubTableContainerTable(header, data) {
+}
+
+/******************************************************************************
+ * EbdtTable::Builder class
+ ******************************************************************************/
+EbdtTable::Builder::Builder(Header* header, WritableFontData* data)
+ : SubTableContainerTable::Builder(header, data) {
+}
+
+EbdtTable::Builder::Builder(Header* header, ReadableFontData* data)
+ : SubTableContainerTable::Builder(header, data) {
+}
+
+EbdtTable::Builder::~Builder() {
+}
+
+CALLER_ATTACH FontDataTable*
+ EbdtTable::Builder::SubBuildTable(ReadableFontData* data) {
+ FontDataTablePtr table = new EbdtTable(header(), data);
+ return table.Detach();
+}
+
+void EbdtTable::Builder::SubDataSet() {
+ // NOP
+}
+
+int32_t EbdtTable::Builder::SubDataSizeToSerialize() {
+ return 0;
+}
+
+bool EbdtTable::Builder::SubReadyToSerialize() {
+ return false;
+}
+
+int32_t EbdtTable::Builder::SubSerialize(WritableFontData* new_data) {
+ UNREFERENCED_PARAMETER(new_data);
+ return 0;
+}
+
+CALLER_ATTACH
+EbdtTable::Builder* EbdtTable::Builder::CreateBuilder(Header* header,
+ WritableFontData* data) {
+ Ptr<EbdtTable::Builder> builder;
+ builder = new Builder(header, data);
+ return builder.Detach();
+}
+
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/ebdt_table.h b/sfntly/table/bitmap/ebdt_table.h
new file mode 100644
index 0000000..998541e
--- /dev/null
+++ b/sfntly/table/bitmap/ebdt_table.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_EBDT_TABLE_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_EBDT_TABLE_H_
+
+#include "sfntly/table/bitmap/bitmap_glyph.h"
+#include "sfntly/table/subtable_container_table.h"
+
+namespace sfntly {
+
+class EbdtTable : public SubTableContainerTable,
+ public RefCounted<EbdtTable> {
+ public:
+ class Builder : public SubTableContainerTable::Builder,
+ public RefCounted<Builder> {
+ public:
+ // Constructor scope altered to public because C++ does not allow base
+ // class to instantiate derived class with protected constructors.
+ Builder(Header* header, WritableFontData* data);
+ Builder(Header* header, ReadableFontData* data);
+ virtual ~Builder();
+
+ virtual int32_t SubSerialize(WritableFontData* new_data);
+ virtual bool SubReadyToSerialize();
+ virtual int32_t SubDataSizeToSerialize();
+ virtual void SubDataSet();
+ virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data);
+
+ static CALLER_ATTACH Builder* CreateBuilder(Header* header,
+ WritableFontData* data);
+ };
+
+ virtual ~EbdtTable();
+ int32_t Version();
+ CALLER_ATTACH BitmapGlyph* Glyph(int32_t offset,
+ int32_t length,
+ int32_t format);
+
+ protected:
+ EbdtTable(Header* header, ReadableFontData* data);
+
+ private:
+ struct Offset {
+ enum {
+ kVersion = 0,
+ };
+ };
+};
+typedef Ptr<EbdtTable> EbdtTablePtr;
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_EBDT_TABLE_H_
diff --git a/sfntly/table/bitmap/eblc_table.cc b/sfntly/table/bitmap/eblc_table.cc
new file mode 100644
index 0000000..a198c10
--- /dev/null
+++ b/sfntly/table/bitmap/eblc_table.cc
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/eblc_table.h"
+
+namespace sfntly {
+/******************************************************************************
+ * EblcTable class
+ ******************************************************************************/
+int32_t EblcTable::Version() {
+ return data_->ReadFixed(Offset::kVersion);
+}
+
+int32_t EblcTable::NumSizes() {
+ return data_->ReadULongAsInt(Offset::kNumSizes);
+}
+
+BitmapSizeTable* EblcTable::GetBitmapSizeTable(int32_t index) {
+ if (index < 0 || index > NumSizes()) {
+#if !defined (SFNTLY_NO_EXCEPTION)
+ throw IndexOutOfBoundException(
+ "Size table index is outside the range of tables.");
+#endif
+ return NULL;
+ }
+ BitmapSizeTableList* bitmap_size_table_list = GetBitmapSizeTableList();
+ if (bitmap_size_table_list) {
+ return (*bitmap_size_table_list)[index];
+ }
+ return NULL;
+}
+
+EblcTable::EblcTable(Header* header, ReadableFontData* data)
+ : SubTableContainerTable(header, data) {
+}
+
+BitmapSizeTableList* EblcTable::GetBitmapSizeTableList() {
+ // TODO(arthurhsu): thread locking.
+ if (bitmap_size_table_.empty()) {
+ CreateBitmapSizeTable(data_, NumSizes(), &bitmap_size_table_);
+ }
+ return &bitmap_size_table_;
+}
+
+// static
+void EblcTable::CreateBitmapSizeTable(ReadableFontData* data,
+ int32_t num_sizes,
+ BitmapSizeTableList* output) {
+ assert(data);
+ assert(output);
+ for (int32_t i = 0; i < num_sizes; ++i) {
+ ReadableFontDataPtr new_data;
+ new_data.Attach(down_cast<ReadableFontData*>(
+ data->Slice(Offset::kBitmapSizeTableArrayStart +
+ i * Offset::kBitmapSizeTableLength,
+ Offset::kBitmapSizeTableLength)));
+ BitmapSizeTablePtr new_table = new BitmapSizeTable(new_data, data);
+ output->push_back(new_table);
+ }
+}
+
+/******************************************************************************
+ * EblcTable::Builder class
+ ******************************************************************************/
+EblcTable::Builder::Builder(Header* header, WritableFontData* data)
+ : SubTableContainerTable::Builder(header, data) {
+}
+
+EblcTable::Builder::Builder(Header* header, ReadableFontData* data)
+ : SubTableContainerTable::Builder(header, data) {
+}
+
+EblcTable::Builder::~Builder() {
+}
+
+int32_t EblcTable::Builder::SubSerialize(WritableFontData* new_data) {
+ UNREFERENCED_PARAMETER(new_data);
+ return 0;
+}
+
+bool EblcTable::Builder::SubReadyToSerialize() {
+ return false;
+}
+
+int32_t EblcTable::Builder::SubDataSizeToSerialize() {
+ return 0;
+}
+
+void EblcTable::Builder::SubDataSet() {
+ // NOP
+}
+
+CALLER_ATTACH
+FontDataTable* EblcTable::Builder::SubBuildTable(ReadableFontData* data) {
+ Ptr<EblcTable> new_table = new EblcTable(header(), data);
+ return new_table.Detach();
+}
+
+// static
+CALLER_ATTACH EblcTable::Builder*
+ EblcTable::Builder::CreateBuilder(Header* header, WritableFontData* data) {
+ Ptr<EblcTable::Builder> new_builder = new EblcTable::Builder(header, data);
+ return new_builder.Detach();
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/eblc_table.h b/sfntly/table/bitmap/eblc_table.h
new file mode 100644
index 0000000..bf7cb15
--- /dev/null
+++ b/sfntly/table/bitmap/eblc_table.h
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_EBLC_TABLE_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_EBLC_TABLE_H_
+
+#include "sfntly/table/bitmap/bitmap_glyph.h"
+#include "sfntly/table/bitmap/bitmap_size_table.h"
+#include "sfntly/table/subtable_container_table.h"
+
+namespace sfntly {
+
+class EblcTable : public SubTableContainerTable,
+ public RefCounted<EblcTable> {
+ public:
+ struct Offset {
+ enum {
+ // header
+ kVersion = 0,
+ kNumSizes = 4,
+
+ // bitmapSizeTable
+ kBitmapSizeTableArrayStart = 8,
+ kBitmapSizeTableLength = 48,
+ kBitmapSizeTable_indexSubTableArrayOffset = 0,
+ kBitmapSizeTable_indexTableSize = 4,
+ kBitmapSizeTable_numberOfIndexSubTables = 8,
+ kBitmapSizeTable_colorRef = 12,
+ kBitmapSizeTable_hori = 16,
+ kBitmapSizeTable_vert = 28,
+ kBitmapSizeTable_startGlyphIndex = 40,
+ kBitmapSizeTable_endGlyphIndex = 42,
+ kBitmapSizeTable_ppemX = 44,
+ kBitmapSizeTable_ppemY = 45,
+ kBitmapSizeTable_bitDepth = 46,
+ kBitmapSizeTable_flags = 47,
+
+ // sbitLineMetrics
+ kSbitLineMetricsLength = 12,
+ kSbitLineMetrics_ascender = 0,
+ kSbitLineMetrics_descender = 1,
+ kSbitLineMetrics_widthMax = 2,
+ kSbitLineMetrics_caretSlopeNumerator = 3,
+ kSbitLineMetrics_caretSlopeDenominator = 4,
+ kSbitLineMetrics_caretOffset = 5,
+ kSbitLineMetrics_minOriginSB = 6,
+ kSbitLineMetrics_minAdvanceSB = 7,
+ kSbitLineMetrics_maxBeforeBL = 8,
+ kSbitLineMetrics_minAfterBL = 9,
+ kSbitLineMetrics_pad1 = 10,
+ kSbitLineMetrics_pad2 = 11,
+
+ // indexSubTable
+ kIndexSubTableEntryLength = 8,
+ kIndexSubTableEntry_firstGlyphIndex = 0,
+ kIndexSubTableEntry_lastGlyphIndex = 2,
+ kIndexSubTableEntry_additionalOffsetToIndexSubTable = 4,
+
+ // indexSubHeader
+ kIndexSubHeaderLength = 8,
+ kIndexSubHeader_indexFormat = 0,
+ kIndexSubHeader_imageFormat = 2,
+ kIndexSubHeader_imageDataOffset = 4,
+
+ // indexSubTable - all offset relative to the subtable start
+
+ // indexSubTable1
+ kIndexSubTable1_offsetArray = kIndexSubHeaderLength,
+
+ // kIndexSubTable2
+ kIndexSubTable2Length = kIndexSubHeaderLength +
+ DataSize::kULONG +
+ BitmapGlyph::Offset::kBigGlyphMetricsLength,
+ kIndexSubTable2_imageSize = kIndexSubHeaderLength,
+ kIndexSubTable2_bigGlyphMetrics = kIndexSubTable2_imageSize + 4,
+
+ // kIndexSubTable3
+ kIndexSubTable3_offsetArray = kIndexSubHeaderLength,
+
+ // kIndexSubTable4
+ kIndexSubTable4_numGlyphs = kIndexSubHeaderLength,
+ kIndexSubTable4_glyphArray = kIndexSubTable4_numGlyphs +
+ DataSize::kULONG,
+
+ // kIndexSubTable5
+ kIndexSubTable5_imageSize = kIndexSubHeaderLength,
+ kIndexSubTable5_bigMetrics = kIndexSubTable5_imageSize +
+ DataSize::kULONG,
+ kIndexSubTable5_numGlyphs = kIndexSubTable5_bigMetrics +
+ BitmapGlyph::Offset::kBigGlyphMetricsLength,
+ kIndexSubTable5_glyphArray = kIndexSubTable5_numGlyphs +
+ DataSize::kULONG,
+
+ // codeOffsetPair
+ kCodeOffsetPairLength = 2 * DataSize::kUSHORT,
+ kCodeOffsetPair_glyphCode = 0,
+ kCodeOffsetPair_offset = DataSize::kUSHORT,
+ };
+ };
+
+ class Builder : public SubTableContainerTable::Builder,
+ public RefCounted<Builder> {
+ public:
+ // Constructor scope altered to public because C++ does not allow base
+ // class to instantiate derived class with protected constructors.
+ Builder(Header* header, WritableFontData* data);
+ Builder(Header* header, ReadableFontData* data);
+ virtual ~Builder();
+
+ virtual int32_t SubSerialize(WritableFontData* new_data);
+ virtual bool SubReadyToSerialize();
+ virtual int32_t SubDataSizeToSerialize();
+ virtual void SubDataSet();
+ virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data);
+
+ static CALLER_ATTACH Builder* CreateBuilder(Header* header,
+ WritableFontData* data);
+ };
+
+ int32_t Version();
+ int32_t NumSizes();
+ // UNIMPLEMENTED: toString()
+
+ BitmapSizeTable* GetBitmapSizeTable(int32_t index);
+
+ protected:
+ EblcTable(Header* header, ReadableFontData* data);
+
+ private:
+ BitmapSizeTableList* GetBitmapSizeTableList();
+ static void CreateBitmapSizeTable(ReadableFontData* data,
+ int32_t num_sizes,
+ BitmapSizeTableList* output);
+
+ // TODO(arthurhsu): this table must be accessed atomically.
+ BitmapSizeTableList bitmap_size_table_;
+};
+typedef Ptr<EblcTable> EblcTablePtr;
+}
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_EBLC_TABLE_H_
diff --git a/sfntly/table/bitmap/index_sub_table.cc b/sfntly/table/bitmap/index_sub_table.cc
new file mode 100644
index 0000000..329179d
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table.cc
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/index_sub_table.h"
+
+#include "sfntly/table/bitmap/eblc_table.h"
+#include "sfntly/table/bitmap/index_sub_table_format1.h"
+#include "sfntly/table/bitmap/index_sub_table_format2.h"
+#include "sfntly/table/bitmap/index_sub_table_format3.h"
+#include "sfntly/table/bitmap/index_sub_table_format4.h"
+#include "sfntly/table/bitmap/index_sub_table_format5.h"
+
+namespace sfntly {
+
+bool IndexSubTable::CheckGlyphRange(int32_t glyph_id) {
+ if (glyph_id < first_glyph_index() || glyph_id > last_glyph_index()) {
+#if !defined (SFNTLY_NO_EXCEPTION)
+ throw IndexOutOfBoundException("Glyph ID is outside of the allowed range");
+#endif
+ return false;
+ }
+ return true;
+}
+
+template <typename IndexSubTableType>
+static IndexSubTableType* CreateTable(ReadableFontData* data,
+ int32_t index_sub_table_offset,
+ int32_t first_glyph_index,
+ int32_t last_glyph_index) {
+ ReadableFontDataPtr new_data;
+ new_data.Attach(down_cast<ReadableFontData*>(
+ data->Slice(index_sub_table_offset,
+ IndexSubTableType::GetDataLength(data,
+ index_sub_table_offset,
+ first_glyph_index,
+ last_glyph_index))));
+ return new IndexSubTableType(new_data, first_glyph_index, last_glyph_index);
+}
+
+// static
+CALLER_ATTACH IndexSubTable*
+ IndexSubTable::CreateIndexSubTable(ReadableFontData* data,
+ int32_t offset_to_index_sub_table_array,
+ int32_t array_index) {
+ int32_t index_sub_table_entry_offset =
+ offset_to_index_sub_table_array +
+ array_index * EblcTable::Offset::kIndexSubTableEntryLength;
+
+ int32_t first_glyph_index =
+ data->ReadUShort(index_sub_table_entry_offset +
+ EblcTable::Offset::kIndexSubTableEntry_firstGlyphIndex);
+ int32_t last_glyph_index =
+ data->ReadUShort(index_sub_table_entry_offset +
+ EblcTable::Offset::kIndexSubTableEntry_lastGlyphIndex);
+ int32_t additional_offset_to_index_subtable = data->ReadULongAsInt(
+ index_sub_table_entry_offset +
+ EblcTable::Offset::kIndexSubTableEntry_additionalOffsetToIndexSubTable);
+
+ int32_t index_sub_table_offset = offset_to_index_sub_table_array +
+ additional_offset_to_index_subtable;
+
+ int32_t index_format = data->ReadUShort(index_sub_table_offset);
+ IndexSubTablePtr new_table;
+ ReadableFontDataPtr new_data;
+ switch (index_format) {
+ case 1:
+ new_table = CreateTable<IndexSubTableFormat1>(data,
+ index_sub_table_offset,
+ first_glyph_index,
+ last_glyph_index);
+ break;
+
+ case 2:
+ new_table = CreateTable<IndexSubTableFormat2>(data,
+ index_sub_table_offset,
+ first_glyph_index,
+ last_glyph_index);
+ break;
+
+ case 3:
+ new_table = CreateTable<IndexSubTableFormat3>(data,
+ index_sub_table_offset,
+ first_glyph_index,
+ last_glyph_index);
+ break;
+
+ case 4:
+ new_table = CreateTable<IndexSubTableFormat4>(data,
+ index_sub_table_offset,
+ first_glyph_index,
+ last_glyph_index);
+ break;
+
+ case 5:
+ new_table = CreateTable<IndexSubTableFormat5>(data,
+ index_sub_table_offset,
+ first_glyph_index,
+ last_glyph_index);
+ break;
+
+ default:
+ // Unknown format and unable to process.
+#if !defined (SFNTLY_NO_EXCEPTION)
+ throw IllegalArgumentException("Invalid Index Subtable Format");
+#endif
+ break;
+ }
+
+ return new_table.Detach();
+}
+
+IndexSubTable::IndexSubTable(ReadableFontData* data,
+ int32_t first,
+ int32_t last)
+ : SubTable(data), first_glyph_index_(first), last_glyph_index_(last) {
+ index_format_ =
+ data_->ReadUShort(EblcTable::Offset::kIndexSubHeader_indexFormat);
+ image_format_ =
+ data_->ReadUShort(EblcTable::Offset::kIndexSubHeader_imageFormat);
+ image_data_offset_ =
+ data_->ReadULongAsInt(EblcTable::Offset::kIndexSubHeader_imageDataOffset);
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/index_sub_table.h b/sfntly/table/bitmap/index_sub_table.h
new file mode 100644
index 0000000..253f165
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_H_
+
+#include <vector>
+
+#include "sfntly/table/subtable.h"
+
+namespace sfntly {
+
+class IndexSubTable : public SubTable {
+ public:
+ int32_t first_glyph_index() { return first_glyph_index_; }
+ int32_t last_glyph_index() { return last_glyph_index_; }
+ int32_t image_format() { return image_format_; }
+ int32_t image_data_offset() { return image_data_offset_; }
+
+ virtual int32_t GlyphOffset(int32_t glyph_id) = 0;
+ virtual int32_t GlyphLength(int32_t glyph_id) = 0;
+ virtual int32_t NumGlyphs() = 0;
+
+ static CALLER_ATTACH IndexSubTable*
+ CreateIndexSubTable(ReadableFontData* data,
+ int32_t offset_to_index_sub_table_array,
+ int32_t array_index);
+
+ protected:
+ // Note: the constructor does not implement offset/length form provided in
+ // Java to avoid heavy lifting in constructors. Callers to call
+ // GetDataLength() static method of the derived class to get proper
+ // length and slice ahead.
+ IndexSubTable(ReadableFontData* data, int32_t first, int32_t last);
+
+ // Note: change return type to bool in C++ since we may not throw.
+ bool CheckGlyphRange(int32_t glyph_id);
+
+ private:
+ int32_t first_glyph_index_;
+ int32_t last_glyph_index_;
+ int32_t index_format_;
+ int32_t image_format_;
+ int32_t image_data_offset_;
+};
+typedef Ptr<IndexSubTable> IndexSubTablePtr;
+typedef std::vector<IndexSubTablePtr> IndexSubTableList;
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_H_
diff --git a/sfntly/table/bitmap/index_sub_table_format1.cc b/sfntly/table/bitmap/index_sub_table_format1.cc
new file mode 100644
index 0000000..b98655a
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table_format1.cc
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/index_sub_table_format1.h"
+
+#include "sfntly/table/bitmap/eblc_table.h"
+
+namespace sfntly {
+
+// static
+int32_t IndexSubTableFormat1::GetDataLength(ReadableFontData* data,
+ int32_t offset,
+ int32_t first,
+ int32_t last) {
+ UNREFERENCED_PARAMETER(data);
+ UNREFERENCED_PARAMETER(offset);
+ return (last - first + 1 + 1) * DataSize::kULONG;
+}
+
+IndexSubTableFormat1::IndexSubTableFormat1(ReadableFontData* data,
+ int32_t first,
+ int32_t last)
+ : IndexSubTable(data, first, last) {
+}
+
+IndexSubTableFormat1::~IndexSubTableFormat1() {
+}
+
+int32_t IndexSubTableFormat1::NumGlyphs() {
+ return last_glyph_index() - first_glyph_index() + 1;
+}
+
+int32_t IndexSubTableFormat1::GlyphOffset(int32_t glyph_id) {
+ if (CheckGlyphRange(glyph_id)) {
+ return Loca(glyph_id);
+ }
+ return -1;
+}
+
+int32_t IndexSubTableFormat1::GlyphLength(int32_t glyph_id) {
+ if (CheckGlyphRange(glyph_id)) {
+ return Loca(glyph_id + 1) - Loca(glyph_id);
+ }
+ return -1;
+}
+
+int32_t IndexSubTableFormat1::Loca(int32_t loca_index) {
+ return image_data_offset() +
+ data_->ReadULongAsInt(EblcTable::Offset::kIndexSubTable1_offsetArray +
+ (loca_index - first_glyph_index()) *
+ DataSize::kULONG);
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/index_sub_table_format1.h b/sfntly/table/bitmap/index_sub_table_format1.h
new file mode 100644
index 0000000..3329bc9
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table_format1.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT1_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT1_H_
+
+#include "sfntly/table/bitmap/index_sub_table.h"
+
+namespace sfntly {
+
+class IndexSubTableFormat1 : public IndexSubTable,
+ public RefCounted<IndexSubTableFormat1> {
+ public:
+ static int32_t GetDataLength(ReadableFontData* data,
+ int32_t offset,
+ int32_t first,
+ int32_t last);
+
+ // Note: the constructor does not implement offset/length form provided in
+ // Java to avoid heavy lifting in constructors. Callers to call
+ // GetDataLength() static method of the derived class to get proper
+ // length and slice ahead.
+ IndexSubTableFormat1(ReadableFontData* data, int32_t first, int32_t last);
+ virtual ~IndexSubTableFormat1();
+
+ virtual int32_t NumGlyphs();
+ virtual int32_t GlyphOffset(int32_t glyph_id);
+ virtual int32_t GlyphLength(int32_t glyph_id);
+
+ private:
+ int32_t Loca(int32_t loca_index);
+};
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT1_H_
diff --git a/sfntly/table/bitmap/index_sub_table_format2.cc b/sfntly/table/bitmap/index_sub_table_format2.cc
new file mode 100644
index 0000000..82deef3
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table_format2.cc
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/index_sub_table_format2.h"
+
+#include "sfntly/table/bitmap/eblc_table.h"
+
+namespace sfntly {
+
+// static
+int32_t IndexSubTableFormat2::GetDataLength(ReadableFontData* data,
+ int32_t offset,
+ int32_t first,
+ int32_t last) {
+ UNREFERENCED_PARAMETER(data);
+ UNREFERENCED_PARAMETER(offset);
+ UNREFERENCED_PARAMETER(first);
+ UNREFERENCED_PARAMETER(last);
+ return EblcTable::Offset::kIndexSubTable2Length;
+}
+
+IndexSubTableFormat2::IndexSubTableFormat2(ReadableFontData* data,
+ int32_t first,
+ int32_t last)
+ : IndexSubTable(data, first, last) {
+ image_size_ =
+ data_->ReadULongAsInt(EblcTable::Offset::kIndexSubTable2_imageSize);
+}
+
+IndexSubTableFormat2::~IndexSubTableFormat2() {
+}
+
+int32_t IndexSubTableFormat2::NumGlyphs() {
+ return last_glyph_index() - first_glyph_index() + 1;
+}
+
+int32_t IndexSubTableFormat2::GlyphOffset(int32_t glyph_id) {
+ if (CheckGlyphRange(glyph_id)) {
+ return image_data_offset() + (glyph_id - first_glyph_index()) * image_size_;
+ }
+ return -1;
+}
+
+int32_t IndexSubTableFormat2::GlyphLength(int32_t glyph_id) {
+ if (CheckGlyphRange(glyph_id)) {
+ return image_size_;
+ }
+ return -1;
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/index_sub_table_format2.h b/sfntly/table/bitmap/index_sub_table_format2.h
new file mode 100644
index 0000000..b325ccd
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table_format2.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT2_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT2_H_
+
+#include "sfntly/table/bitmap/index_sub_table.h"
+
+namespace sfntly {
+
+class IndexSubTableFormat2 : public IndexSubTable,
+ public RefCounted<IndexSubTableFormat2> {
+ public:
+ static int32_t GetDataLength(ReadableFontData* data,
+ int32_t offset,
+ int32_t first,
+ int32_t last);
+
+ // Note: the constructor does not implement offset/length form provided in
+ // Java to avoid heavy lifting in constructors. Callers to call
+ // GetDataLength() static method of the derived class to get proper
+ // length and slice ahead.
+ IndexSubTableFormat2(ReadableFontData* data, int32_t first, int32_t last);
+ virtual ~IndexSubTableFormat2();
+
+ virtual int32_t NumGlyphs();
+ virtual int32_t GlyphOffset(int32_t glyph_id);
+ virtual int32_t GlyphLength(int32_t glyph_id);
+
+ private:
+ int32_t Loca(int32_t loca_index);
+
+ int32_t image_size_;
+};
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT1_H_
diff --git a/sfntly/table/bitmap/index_sub_table_format3.cc b/sfntly/table/bitmap/index_sub_table_format3.cc
new file mode 100644
index 0000000..4fa529e
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table_format3.cc
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/index_sub_table_format3.h"
+
+#include "sfntly/table/bitmap/eblc_table.h"
+
+namespace sfntly {
+
+// static
+int32_t IndexSubTableFormat3::GetDataLength(ReadableFontData* data,
+ int32_t offset,
+ int32_t first,
+ int32_t last) {
+ UNREFERENCED_PARAMETER(data);
+ UNREFERENCED_PARAMETER(offset);
+ return (last - first + 1 + 1) * DataSize::kUSHORT;
+}
+
+IndexSubTableFormat3::IndexSubTableFormat3(ReadableFontData* data,
+ int32_t first,
+ int32_t last)
+ : IndexSubTable(data, first, last) {
+}
+
+IndexSubTableFormat3::~IndexSubTableFormat3() {
+}
+
+int32_t IndexSubTableFormat3::NumGlyphs() {
+ return last_glyph_index() - first_glyph_index() + 1;
+}
+
+int32_t IndexSubTableFormat3::GlyphOffset(int32_t glyph_id) {
+ if (CheckGlyphRange(glyph_id)) {
+ return Loca(glyph_id);
+ }
+ return -1;
+}
+
+int32_t IndexSubTableFormat3::GlyphLength(int32_t glyph_id) {
+ if (CheckGlyphRange(glyph_id)) {
+ return Loca(glyph_id + 1) - Loca(glyph_id);
+ }
+ return -1;
+}
+
+int32_t IndexSubTableFormat3::Loca(int32_t loca_index) {
+ int32_t read_offset =
+ data_->ReadUShort(EblcTable::Offset::kIndexSubTable3_offsetArray +
+ (loca_index - first_glyph_index()) * DataSize::kUSHORT);
+ return image_data_offset() + read_offset;
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/index_sub_table_format3.h b/sfntly/table/bitmap/index_sub_table_format3.h
new file mode 100644
index 0000000..1e45f23
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table_format3.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT3_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT3_H_
+
+#include "sfntly/table/bitmap/index_sub_table.h"
+
+namespace sfntly {
+
+class IndexSubTableFormat3 : public IndexSubTable,
+ public RefCounted<IndexSubTableFormat3> {
+ public:
+ static int32_t GetDataLength(ReadableFontData* data,
+ int32_t offset,
+ int32_t first,
+ int32_t last);
+
+ // Note: the constructor does not implement offset/length form provided in
+ // Java to avoid heavy lifting in constructors. Callers to call
+ // GetDataLength() static method of the derived class to get proper
+ // length and slice ahead.
+ IndexSubTableFormat3(ReadableFontData* data, int32_t first, int32_t last);
+ virtual ~IndexSubTableFormat3();
+
+ virtual int32_t NumGlyphs();
+ virtual int32_t GlyphOffset(int32_t glyph_id);
+ virtual int32_t GlyphLength(int32_t glyph_id);
+
+ private:
+ int32_t Loca(int32_t loca_index);
+};
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT3_H_
diff --git a/sfntly/table/bitmap/index_sub_table_format4.cc b/sfntly/table/bitmap/index_sub_table_format4.cc
new file mode 100644
index 0000000..9ef681c
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table_format4.cc
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/index_sub_table_format4.h"
+
+#include "sfntly/table/bitmap/eblc_table.h"
+
+namespace sfntly {
+
+// static
+int32_t IndexSubTableFormat4::GetDataLength(ReadableFontData* data,
+ int32_t offset,
+ int32_t first,
+ int32_t last) {
+ UNREFERENCED_PARAMETER(first);
+ UNREFERENCED_PARAMETER(last);
+ assert(data);
+ return data->ReadULongAsInt(offset +
+ EblcTable::Offset::kIndexSubTable4_numGlyphs) *
+ EblcTable::Offset::kCodeOffsetPairLength;
+}
+
+IndexSubTableFormat4::IndexSubTableFormat4(ReadableFontData* data,
+ int32_t first,
+ int32_t last)
+ : IndexSubTable(data, first, last) {
+}
+
+IndexSubTableFormat4::~IndexSubTableFormat4() {
+}
+
+int32_t IndexSubTableFormat4::NumGlyphs() {
+ return data_->ReadULongAsInt(EblcTable::Offset::kIndexSubTable4_numGlyphs);
+}
+
+int32_t IndexSubTableFormat4::GlyphOffset(int32_t glyph_id) {
+ if (CheckGlyphRange(glyph_id)) {
+ int32_t pair_index = FindCodeOffsetPair(glyph_id);
+ if (pair_index < 0) {
+ return -1;
+ }
+ return data_->ReadUShort(
+ EblcTable::Offset::kIndexSubTable4_glyphArray +
+ pair_index * EblcTable::Offset::kCodeOffsetPairLength +
+ EblcTable::Offset::kCodeOffsetPair_offset);
+ }
+ return -1;
+}
+
+int32_t IndexSubTableFormat4::GlyphLength(int32_t glyph_id) {
+ if (CheckGlyphRange(glyph_id)) {
+ int32_t pair_index = FindCodeOffsetPair(glyph_id);
+ if (pair_index < 0) {
+ return -1;
+ }
+ return data_->ReadUShort(
+ EblcTable::Offset::kIndexSubTable4_glyphArray +
+ (pair_index + 1) * EblcTable::Offset::kCodeOffsetPairLength +
+ EblcTable::Offset::kCodeOffsetPair_offset) -
+ data_->ReadUShort(
+ EblcTable::Offset::kIndexSubTable4_glyphArray +
+ (pair_index) * EblcTable::Offset::kCodeOffsetPairLength +
+ EblcTable::Offset::kCodeOffsetPair_offset);
+ }
+ return -1;
+}
+
+int32_t IndexSubTableFormat4::FindCodeOffsetPair(int32_t glyph_id) {
+ return data_->SearchUShort(EblcTable::Offset::kIndexSubTable4_glyphArray,
+ EblcTable::Offset::kCodeOffsetPairLength,
+ NumGlyphs(),
+ glyph_id);
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/index_sub_table_format4.h b/sfntly/table/bitmap/index_sub_table_format4.h
new file mode 100644
index 0000000..821acca
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table_format4.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT4_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT4_H_
+
+#include "sfntly/table/bitmap/index_sub_table.h"
+
+namespace sfntly {
+
+class IndexSubTableFormat4 : public IndexSubTable,
+ public RefCounted<IndexSubTableFormat4> {
+ public:
+ static int32_t GetDataLength(ReadableFontData* data,
+ int32_t offset,
+ int32_t first,
+ int32_t last);
+
+ // Note: the constructor does not implement offset/length form provided in
+ // Java to avoid heavy lifting in constructors. Callers to call
+ // GetDataLength() static method of the derived class to get proper
+ // length and slice ahead.
+ IndexSubTableFormat4(ReadableFontData* data, int32_t first, int32_t last);
+ virtual ~IndexSubTableFormat4();
+
+ virtual int32_t NumGlyphs();
+ virtual int32_t GlyphOffset(int32_t glyph_id);
+ virtual int32_t GlyphLength(int32_t glyph_id);
+
+ private:
+ int32_t FindCodeOffsetPair(int32_t glyph_id);
+};
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT4_H_
diff --git a/sfntly/table/bitmap/index_sub_table_format5.cc b/sfntly/table/bitmap/index_sub_table_format5.cc
new file mode 100644
index 0000000..a2aed5c
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table_format5.cc
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/index_sub_table_format5.h"
+
+#include "sfntly/table/bitmap/eblc_table.h"
+
+namespace sfntly {
+
+// static
+int32_t IndexSubTableFormat5::GetDataLength(ReadableFontData* data,
+ int32_t offset,
+ int32_t first,
+ int32_t last) {
+ UNREFERENCED_PARAMETER(first);
+ UNREFERENCED_PARAMETER(last);
+ assert(data);
+ return data->ReadULongAsInt(offset +
+ EblcTable::Offset::kIndexSubTable5_numGlyphs) *
+ EblcTable::Offset::kCodeOffsetPairLength;
+}
+
+IndexSubTableFormat5::IndexSubTableFormat5(ReadableFontData* data,
+ int32_t first,
+ int32_t last)
+ : IndexSubTable(data, first, last) {
+}
+
+IndexSubTableFormat5::~IndexSubTableFormat5() {
+}
+
+int32_t IndexSubTableFormat5::NumGlyphs() {
+ return data_->ReadULongAsInt(EblcTable::Offset::kIndexSubTable5_numGlyphs);
+}
+
+int32_t IndexSubTableFormat5::GlyphOffset(int32_t glyph_id) {
+ if (CheckGlyphRange(glyph_id)) {
+ return data_->ReadUShort(
+ EblcTable::Offset::kIndexSubTable5_glyphArray +
+ glyph_id * DataSize::kUSHORT);
+ }
+ return -1;
+}
+
+int32_t IndexSubTableFormat5::GlyphLength(int32_t glyph_id) {
+ if (CheckGlyphRange(glyph_id)) {
+ return data_->ReadULongAsInt(EblcTable::Offset::kIndexSubTable5_imageSize);
+ }
+ return -1;
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/index_sub_table_format5.h b/sfntly/table/bitmap/index_sub_table_format5.h
new file mode 100644
index 0000000..354834e
--- /dev/null
+++ b/sfntly/table/bitmap/index_sub_table_format5.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT5_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT5_H_
+
+#include "sfntly/table/bitmap/index_sub_table.h"
+
+namespace sfntly {
+
+class IndexSubTableFormat5 : public IndexSubTable,
+ public RefCounted<IndexSubTableFormat5> {
+ public:
+ static int32_t GetDataLength(ReadableFontData* data,
+ int32_t offset,
+ int32_t first,
+ int32_t last);
+
+ // Note: the constructor does not implement offset/length form provided in
+ // Java to avoid heavy lifting in constructors. Callers to call
+ // GetDataLength() static method of the derived class to get proper
+ // length and slice ahead.
+ IndexSubTableFormat5(ReadableFontData* data, int32_t first, int32_t last);
+ virtual ~IndexSubTableFormat5();
+
+ virtual int32_t NumGlyphs();
+ virtual int32_t GlyphOffset(int32_t glyph_id);
+ virtual int32_t GlyphLength(int32_t glyph_id);
+};
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT5_H_
diff --git a/sfntly/table/bitmap/simple_bitmap_glyph.cc b/sfntly/table/bitmap/simple_bitmap_glyph.cc
new file mode 100644
index 0000000..85364fd
--- /dev/null
+++ b/sfntly/table/bitmap/simple_bitmap_glyph.cc
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 = the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/bitmap/simple_bitmap_glyph.h"
+
+namespace sfntly {
+
+SimpleBitmapGlyph::SimpleBitmapGlyph(ReadableFontData* data, int32_t format)
+ : BitmapGlyph(data, format) {
+}
+
+SimpleBitmapGlyph::~SimpleBitmapGlyph() {
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/bitmap/simple_bitmap_glyph.h b/sfntly/table/bitmap/simple_bitmap_glyph.h
new file mode 100644
index 0000000..48bca98
--- /dev/null
+++ b/sfntly/table/bitmap/simple_bitmap_glyph.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 = the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_SIMPLE_BITMAP_GLYPH_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_SIMPLE_BITMAP_GLYPH_H_
+
+#include "sfntly/table/bitmap/bitmap_glyph.h"
+
+namespace sfntly {
+
+class SimpleBitmapGlyph : public BitmapGlyph,
+ public RefCounted<SimpleBitmapGlyph> {
+ public:
+ SimpleBitmapGlyph(ReadableFontData* data, int32_t format);
+ virtual ~SimpleBitmapGlyph();
+};
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_SIMPLE_BITMAP_GLYPH_H_
diff --git a/sfntly/table/core/font_header_table.cc b/sfntly/table/core/font_header_table.cc
index 3713b02..60015ca 100644
--- a/sfntly/table/core/font_header_table.cc
+++ b/sfntly/table/core/font_header_table.cc
@@ -103,11 +103,11 @@ FontHeaderTable::FontHeaderTable(Header* header, ReadableFontData* data)
* FontHeaderTable::Builder class
******************************************************************************/
FontHeaderTable::Builder::Builder(Header* header, WritableFontData* data)
- : Table::TableBasedTableBuilder(header, data) {
+ : TableBasedTableBuilder(header, data) {
}
FontHeaderTable::Builder::Builder(Header* header, ReadableFontData* data)
- : Table::TableBasedTableBuilder(header, data) {
+ : TableBasedTableBuilder(header, data) {
}
FontHeaderTable::Builder::~Builder() {}
diff --git a/sfntly/table/core/font_header_table.h b/sfntly/table/core/font_header_table.h
index 3b20863..841955b 100644
--- a/sfntly/table/core/font_header_table.h
+++ b/sfntly/table/core/font_header_table.h
@@ -18,6 +18,7 @@
#define SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_FONT_HEADER_TABLE_H_
#include "sfntly/table/table.h"
+#include "sfntly/table/table_based_table_builder.h"
namespace sfntly {
@@ -40,8 +41,7 @@ struct FontDirectionHint {
class FontHeaderTable : public Table, public RefCounted<FontHeaderTable> {
public:
- class Builder : public Table::TableBasedTableBuilder,
- public RefCounted<Builder> {
+ class Builder : public TableBasedTableBuilder, public RefCounted<Builder> {
public:
// Constructor scope altered to public because C++ does not allow base
// class to instantiate derived class with protected constructors.
diff --git a/sfntly/table/core/horizontal_header_table.cc b/sfntly/table/core/horizontal_header_table.cc
index f07ab01..43c2058 100644
--- a/sfntly/table/core/horizontal_header_table.cc
+++ b/sfntly/table/core/horizontal_header_table.cc
@@ -83,11 +83,11 @@ HorizontalHeaderTable:: HorizontalHeaderTable(Header* header,
* HorizontalHeaderTable::Builder class
******************************************************************************/
HorizontalHeaderTable::Builder::Builder(Header* header, WritableFontData* data)
- : Table::TableBasedTableBuilder(header, data) {
+ : TableBasedTableBuilder(header, data) {
}
HorizontalHeaderTable::Builder::Builder(Header* header, ReadableFontData* data)
- : Table::TableBasedTableBuilder(header, data) {
+ : TableBasedTableBuilder(header, data) {
}
HorizontalHeaderTable::Builder::~Builder() {}
diff --git a/sfntly/table/core/horizontal_header_table.h b/sfntly/table/core/horizontal_header_table.h
index c79a7b6..71f30b4 100644
--- a/sfntly/table/core/horizontal_header_table.h
+++ b/sfntly/table/core/horizontal_header_table.h
@@ -18,6 +18,7 @@
#define SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_HORIZONTAL_HEADER_TABLE_H_
#include "sfntly/table/table.h"
+#include "sfntly/table/table_based_table_builder.h"
namespace sfntly {
@@ -26,8 +27,7 @@ class HorizontalHeaderTable : public Table,
public RefCounted<HorizontalHeaderTable> {
public:
// Builder for a Horizontal Header table - 'hhea'.
- class Builder : public Table::TableBasedTableBuilder,
- public RefCounted<Builder> {
+ class Builder : public TableBasedTableBuilder, public RefCounted<Builder> {
public:
// Constructor scope altered to public because C++ does not allow base
// class to instantiate derived class with protected constructors.
diff --git a/sfntly/table/core/horizontal_metrics_table.cc b/sfntly/table/core/horizontal_metrics_table.cc
index 67e99e0..156387d 100644
--- a/sfntly/table/core/horizontal_metrics_table.cc
+++ b/sfntly/table/core/horizontal_metrics_table.cc
@@ -94,15 +94,11 @@ HorizontalMetricsTable::HorizontalMetricsTable(Header* header,
* HorizontalMetricsTable::Builder class
******************************************************************************/
HorizontalMetricsTable::Builder::Builder(Header* header, WritableFontData* data)
- : Table::TableBasedTableBuilder(header, data),
- num_hmetrics_(-1),
- num_glyphs_(-1) {
+ : TableBasedTableBuilder(header, data), num_hmetrics_(-1), num_glyphs_(-1) {
}
HorizontalMetricsTable::Builder::Builder(Header* header, ReadableFontData* data)
- : Table::TableBasedTableBuilder(header, data),
- num_hmetrics_(-1),
- num_glyphs_(-1) {
+ : TableBasedTableBuilder(header, data), num_hmetrics_(-1), num_glyphs_(-1) {
}
HorizontalMetricsTable::Builder::~Builder() {}
diff --git a/sfntly/table/core/horizontal_metrics_table.h b/sfntly/table/core/horizontal_metrics_table.h
index eaf79e4..44b51f2 100644
--- a/sfntly/table/core/horizontal_metrics_table.h
+++ b/sfntly/table/core/horizontal_metrics_table.h
@@ -18,6 +18,7 @@
#define SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_HORIZONTAL_METRICS_TABLE_H_
#include "sfntly/table/table.h"
+#include "sfntly/table/table_based_table_builder.h"
namespace sfntly {
@@ -26,8 +27,7 @@ class HorizontalMetricsTable : public Table,
public RefCounted<HorizontalMetricsTable> {
public:
// Builder for a Horizontal Metrics Table - 'hmtx'.
- class Builder : public Table::TableBasedTableBuilder,
- public RefCounted<Builder> {
+ class Builder : public TableBasedTableBuilder, public RefCounted<Builder> {
public:
// Constructor scope altered to public because C++ does not allow base
// class to instantiate derived class with protected constructors.
diff --git a/sfntly/table/core/maximum_profile_table.cc b/sfntly/table/core/maximum_profile_table.cc
index e457621..a8ac3bc 100644
--- a/sfntly/table/core/maximum_profile_table.cc
+++ b/sfntly/table/core/maximum_profile_table.cc
@@ -87,11 +87,11 @@ MaximumProfileTable::MaximumProfileTable(Header* header,
* MaximumProfileTable::Builder class
******************************************************************************/
MaximumProfileTable::Builder::Builder(Header* header, WritableFontData* data)
- : Table::TableBasedTableBuilder(header, data) {
+ : TableBasedTableBuilder(header, data) {
}
MaximumProfileTable::Builder::Builder(Header* header, ReadableFontData* data)
- : Table::TableBasedTableBuilder(header, data) {
+ : TableBasedTableBuilder(header, data) {
}
MaximumProfileTable::Builder::~Builder() {}
diff --git a/sfntly/table/core/maximum_profile_table.h b/sfntly/table/core/maximum_profile_table.h
index 9b89617..e7c5abb 100644
--- a/sfntly/table/core/maximum_profile_table.h
+++ b/sfntly/table/core/maximum_profile_table.h
@@ -19,6 +19,7 @@
#include "sfntly/port/refcount.h"
#include "sfntly/table/table.h"
+#include "sfntly/table/table_based_table_builder.h"
namespace sfntly {
@@ -27,8 +28,7 @@ class MaximumProfileTable : public Table,
public RefCounted<MaximumProfileTable> {
public:
// Builder for a Maximum Profile table - 'maxp'.
- class Builder : public Table::TableBasedTableBuilder,
- public RefCounted<Builder> {
+ class Builder : public TableBasedTableBuilder, public RefCounted<Builder> {
public:
// Constructor scope altered to public because C++ does not allow base
// class to instantiate derived class with protected constructors.
diff --git a/sfntly/table/core/os2_table.cc b/sfntly/table/core/os2_table.cc
index 024b03a..7ca9d9a 100644
--- a/sfntly/table/core/os2_table.cc
+++ b/sfntly/table/core/os2_table.cc
@@ -261,12 +261,12 @@ OS2Table::OS2Table(Header* header, ReadableFontData* data)
/******************************************************************************
* class OS2Table::Builder
******************************************************************************/
-OS2Table::Builder::Builder(Header* header, WritableFontData* data) :
- Table::TableBasedTableBuilder(header, data) {
+OS2Table::Builder::Builder(Header* header, WritableFontData* data)
+ : TableBasedTableBuilder(header, data) {
}
-OS2Table::Builder::Builder(Header* header, ReadableFontData* data) :
- Table::TableBasedTableBuilder(header, data) {
+OS2Table::Builder::Builder(Header* header, ReadableFontData* data)
+ : TableBasedTableBuilder(header, data) {
}
OS2Table::Builder::~Builder() {}
@@ -476,12 +476,13 @@ void OS2Table::Builder::AchVendId(ByteVector* b) {
void OS2Table::Builder::SetAchVendId(ByteVector* b) {
assert(b);
assert(b->size());
- InternalWriteData()->WriteBytes(Offset::kAchVendId,
- &((*b)[0]),
- 0,
- std::min<size_t>(
- (size_t)Offset::kAchVendIdLength,
- b->size()));
+ InternalWriteData()->WriteBytesPad(Offset::kAchVendId,
+ b,
+ 0,
+ std::min<size_t>(
+ (size_t)Offset::kAchVendIdLength,
+ b->size()),
+ static_cast<byte_t>(' '));
}
int32_t OS2Table::Builder::FsSelection() {
diff --git a/sfntly/table/core/os2_table.h b/sfntly/table/core/os2_table.h
index cd34ff8..00d26d2 100644
--- a/sfntly/table/core/os2_table.h
+++ b/sfntly/table/core/os2_table.h
@@ -19,6 +19,7 @@
#include "sfntly/port/refcount.h"
#include "sfntly/table/table.h"
+#include "sfntly/table/table_based_table_builder.h"
namespace sfntly {
@@ -312,8 +313,7 @@ struct CodePageRange {
class OS2Table : public Table, public RefCounted<OS2Table> {
public:
// A builder for the OS/2 table = 'OS/2'.
- class Builder : public Table::TableBasedTableBuilder,
- public RefCounted<Builder> {
+ class Builder : public TableBasedTableBuilder, public RefCounted<Builder> {
public:
Builder(Header* header, WritableFontData* data);
Builder(Header* header, ReadableFontData* data);
@@ -370,6 +370,10 @@ class OS2Table : public Table, public RefCounted<OS2Table> {
// UNIMPLEMENTED: EnumSet<UnicodeRange> UlUnicodeRange()
// setUlUnicodeRange(EnumSet<UnicodeRange> rangeSet)
void AchVendId(ByteVector* b);
+ // This field is 4 bytes in length and only the first 4 bytes of the byte
+ // array will be written. If the byte array is less than 4 bytes it will be
+ // padded out with space characters (0x20).
+ // @param b ach Vendor Id
void SetAchVendId(ByteVector* b);
// UNIMPLEMENTED: public EnumSet<FsSelection> fsSelection()
int32_t FsSelection();
diff --git a/sfntly/table/font_data_table.cc b/sfntly/table/font_data_table.cc
index d662e42..0197bbd 100644
--- a/sfntly/table/font_data_table.cc
+++ b/sfntly/table/font_data_table.cc
@@ -62,7 +62,9 @@ CALLER_ATTACH WritableFontData* FontDataTable::Builder::Data() {
ReadableFontDataPtr data = InternalReadData();
new_data.Attach(WritableFontData::CreateWritableFontData(
data != NULL ? data->Length() : 0));
- data->CopyTo(new_data);
+ if (data != NULL) {
+ data->CopyTo(new_data);
+ }
}
return new_data.Detach();
}
@@ -73,6 +75,7 @@ void FontDataTable::Builder::SetData(ReadableFontData* data) {
CALLER_ATTACH FontDataTable* FontDataTable::Builder::Build() {
+ FontDataTablePtr table; // NULL default table
ReadableFontDataPtr data = InternalReadData();
if (model_changed_) {
// Let subclass serialize from model.
@@ -86,12 +89,13 @@ CALLER_ATTACH FontDataTable* FontDataTable::Builder::Build() {
data = new_data;
}
- if (data == NULL) {
- return NULL; // Do not build table with NULL data.
+ if (data != NULL) {
+ table = SubBuildTable(data);
+ NotifyPostTableBuild(table);
}
- FontDataTablePtr table = SubBuildTable(data);
- NotifyPostTableBuild(table);
+ r_data_.Release();
+ w_data_.Release();
return table;
}
@@ -117,16 +121,23 @@ WritableFontData* FontDataTable::Builder::InternalWriteData() {
return w_data_.p_;
}
-FontDataTable::Builder::Builder() {
+FontDataTable::Builder::Builder()
+ : model_changed_(false),
+ contained_model_changed_(false),
+ data_changed_(false) {
}
FontDataTable::Builder::Builder(WritableFontData* data)
- : model_changed_(false), data_changed_(false) {
+ : model_changed_(false),
+ contained_model_changed_(false),
+ data_changed_(false) {
w_data_ = data;
}
FontDataTable::Builder::Builder(ReadableFontData* data)
- : model_changed_(false), data_changed_(false) {
+ : model_changed_(false),
+ contained_model_changed_(false),
+ data_changed_(false) {
r_data_ = data;
}
diff --git a/sfntly/table/header.cc b/sfntly/table/header.cc
new file mode 100644
index 0000000..672ace5
--- /dev/null
+++ b/sfntly/table/header.cc
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/header.h"
+
+namespace sfntly {
+
+/******************************************************************************
+ * Header class
+ ******************************************************************************/
+Header::Header(int32_t tag)
+ : tag_(tag),
+ offset_(0),
+ offset_valid_(false),
+ length_(0),
+ length_valid_(false),
+ checksum_(0),
+ checksum_valid_(false) {
+}
+
+Header::Header(int32_t tag, int32_t length)
+ : tag_(tag),
+ offset_(0),
+ offset_valid_(false),
+ length_(length),
+ length_valid_(true),
+ checksum_(0),
+ checksum_valid_(false) {
+}
+
+Header::Header(int32_t tag, int64_t checksum, int32_t offset, int32_t length)
+ : tag_(tag),
+ offset_(offset),
+ offset_valid_(true),
+ length_(length),
+ length_valid_(true),
+ checksum_(checksum),
+ checksum_valid_(true) {
+}
+
+Header::~Header() {}
+
+bool HeaderComparatorByOffset::operator() (const HeaderPtr lhs,
+ const HeaderPtr rhs) {
+ return lhs->offset_ > rhs->offset_;
+}
+
+bool HeaderComparatorByTag::operator() (const HeaderPtr lhs,
+ const HeaderPtr rhs) {
+ return lhs->tag_ > rhs->tag_;
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/header.h b/sfntly/table/header.h
new file mode 100644
index 0000000..117da95
--- /dev/null
+++ b/sfntly/table/header.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_HEADER_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_HEADER_H_
+
+#include "sfntly/port/refcount.h"
+
+namespace sfntly {
+
+class Header : public RefCounted<Header> {
+ public:
+ // Make a partial header with only the basic info for an empty new table.
+ explicit Header(int32_t tag);
+
+ // Make a partial header with only the basic info for a new table.
+ Header(int32_t tag, int32_t length);
+
+ // Make a full header as read from an existing font.
+ Header(int32_t tag, int64_t checksum, int32_t offset, int32_t length);
+ virtual ~Header();
+
+ // Get the table tag.
+ int32_t tag() { return tag_; }
+
+ // Get the table offset. The offset is from the start of the font file.
+ int32_t offset() { return offset_; }
+
+ // Is the offset in the header valid. The offset will not be valid if the
+ // table was constructed during building and has no physical location in a
+ // font file.
+ bool offset_valid() { return offset_valid_; }
+
+ // Get the length of the table as recorded in the table record header.
+ int32_t length() { return length_; }
+
+ // Is the length in the header valid. The length will not be valid if the
+ // table was constructed during building and has no physical location in a
+ // font file.
+ bool length_valid() { return length_valid_; }
+
+ // Get the checksum for the table as recorded in the table record header.
+ int64_t checksum() { return checksum_; }
+
+ // Is the checksum valid. The checksum will not be valid if the table was
+ // constructed during building and has no physical location in a font file.
+ // Note that this does *NOT* check the validity of the checksum against
+ // the calculated checksum for the table data.
+ bool checksum_valid() { return checksum_valid_; }
+
+ // UNIMPLEMENTED: boolean equals(Object obj)
+ // int hashCode()
+ // string toString()
+
+ private:
+ int32_t tag_;
+ int32_t offset_;
+ bool offset_valid_;
+ int32_t length_;
+ bool length_valid_;
+ int64_t checksum_;
+ bool checksum_valid_;
+
+ friend class HeaderComparatorByOffset;
+ friend class HeaderComparatorByTag;
+};
+typedef Ptr<Header> HeaderPtr;
+
+class HeaderComparator {
+ public:
+ virtual ~HeaderComparator() {}
+ virtual bool operator()(const HeaderPtr h1,
+ const HeaderPtr h2) = 0;
+};
+
+class HeaderComparatorByOffset : public HeaderComparator {
+ public:
+ virtual ~HeaderComparatorByOffset() {}
+ virtual bool operator()(const HeaderPtr h1,
+ const HeaderPtr h2);
+};
+
+class HeaderComparatorByTag : public HeaderComparator {
+ public:
+ virtual ~HeaderComparatorByTag() {}
+ virtual bool operator()(const HeaderPtr h1,
+ const HeaderPtr h2);
+};
+
+typedef std::set<HeaderPtr, HeaderComparatorByOffset> HeaderOffsetSortedSet;
+typedef std::set<HeaderPtr, HeaderComparatorByTag> HeaderTagSortedSet;
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_HEADER_H_
diff --git a/sfntly/table/table.cc b/sfntly/table/table.cc
index 10276aa..7183d38 100644
--- a/sfntly/table/table.cc
+++ b/sfntly/table/table.cc
@@ -18,6 +18,8 @@
#include "sfntly/font.h"
#include "sfntly/tag.h"
+#include "sfntly/table/bitmap/ebdt_table.h"
+#include "sfntly/table/bitmap/eblc_table.h"
#include "sfntly/table/core/cmap_table.h"
#include "sfntly/table/core/font_header_table.h"
#include "sfntly/table/core/horizontal_header_table.h"
@@ -25,6 +27,7 @@
#include "sfntly/table/core/maximum_profile_table.h"
#include "sfntly/table/core/name_table.h"
#include "sfntly/table/core/os2_table.h"
+#include "sfntly/table/table_based_table_builder.h"
#include "sfntly/table/truetype/glyph_table.h"
#include "sfntly/table/truetype/loca_table.h"
@@ -49,54 +52,6 @@ Table::Table(Header* header, ReadableFontData* data)
}
/******************************************************************************
- * Table::Header class
- ******************************************************************************/
-Table::Header::Header(int32_t tag)
- : tag_(tag),
- offset_(0),
- offset_valid_(false),
- length_(0),
- length_valid_(false),
- checksum_(0),
- checksum_valid_(false) {
-}
-
-Table::Header::Header(int32_t tag, int32_t length)
- : tag_(tag),
- offset_(0),
- offset_valid_(false),
- length_(length),
- length_valid_(true),
- checksum_(0),
- checksum_valid_(false) {
-}
-
-Table::Header::Header(int32_t tag,
- int64_t checksum,
- int32_t offset,
- int32_t length)
- : tag_(tag),
- offset_(offset),
- offset_valid_(true),
- length_(length),
- length_valid_(true),
- checksum_(checksum),
- checksum_valid_(true) {
-}
-
-Table::Header::~Header() {}
-
-bool HeaderComparatorByOffset::operator() (const TableHeaderPtr lhs,
- const TableHeaderPtr rhs) {
- return lhs->offset_ > rhs->offset_;
-}
-
-bool HeaderComparatorByTag::operator() (const TableHeaderPtr lhs,
- const TableHeaderPtr rhs) {
- return lhs->tag_ > rhs->tag_;
-}
-
-/******************************************************************************
* Table::Builder class
******************************************************************************/
Table::Builder::~Builder() {
@@ -155,12 +110,21 @@ Table::Builder* Table::Builder::GetBuilder(Header* header,
}/* else if (tag == Tag::prep) {
builder_raw = static_cast<Table::Builder*>(
ControlProgramTable::Builder::CreateBuilder(header, table_data));
+ }*/ else if (tag == Tag::EBDT || tag == Tag::bdat) {
+ builder_raw = static_cast<Table::Builder*>(
+ EbdtTable::Builder::CreateBuilder(header, table_data));
+ } else if (tag == Tag::EBLC || tag == Tag::bloc) {
+ builder_raw = static_cast<Table::Builder*>(
+ EblcTable::Builder::CreateBuilder(header, table_data));
+ }/* else if (tag == Tag::EBSC) {
+ builder_raw = static_cast<Table::Builder*>(
+ EbscTable::Builder::CreateBuilder(header, table_data));
}*/ else if (tag == Tag::bhed) {
builder_raw = static_cast<Table::Builder*>(
FontHeaderTable::Builder::CreateBuilder(header, table_data));
} else {
builder_raw = static_cast<Table::Builder*>(
- Table::GenericTableBuilder::CreateBuilder(header, table_data));
+ GenericTableBuilder::CreateBuilder(header, table_data));
}
return builder_raw;
@@ -180,76 +144,4 @@ Table::Builder::Builder(Header* header) {
header_ = header;
}
-/******************************************************************************
- * Table::TableBasedTableBuilder class
- ******************************************************************************/
-Table::TableBasedTableBuilder::~TableBasedTableBuilder() {}
-
-int32_t Table::TableBasedTableBuilder::SubSerialize(WritableFontData* data) {
- UNREFERENCED_PARAMETER(data);
- return 0;
-}
-
-bool Table::TableBasedTableBuilder::SubReadyToSerialize() {
- return false;
-}
-
-int32_t Table::TableBasedTableBuilder::SubDataSizeToSerialize() {
- return 0;
-}
-
-void Table::TableBasedTableBuilder::SubDataSet() {
- table_ = NULL;
-}
-
-CALLER_ATTACH FontDataTable* Table::TableBasedTableBuilder::Build() {
- FontDataTablePtr table = static_cast<FontDataTable*>(GetTable());
- return table.Detach();
-}
-
-Table::TableBasedTableBuilder::TableBasedTableBuilder(Header* header,
- WritableFontData* data)
- : Builder(header, data) {
-}
-
-Table::TableBasedTableBuilder::TableBasedTableBuilder(Header* header,
- ReadableFontData* data)
- : Builder(header, data) {
-}
-
-Table::TableBasedTableBuilder::TableBasedTableBuilder(Header* header)
- : Builder(header) {
-}
-
-Table* Table::TableBasedTableBuilder::GetTable() {
- if (table_ == NULL) {
- table_.Attach(down_cast<Table*>(SubBuildTable(InternalReadData())));
- }
- return table_;
-}
-
-/******************************************************************************
- * Table::GenericTableBuilder class
- ******************************************************************************/
-Table::GenericTableBuilder::GenericTableBuilder(Header* header,
- WritableFontData* data)
- : TableBasedTableBuilder(header, data) {
-}
-
-CALLER_ATTACH FontDataTable*
- Table::GenericTableBuilder::SubBuildTable(ReadableFontData* data) {
- // Note: In C++ port, we use GenericTable, the ref-counted version of Table
- UNREFERENCED_PARAMETER(data);
- FontDataTablePtr table = new GenericTable(this->header(), InternalReadData());
- return table.Detach();
-}
-
-CALLER_ATTACH Table::GenericTableBuilder*
- Table::GenericTableBuilder::CreateBuilder(Header* header,
- WritableFontData* data) {
- Ptr<Table::GenericTableBuilder> builder =
- new Table::GenericTableBuilder(header, data);
- return builder.Detach();
-}
-
} // namespace sfntly
diff --git a/sfntly/table/table.h b/sfntly/table/table.h
index 5adbfb1..6ebc22d 100644
--- a/sfntly/table/table.h
+++ b/sfntly/table/table.h
@@ -24,6 +24,7 @@
#include "sfntly/port/type.h"
#include "sfntly/table/font_data_table.h"
+#include "sfntly/table/header.h"
namespace sfntly {
class Font;
@@ -33,63 +34,6 @@ class Font;
// table for all tables which have no specific implementations.
class Table : public FontDataTable {
public:
- class Header : public RefCounted<Header> {
- public:
- // Make a partial header with only the basic info for an empty new table.
- explicit Header(int32_t tag);
-
- // Make a partial header with only the basic info for a new table.
- Header(int32_t tag, int32_t length);
-
- // Make a full header as read from an existing font.
- Header(int32_t tag, int64_t checksum, int32_t offset, int32_t length);
- virtual ~Header();
-
- // Get the table tag.
- int32_t tag() { return tag_; }
-
- // Get the table offset. The offset is from the start of the font file.
- int32_t offset() { return offset_; }
-
- // Is the offset in the header valid. The offset will not be valid if the
- // table was constructed during building and has no physical location in a
- // font file.
- bool offset_valid() { return offset_valid_; }
-
- // Get the length of the table as recorded in the table record header.
- int32_t length() { return length_; }
-
- // Is the length in the header valid. The length will not be valid if the
- // table was constructed during building and has no physical location in a
- // font file.
- bool length_valid() { return length_valid_; }
-
- // Get the checksum for the table as recorded in the table record header.
- int64_t checksum() { return checksum_; }
-
- // Is the checksum valid. The checksum will not be valid if the table was
- // constructed during building and has no physical location in a font file.
- // Note that this does *NOT* check the validity of the checksum against
- // the calculated checksum for the table data.
- bool checksum_valid() { return checksum_valid_; }
-
- // UNIMPLEMENTED: boolean equals(Object obj)
- // int hashCode()
- // string toString()
-
- private:
- int32_t tag_;
- int32_t offset_;
- bool offset_valid_;
- int32_t length_;
- bool length_valid_;
- int64_t checksum_;
- bool checksum_valid_;
-
- friend class HeaderComparatorByOffset;
- friend class HeaderComparatorByTag;
- };
-
// Note: original version is Builder<T extends Table>
// C++ template is not designed that way so plain old inheritance is
// chosen.
@@ -117,38 +61,8 @@ class Table : public FontDataTable {
Ptr<Header> header_;
};
- class TableBasedTableBuilder : public Builder {
- public:
- virtual ~TableBasedTableBuilder();
-
- virtual int32_t SubSerialize(WritableFontData* new_data);
- virtual bool SubReadyToSerialize();
- virtual int32_t SubDataSizeToSerialize();
- virtual void SubDataSet();
- virtual CALLER_ATTACH FontDataTable* Build();
-
- protected:
- TableBasedTableBuilder(Header* header, WritableFontData* data);
- TableBasedTableBuilder(Header* header, ReadableFontData* data);
- TableBasedTableBuilder(Header* header);
-
- // C++ port: renamed table() to GetTable()
- virtual Table* GetTable();
-
- // TODO(arthurhsu): style guide violation: protected member, need refactor
- Ptr<Table> table_;
- };
-
- class GenericTableBuilder : public TableBasedTableBuilder,
- public RefCounted<GenericTableBuilder> {
- public:
- GenericTableBuilder(Header* header, WritableFontData* data);
- virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data);
-
- static CALLER_ATTACH
- GenericTableBuilder* CreateBuilder(Header* header,
- WritableFontData* data);
- };
+ // Note: GenericTableBuilder moved to table_based_table_builder.h to avoid
+ // circular inclusion.
virtual ~Table();
@@ -190,43 +104,16 @@ class GenericTable : public Table, public RefCounted<GenericTable> {
};
typedef Ptr<Table> TablePtr;
-typedef Ptr<Table::Header> TableHeaderPtr;
-typedef std::vector<TableHeaderPtr> TableHeaderList;
+typedef std::vector<HeaderPtr> TableHeaderList;
typedef Ptr<Table::Builder> TableBuilderPtr;
typedef std::map<int32_t, TablePtr> TableMap;
typedef std::pair<int32_t, TablePtr> TableMapEntry;
-typedef std::map<TableHeaderPtr, WritableFontDataPtr> DataBlockMap;
-typedef std::pair<TableHeaderPtr, WritableFontDataPtr> DataBlockEntry;
+typedef std::map<HeaderPtr, WritableFontDataPtr> DataBlockMap;
+typedef std::pair<HeaderPtr, WritableFontDataPtr> DataBlockEntry;
typedef std::map<int32_t, TableBuilderPtr> TableBuilderMap;
typedef std::pair<int32_t, TableBuilderPtr> TableBuilderEntry;
-class HeaderComparator {
- public:
- virtual ~HeaderComparator() {}
- virtual bool operator()(const TableHeaderPtr h1,
- const TableHeaderPtr h2) = 0;
-};
-
-class HeaderComparatorByOffset : public HeaderComparator {
- public:
- virtual ~HeaderComparatorByOffset() {}
- virtual bool operator()(const TableHeaderPtr h1,
- const TableHeaderPtr h2);
-};
-
-class HeaderComparatorByTag : public HeaderComparator {
- public:
- virtual ~HeaderComparatorByTag() {}
- virtual bool operator()(const TableHeaderPtr h1,
- const TableHeaderPtr h2);
-};
-
-typedef std::set<TableHeaderPtr, HeaderComparatorByOffset>
- HeaderOffsetSortedSet;
-typedef std::set<TableHeaderPtr, HeaderComparatorByTag>
- HeaderTagSortedSet;
-
} // namespace sfntly
#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_TABLE_H_
diff --git a/sfntly/table/table_based_table_builder.cc b/sfntly/table/table_based_table_builder.cc
new file mode 100644
index 0000000..6e6a46a
--- /dev/null
+++ b/sfntly/table/table_based_table_builder.cc
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sfntly/table/table_based_table_builder.h"
+
+namespace sfntly {
+
+
+/******************************************************************************
+ * TableBasedTableBuilder class
+ ******************************************************************************/
+TableBasedTableBuilder::~TableBasedTableBuilder() {}
+
+int32_t TableBasedTableBuilder::SubSerialize(WritableFontData* data) {
+ UNREFERENCED_PARAMETER(data);
+ return 0;
+}
+
+bool TableBasedTableBuilder::SubReadyToSerialize() {
+ return false;
+}
+
+int32_t TableBasedTableBuilder::SubDataSizeToSerialize() {
+ return 0;
+}
+
+void TableBasedTableBuilder::SubDataSet() {
+ table_ = NULL;
+}
+
+CALLER_ATTACH FontDataTable* TableBasedTableBuilder::Build() {
+ FontDataTablePtr table = static_cast<FontDataTable*>(GetTable());
+ return table.Detach();
+}
+
+TableBasedTableBuilder::TableBasedTableBuilder(Header* header,
+ WritableFontData* data)
+ : Table::Builder(header, data) {
+}
+
+TableBasedTableBuilder::TableBasedTableBuilder(Header* header,
+ ReadableFontData* data)
+ : Table::Builder(header, data) {
+}
+
+TableBasedTableBuilder::TableBasedTableBuilder(Header* header)
+ : Table::Builder(header) {
+}
+
+Table* TableBasedTableBuilder::GetTable() {
+ if (table_ == NULL) {
+ table_.Attach(down_cast<Table*>(SubBuildTable(InternalReadData())));
+ }
+ return table_;
+}
+
+/******************************************************************************
+ * GenericTableBuilder class
+ ******************************************************************************/
+GenericTableBuilder::GenericTableBuilder(Header* header,
+ WritableFontData* data)
+ : TableBasedTableBuilder(header, data) {
+}
+
+CALLER_ATTACH FontDataTable*
+ GenericTableBuilder::SubBuildTable(ReadableFontData* data) {
+ // Note: In C++ port, we use GenericTable, the ref-counted version of Table
+ UNREFERENCED_PARAMETER(data);
+ FontDataTablePtr table = new GenericTable(this->header(), InternalReadData());
+ return table.Detach();
+}
+
+CALLER_ATTACH GenericTableBuilder*
+ GenericTableBuilder::CreateBuilder(Header* header, WritableFontData* data) {
+ Ptr<GenericTableBuilder> builder =
+ new GenericTableBuilder(header, data);
+ return builder.Detach();
+}
+
+} // namespace sfntly
diff --git a/sfntly/table/table_based_table_builder.h b/sfntly/table/table_based_table_builder.h
new file mode 100644
index 0000000..3868d46
--- /dev/null
+++ b/sfntly/table/table_based_table_builder.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_TABLE_BASED_TABLE_BUILDER_H_
+#define SFNTLY_CPP_SRC_SFNTLY_TABLE_TABLE_BASED_TABLE_BUILDER_H_
+
+#include "sfntly/table/table.h"
+
+namespace sfntly {
+
+class TableBasedTableBuilder : public Table::Builder {
+ public:
+ virtual ~TableBasedTableBuilder();
+
+ virtual int32_t SubSerialize(WritableFontData* new_data);
+ virtual bool SubReadyToSerialize();
+ virtual int32_t SubDataSizeToSerialize();
+ virtual void SubDataSet();
+ virtual CALLER_ATTACH FontDataTable* Build();
+
+ protected:
+ TableBasedTableBuilder(Header* header, WritableFontData* data);
+ TableBasedTableBuilder(Header* header, ReadableFontData* data);
+ TableBasedTableBuilder(Header* header);
+
+ // C++ port: renamed table() to GetTable()
+ virtual Table* GetTable();
+
+ // TODO(arthurhsu): style guide violation: protected member, need refactor
+ TablePtr table_;
+};
+
+class GenericTableBuilder : public TableBasedTableBuilder,
+ public RefCounted<GenericTableBuilder> {
+ public:
+ GenericTableBuilder(Header* header, WritableFontData* data);
+ virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data);
+
+ static CALLER_ATTACH
+ GenericTableBuilder* CreateBuilder(Header* header,
+ WritableFontData* data);
+};
+
+} // namespace sfntly
+
+#endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_TABLE_BASED_TABLE_BUILDER_H_
diff --git a/sfntly/tag.cc b/sfntly/tag.cc
index e3c11cd..893b74d 100644
--- a/sfntly/tag.cc
+++ b/sfntly/tag.cc
@@ -52,6 +52,17 @@ const int32_t Tag::PCLT = GenerateTag('P', 'C', 'L', 'T');
const int32_t Tag::VDMX = GenerateTag('V', 'D', 'M', 'X');
const int32_t Tag::vhea = GenerateTag('v', 'h', 'e', 'a');
const int32_t Tag::vmtx = GenerateTag('v', 'm', 't', 'x');
+const int32_t Tag::bsln = GenerateTag('b', 's', 'l', 'n');
+const int32_t Tag::feat = GenerateTag('f', 'e', 'a', 't');
+const int32_t Tag::lcar = GenerateTag('l', 'c', 'a', 'r');
+const int32_t Tag::morx = GenerateTag('m', 'o', 'r', 'x');
+const int32_t Tag::opbd = GenerateTag('o', 'p', 'b', 'd');
+const int32_t Tag::prop = GenerateTag('p', 'r', 'o', 'p');
+const int32_t Tag::Feat = GenerateTag('F', 'e', 'a', 't');
+const int32_t Tag::Glat = GenerateTag('G', 'l', 'a', 't');
+const int32_t Tag::Gloc = GenerateTag('G', 'l', 'o', 'c');
+const int32_t Tag::Sile = GenerateTag('S', 'i', 'l', 'e');
+const int32_t Tag::Silf = GenerateTag('S', 'i', 'l', 'f');
const int32_t Tag::bhed = GenerateTag('b', 'h', 'e', 'd');
const int32_t Tag::bdat = GenerateTag('b', 'd', 'a', 't');
const int32_t Tag::bloc = GenerateTag('b', 'l', 'o', 'c');
diff --git a/sfntly/tag.h b/sfntly/tag.h
index 9b50a85..87d2837 100644
--- a/sfntly/tag.h
+++ b/sfntly/tag.h
@@ -73,8 +73,20 @@ struct Tag {
static const int32_t vhea;
static const int32_t vmtx;
- // GX Tables
- // TODO(stuartg): add these tables
+ // AAT tables
+ static const int32_t bsln;
+ static const int32_t feat;
+ static const int32_t lcar;
+ static const int32_t morx;
+ static const int32_t opbd;
+ static const int32_t prop;
+
+ // Graphite tables
+ static const int32_t Feat;
+ static const int32_t Glat;
+ static const int32_t Gloc;
+ static const int32_t Sile;
+ static const int32_t Silf;
// Bitmap font tables
static const int32_t bhed;
@@ -91,10 +103,10 @@ inline int32_t GenerateTag(int32_t a, int32_t b, int32_t c, int32_t d) {
// The Caller must delete[] the returned value.
inline char* TagToString(int32_t tag) {
char *name = new char[5];
- name[0] = (char)((tag & 0xff000000) >> 24);
- name[1] = (char)((tag & 0x00ff0000) >> 16);
- name[2] = (char)((tag & 0x0000ff00) >> 8);
- name[3] = (char)(tag & 0x000000ff);
+ name[0] = static_cast<char>((tag & 0xff000000) >> 24);
+ name[1] = static_cast<char>((tag & 0x00ff0000) >> 16);
+ name[2] = static_cast<char>((tag & 0x0000ff00) >> 8);
+ name[3] = static_cast<char>(tag & 0x000000ff);
name[4] = 0;
return name;
}
diff --git a/test/bitmap_table_test.cc b/test/bitmap_table_test.cc
new file mode 100644
index 0000000..c8f239c
--- /dev/null
+++ b/test/bitmap_table_test.cc
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2011 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "gtest/gtest.h"
+#include "sfntly/font.h"
+#include "sfntly/table/bitmap/ebdt_table.h"
+#include "sfntly/table/bitmap/eblc_table.h"
+#include "test/test_data.h"
+#include "test/test_font_utils.h"
+
+namespace sfntly {
+
+const int32_t NUM_STRIKES = 4;
+const int32_t STRIKE1_ARRAY_OFFSET = 0xc8;
+const int32_t STRIKE1_INDEX_TABLE_SIZE = 0x4f4;
+const int32_t STRIKE1_NUM_INDEX_TABLES = 1;
+const int32_t STRIKE1_COLOR_REF = 0;
+const int32_t STRIKE1_START_GLYPH_INDEX = 0;
+const int32_t STRIKE1_END_GLYPH_INDEX = 623;
+const int32_t STRIKE1_PPEM_X = 10;
+const int32_t STRIKE1_PPEM_Y = 10;
+const int32_t STRIKE1_BIT_DEPTH = 1;
+const int32_t STRIKE1_FLAGS = 0x01;
+
+const int32_t STRIKE4_SUB1_IMAGE_FORMAT = 1;
+const int32_t STRIKE4_SUB1_IMAGE_DATA_OFFSET = 0x00005893;
+const int32_t STRIKE4_SUB1_GLYPH_OFFSET[] = {
+ 0x00005893, 0x00005898, 0x0000589d, 0x000058a2, 0x000058a7,
+ 0x000058b2, 0x000058c2, 0x000058d0, 0x000058de, 0x000058e6 };
+const int32_t NUM_STRIKE4_SUB1_GLYPH_OFFSET = 10; // must be 1 less
+
+bool TestReadingBitmapTable() {
+ FontFactoryPtr factory;
+ factory.Attach(FontFactory::GetInstance());
+ FontArray font_array;
+ LoadFont(SAMPLE_BITMAP_FONT, factory, &font_array);
+ FontPtr font = font_array[0];
+
+ EblcTablePtr bitmap_loca = down_cast<EblcTable*>(font->GetTable(Tag::EBLC));
+ EbdtTablePtr bitmap_table = down_cast<EbdtTable*>(font->GetTable(Tag::EBDT));
+
+ EXPECT_FALSE(bitmap_loca == NULL);
+ EXPECT_FALSE(bitmap_table == NULL);
+
+ EXPECT_EQ(bitmap_loca->NumSizes(), NUM_STRIKES);
+
+ // Strike 1
+ BitmapSizeTablePtr strike1 = bitmap_loca->GetBitmapSizeTable(0);
+ EXPECT_FALSE(strike1 == NULL);
+ EXPECT_EQ(strike1->IndexSubTableArrayOffset(), STRIKE1_ARRAY_OFFSET);
+ EXPECT_EQ(strike1->IndexTableSize(), STRIKE1_INDEX_TABLE_SIZE);
+ EXPECT_EQ(strike1->NumberOfIndexSubTables(), STRIKE1_NUM_INDEX_TABLES);
+ EXPECT_EQ(strike1->ColorRef(), STRIKE1_COLOR_REF);
+ EXPECT_EQ(strike1->StartGlyphIndex(), STRIKE1_START_GLYPH_INDEX);
+ EXPECT_EQ(strike1->EndGlyphIndex(), STRIKE1_END_GLYPH_INDEX);
+ EXPECT_EQ(strike1->PpemX(), STRIKE1_PPEM_X);
+ EXPECT_EQ(strike1->PpemY(), STRIKE1_PPEM_Y);
+ EXPECT_EQ(strike1->BitDepth(), STRIKE1_BIT_DEPTH);
+ EXPECT_EQ(strike1->FlagsAsInt(), STRIKE1_FLAGS);
+
+ // Strike 4
+ // In this test font, all strikes and all subtables have same glyphs.
+ BitmapSizeTablePtr strike4 = bitmap_loca->GetBitmapSizeTable(3);
+ EXPECT_FALSE(strike4 == NULL);
+ EXPECT_EQ(strike4->StartGlyphIndex(), STRIKE1_START_GLYPH_INDEX);
+ EXPECT_EQ(strike4->EndGlyphIndex(), STRIKE1_END_GLYPH_INDEX);
+ IndexSubTablePtr sub1 = strike4->GetIndexSubTable(0);
+ EXPECT_FALSE(sub1 == NULL);
+ EXPECT_EQ(sub1->first_glyph_index(), STRIKE1_START_GLYPH_INDEX);
+ EXPECT_EQ(sub1->last_glyph_index(), STRIKE1_END_GLYPH_INDEX);
+ EXPECT_EQ(sub1->image_format(), STRIKE4_SUB1_IMAGE_FORMAT);
+ EXPECT_EQ(sub1->image_data_offset(), STRIKE4_SUB1_IMAGE_DATA_OFFSET);
+
+ for (int32_t i = 0; i < NUM_STRIKE4_SUB1_GLYPH_OFFSET; ++i) {
+ EXPECT_EQ(sub1->GlyphOffset(i), STRIKE4_SUB1_GLYPH_OFFSET[i]);
+ }
+
+ return true;
+}
+
+} // namespace sfntly
+
+TEST(BitmapTable, All) {
+ ASSERT_TRUE(sfntly::TestReadingBitmapTable());
+}
diff --git a/test/file_io_test.cc b/test/file_io_test.cc
index e6801d5..3cec4d6 100644
--- a/test/file_io_test.cc
+++ b/test/file_io_test.cc
@@ -134,19 +134,12 @@ bool TestFontInputStreamTableLoading() {
is.Open(SAMPLE_TTF_FILE);
FontInputStream font_is(&is);
- font_is.Skip(TTF_OFFSET[SAMPLE_TTF_GDEF]);
- FontInputStream gdef_is(&font_is, TTF_LENGTH[SAMPLE_TTF_GDEF]);
- ByteVector gdef_data;
- gdef_is.Read(&gdef_data, 0, TTF_LENGTH[SAMPLE_TTF_GDEF]);
- EXPECT_EQ(memcmp(&(gdef_data[0]), TTF_GDEF_DATA,
- TTF_LENGTH[SAMPLE_TTF_GDEF]), 0);
-
- font_is.Skip(TTF_OFFSET[SAMPLE_TTF_HEAD] - font_is.position());
- FontInputStream head_is(&font_is, TTF_LENGTH[SAMPLE_TTF_HEAD]);
- ByteVector head_data;
- head_is.Read(&head_data, 0, TTF_LENGTH[SAMPLE_TTF_HEAD]);
- EXPECT_EQ(memcmp(&(head_data[0]), TTF_HEAD_DATA,
- TTF_LENGTH[SAMPLE_TTF_HEAD]), 0);
+ font_is.Skip(TTF_OFFSET[SAMPLE_TTF_FEAT]);
+ FontInputStream gdef_is(&font_is, TTF_LENGTH[SAMPLE_TTF_FEAT]);
+ ByteVector feat_data;
+ gdef_is.Read(&feat_data, 0, TTF_LENGTH[SAMPLE_TTF_FEAT]);
+ EXPECT_EQ(memcmp(&(feat_data[0]), TTF_FEAT_DATA,
+ TTF_LENGTH[SAMPLE_TTF_FEAT]), 0);
return true;
}
diff --git a/test/font_parsing_test.cc b/test/font_parsing_test.cc
index fb161a6..60c5524 100644
--- a/test/font_parsing_test.cc
+++ b/test/font_parsing_test.cc
@@ -22,6 +22,7 @@
#include "sfntly/font_factory.h"
#include "sfntly/table/core/font_header_table.h"
#include "sfntly/table/table.h"
+#include "sfntly/table/table_based_table_builder.h"
#include "sfntly/tag.h"
#include "sfntly/port/file_input_stream.h"
#include "test/test_data.h"
@@ -50,27 +51,26 @@ bool TestFontParsing() {
}
// Generic table
- Ptr<Table::GenericTableBuilder> gdef_builder =
- down_cast<Table::GenericTableBuilder*>(
- font_builder->GetTableBuilder(Tag::GDEF));
- Ptr<Table::Header> gdef_header = gdef_builder->header();
- EXPECT_EQ(gdef_header->length(), TTF_LENGTH[SAMPLE_TTF_GDEF]);
- EXPECT_EQ(gdef_header->offset(), TTF_OFFSET[SAMPLE_TTF_GDEF]);
- EXPECT_EQ(gdef_header->checksum(), TTF_CHECKSUM[SAMPLE_TTF_GDEF]);
+ Ptr<GenericTableBuilder> gdef_builder =
+ down_cast<GenericTableBuilder*>(font_builder->GetTableBuilder(Tag::feat));
+ HeaderPtr gdef_header = gdef_builder->header();
+ EXPECT_EQ(gdef_header->length(), TTF_LENGTH[SAMPLE_TTF_FEAT]);
+ EXPECT_EQ(gdef_header->offset(), TTF_OFFSET[SAMPLE_TTF_FEAT]);
+ EXPECT_EQ(gdef_header->checksum(), TTF_CHECKSUM[SAMPLE_TTF_FEAT]);
EXPECT_TRUE(gdef_header->checksum_valid());
WritableFontDataPtr wfd;
wfd.Attach(gdef_builder->Data());
ByteVector b;
- b.resize(TTF_LENGTH[SAMPLE_TTF_GDEF]);
- wfd->ReadBytes(0, &(b[0]), 0, TTF_LENGTH[SAMPLE_TTF_GDEF]);
- EXPECT_EQ(memcmp(&(b[0]), TTF_GDEF_DATA, TTF_LENGTH[SAMPLE_TTF_GDEF]), 0);
+ b.resize(TTF_LENGTH[SAMPLE_TTF_FEAT]);
+ wfd->ReadBytes(0, &(b[0]), 0, TTF_LENGTH[SAMPLE_TTF_FEAT]);
+ EXPECT_EQ(memcmp(&(b[0]), TTF_FEAT_DATA, TTF_LENGTH[SAMPLE_TTF_FEAT]), 0);
// Header table
FontHeaderTableBuilderPtr header_builder =
down_cast<FontHeaderTable::Builder*>(
font_builder->GetTableBuilder(Tag::head));
- Ptr<Table::Header> header_header = header_builder->header();
+ HeaderPtr header_header = header_builder->header();
EXPECT_EQ(header_header->length(), TTF_LENGTH[SAMPLE_TTF_HEAD]);
EXPECT_EQ(header_header->offset(), TTF_OFFSET[SAMPLE_TTF_HEAD]);
EXPECT_EQ(header_header->checksum(), TTF_CHECKSUM[SAMPLE_TTF_HEAD]);
diff --git a/test/otf_basic_editing_test.cc b/test/otf_basic_editing_test.cc
index c99a3a3..7388fac 100644
--- a/test/otf_basic_editing_test.cc
+++ b/test/otf_basic_editing_test.cc
@@ -66,7 +66,7 @@ bool TestOTFBasicEditing() {
for (TableMap::const_iterator i = table_map->begin(), e = table_map->end();
i != e; ++i) {
TablePtr table = (*i).second;
- TableHeaderPtr header = table->header();
+ HeaderPtr header = table->header();
EXPECT_TRUE(builder_tags.find(header->tag()) != builder_tags.end());
builder_tags.erase(header->tag());
}
diff --git a/test/test_data.cc b/test/test_data.cc
index e4cabbe..6c26f0e 100644
--- a/test/test_data.cc
+++ b/test/test_data.cc
@@ -26,46 +26,43 @@ namespace sfntly {
// code.
const char* SAMPLE_TTF_FILE = "Tuffy.ttf";
-const char* SAMPLE_OTF_FILE = "Tuffy.otf";
+const char* SAMPLE_BITMAP_FONT = "AnonymousPro-Regular.ttf";
-const size_t SAMPLE_TTF_SIZE = 18444;
-const size_t SAMPLE_TTF_TABLES = 16;
-const size_t SAMPLE_TTF_KNOWN_TAGS = 15;
-const size_t SAMPLE_TTF_GDEF = 0;
-const size_t SAMPLE_TTF_HEAD = 8;
+const size_t SAMPLE_TTF_SIZE = 183936;
+const size_t SAMPLE_TTF_TABLES = 17;
+const size_t SAMPLE_TTF_KNOWN_TAGS = 16;
+const size_t SAMPLE_TTF_FEAT = 3;
+const size_t SAMPLE_TTF_HEAD = 6;
const size_t SAMPLE_TTF_POST = 14;
const int32_t TTF_KNOWN_TAGS[] = {
- Tag::GDEF, Tag::GPOS, Tag::GSUB, Tag::OS_2, Tag::cmap, Tag::cvt,
- Tag::gasp, Tag::glyf, Tag::head, Tag::hhea, Tag::hmtx, Tag::loca,
- Tag::maxp, Tag::name, Tag::post };
+ Tag::OS_2, Tag::cmap, Tag::cvt, Tag::feat, Tag::gasp,
+ Tag::glyf, Tag::head, Tag::hhea, Tag::hmtx, Tag::kern,
+ Tag::loca, Tag::maxp, Tag::morx, Tag::name, Tag::post,
+ Tag::prop };
const int64_t TTF_CHECKSUM[] = {
- 0x002900cb, 0xe1b5ef99, 0x6c91748f, 0xae08cb6b, 0xc62ba2e8, 0x00210279,
- 0xffff0003, 0x8ed2ba01, 0xe8afc442, 0x0dce8e86, 0x77c44a8a, 0xbfd5cd52,
- 0x011200bc, 0x2f64d0e9, 0x6548bddf };
+ 0xD463FC48, 0x252028D1, 0x0065078A, 0xC01407B5, 0xFFFF0003,
+ 0x9544342B, 0xFC8F16AD, 0x0EC30C7A, 0xA029CD5D, 0x32513087,
+ 0x05C323B0, 0x06320195, 0x3B67E701, 0xE7DB08F3, 0xD46E5E89,
+ 0xE6EB4A27 };
const int64_t TTF_OFFSET[] = {
- 0x4650, 0x4690, 0x4670, 0x0188, 0x04f4, 0x0738,
- 0x4648, 0x08c8, 0x010c, 0x0144, 0x01e0, 0x073c,
- 0x0168, 0x3d9c, 0x4468 };
+ 0x00000198, 0x00001964, 0x000025B0, 0x0002CA74, 0x0002C854,
+ 0x00003D34, 0x0000011C, 0x00000154, 0x000001F0, 0x000245D8,
+ 0x000025B8, 0x00000178, 0x0002CAB4, 0x00024860, 0x00028854,
+ 0x0002C85C };
const int32_t TTF_LENGTH[] = {
- 0x001e, 0x015e, 0x0020, 0x0056, 0x0242, 0x0004,
- 0x0008, 0x34d4, 0x0036, 0x0024, 0x0314, 0x018c,
- 0x0020, 0x06cb, 0x01dd };
+ 86, 3146, 8, 64, 8,
+ 133284, 54, 36, 6002, 648,
+ 6012, 32, 944, 16371, 16383,
+ 536 };
-const unsigned char TTF_GDEF_DATA[] = {
- 0, 1, 0, 0, 0, 0x0c, 0, 0, 0, 0x16, 0, 0, 0, 2, 0, 1,
- 0, 3, 0, 0xc4, 0, 1, 0, 4, 0, 0, 0, 2, 0, 0 };
-
-const unsigned char TTF_HEAD_DATA[] = {
- 0, 1, 0, 0,
- 0, 1, 0x19, 0x99, 9, 6, 0x34, 0xb7, 0x5f, 0xf, 0x3c, 0xf5, 0, 0xb, 8, 0,
- 0, 0, 0, 0, 0xc1, 0xf5, 0x2f, 0xd2, 0, 0, 0, 0, 0xc1, 0xf5, 0x2f, 0xd2,
- 0xff, 0x89, 0xfe, 0x3f, 6, 0x1d, 7, 0xc9, 0, 0, 0, 8, 0, 2, 0, 0,
- 0, 0 };
-
-const size_t SAMPLE_OTF_SIZE = 18900;
+const unsigned char TTF_FEAT_DATA[] = {
+ 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ 0, 0, 0, 0x30, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0x34,
+ 0, 0, 1, 1, 0, 0xB, 0, 2, 0, 0, 0, 0x38, 0xC0, 0, 1, 2,
+ 0, 0, 1, 3, 0, 2, 1, 4, 0, 0, 1, 5, 0, 2, 1, 6 };
} // namespace sfntly
diff --git a/test/test_data.h b/test/test_data.h
index 1b50549..b6a5ed6 100644
--- a/test/test_data.h
+++ b/test/test_data.h
@@ -22,12 +22,12 @@
namespace sfntly {
extern const char* SAMPLE_TTF_FILE;
-extern const char* SAMPLE_OTF_FILE;
+extern const char* SAMPLE_BITMAP_FONT;
extern const size_t SAMPLE_TTF_SIZE;
extern const size_t SAMPLE_TTF_TABLES;
extern const size_t SAMPLE_TTF_KNOWN_TAGS;
-extern const size_t SAMPLE_TTF_GDEF;
+extern const size_t SAMPLE_TTF_FEAT;
extern const size_t SAMPLE_TTF_HEAD;
extern const size_t SAMPLE_TTF_POST;
@@ -35,10 +35,7 @@ extern const int32_t TTF_KNOWN_TAGS[];
extern const int64_t TTF_CHECKSUM[];
extern const int64_t TTF_OFFSET[];
extern const int32_t TTF_LENGTH[];
-extern const unsigned char TTF_GDEF_DATA[];
-extern const unsigned char TTF_HEAD_DATA[];
-
-extern const size_t SAMPLE_OTF_SIZE;
+extern const unsigned char TTF_FEAT_DATA[];
} // namespace sfntly
diff --git a/test/verify_glyf.cc b/test/verify_glyf.cc
index ff89638..abfe1ab 100644
--- a/test/verify_glyf.cc
+++ b/test/verify_glyf.cc
@@ -22,7 +22,7 @@
namespace sfntly {
// We spot check only glyph id 33.
-const int32_t GLYPH33_OFFSET = 0xA70;
+const int32_t GLYPH33_OFFSET = 0xAC8;
const int32_t GLYPH33_LENGTH = 40;
const int32_t GLYPH33_XMIN = 92;
const int32_t GLYPH33_YMIN = 20;
diff --git a/test/verify_hhea.cc b/test/verify_hhea.cc
index 05886d4..021c189 100644
--- a/test/verify_hhea.cc
+++ b/test/verify_hhea.cc
@@ -21,15 +21,15 @@
namespace sfntly {
-const int32_t HHEA_ASCENDER = 1993;
-const int32_t HHEA_DESCENDER = -449;
+const int32_t HHEA_ASCENDER = 2023;
+const int32_t HHEA_DESCENDER = -648;
const int32_t HHEA_LINE_GAP = 93;
-const int32_t HHEA_ADVANCE_WIDTH_MAX = 3969;
-const int32_t HHEA_MIN_LSB = -119;
-const int32_t HHEA_MIN_RSB = -32768;
-const int32_t HHEA_X_MAX_EXTENT = 1565;
+const int32_t HHEA_ADVANCE_WIDTH_MAX = 2753;
+const int32_t HHEA_MIN_LSB = -968;
+const int32_t HHEA_MIN_RSB = -411;
+const int32_t HHEA_X_MAX_EXTENT = 2628;
const int32_t HHEA_METRIC_DATA_FORMAT = 0;
-const int32_t HHEA_NUM_METRICS = 197;
+const int32_t HHEA_NUM_METRICS = 1499;
static bool VerifyHHEA(Table* table) {
HorizontalHeaderTablePtr hhea = down_cast<HorizontalHeaderTable*>(table);
diff --git a/test/verify_hmtx.cc b/test/verify_hmtx.cc
index 67ea6a3..d37bba9 100644
--- a/test/verify_hmtx.cc
+++ b/test/verify_hmtx.cc
@@ -21,8 +21,8 @@
namespace sfntly {
-const int32_t HMTX_ENTRIES_COUNT = 197;
-const int32_t HMTX_LSB_COUNT = 0;
+const int32_t HMTX_ENTRIES_COUNT = 1499;
+const int32_t HMTX_LSB_COUNT = 3;
struct HmtxEntry {
int32_t advance_width_;
@@ -33,7 +33,7 @@ struct HmtxEntry {
};
const HmtxEntry HMTX_ENTRIES[] = {
- HmtxEntry(32768, 0), // 0
+ HmtxEntry(748, 68), // 0
HmtxEntry(0, 0), // 1
HmtxEntry(682, 0), // 2
HmtxEntry(616, 0), // 3
@@ -43,196 +43,8 @@ const HmtxEntry HMTX_ENTRIES[] = {
HmtxEntry(1017, 25), // 7
HmtxEntry(1402, 104), // 8
HmtxEntry(1241, 100), // 9
- HmtxEntry(382, 129), // 10
- HmtxEntry(548, 41), // 11
- HmtxEntry(536, 90), // 12
- HmtxEntry(913, 33), // 13
- HmtxEntry(894, 78), // 14
- HmtxEntry(399, 103), // 15
- HmtxEntry(866, 109), // 16
- HmtxEntry(405, 103), // 17
- HmtxEntry(808, -23), // 18
- HmtxEntry(1136, 100), // 19
- HmtxEntry(1136, 424), // 20
- HmtxEntry(1136, 109), // 21
- HmtxEntry(1126, 113), // 22
- HmtxEntry(1136, 88), // 23
- HmtxEntry(1136, 135), // 24
- HmtxEntry(1136, 129), // 25
- HmtxEntry(1136, 111), // 26
- HmtxEntry(1136, 104), // 27
- HmtxEntry(1136, 143), // 28
- HmtxEntry(423, 113), // 29
- HmtxEntry(423, 113), // 30
- HmtxEntry(843, 84), // 31
- HmtxEntry(907, 66), // 32
- HmtxEntry(856, 92), // 33
- HmtxEntry(985, 57), // 34
- HmtxEntry(1624, 41), // 35
- HmtxEntry(1302, 72), // 36
- HmtxEntry(1179, 121), // 37
- HmtxEntry(1220, 100), // 38
- HmtxEntry(1220, 121), // 39
- HmtxEntry(1142, 121), // 40
- HmtxEntry(1146, 121), // 41
- HmtxEntry(1363, 100), // 42
- HmtxEntry(1198, 121), // 43
- HmtxEntry(444, 154), // 44
- HmtxEntry(1140, 113), // 45
- HmtxEntry(1239, 121), // 46
- HmtxEntry(1105, 121), // 47
- HmtxEntry(1562, 121), // 48
- HmtxEntry(1271, 121), // 49
- HmtxEntry(1333, 92), // 50
- HmtxEntry(1099, 121), // 51
- HmtxEntry(1370, 92), // 52
- HmtxEntry(1101, 121), // 53
- HmtxEntry(1079, 45), // 54
- HmtxEntry(1243, 88), // 55
- HmtxEntry(1265, 121), // 56
- HmtxEntry(1245, 80), // 57
- HmtxEntry(1576, 84), // 58
- HmtxEntry(1214, 74), // 59
- HmtxEntry(1179, 76), // 60
- HmtxEntry(1325, 100), // 61
- HmtxEntry(626, 131), // 62
- HmtxEntry(811, -29), // 63
- HmtxEntry(638, 129), // 64
- HmtxEntry(927, 133), // 65
- HmtxEntry(1241, 88), // 66
- HmtxEntry(516, 96), // 67
- HmtxEntry(993, 84), // 68
- HmtxEntry(1044, 129), // 69
- HmtxEntry(921, 76), // 70
- HmtxEntry(1044, 73), // 71
- HmtxEntry(1013, 98), // 72
- HmtxEntry(716, 125), // 73
- HmtxEntry(1021, 73), // 74
- HmtxEntry(1064, 129), // 75
- HmtxEntry(430, 131), // 76
- HmtxEntry(468, -119), // 77
- HmtxEntry(944, 129), // 78
- HmtxEntry(430, 150), // 79
- HmtxEntry(1533, 129), // 80
- HmtxEntry(1064, 129), // 81
- HmtxEntry(1054, 102), // 82
- HmtxEntry(1044, 129), // 83
- HmtxEntry(1048, 73), // 84
- HmtxEntry(686, 129), // 85
- HmtxEntry(921, 96), // 86
- HmtxEntry(696, 102), // 87
- HmtxEntry(1064, 120), // 88
- HmtxEntry(1024, 82), // 89
- HmtxEntry(1374, 68), // 90
- HmtxEntry(901, 53), // 91
- HmtxEntry(1064, 120), // 92
- HmtxEntry(962, 90), // 93
- HmtxEntry(747, 90), // 94
- HmtxEntry(368, 125), // 95
- HmtxEntry(747, 133), // 96
- HmtxEntry(735, 63), // 97
- HmtxEntry(309, 28), // 98
- HmtxEntry(808, 80), // 99
- HmtxEntry(1120, 84), // 100
- HmtxEntry(856, 63), // 101
- HmtxEntry(1110, 74), // 102
- HmtxEntry(305, 90), // 103
- HmtxEntry(686, 43), // 104
- HmtxEntry(794, 76), // 105
- HmtxEntry(942, 41), // 106
- HmtxEntry(872, 59), // 107
- HmtxEntry(1026, 154), // 108
- HmtxEntry(950, 109), // 109
- HmtxEntry(1189, 94), // 110
- HmtxEntry(706, 63), // 111
- HmtxEntry(598, 49), // 112
- HmtxEntry(983, 150), // 113
- HmtxEntry(550, 97), // 114
- HmtxEntry(1003, 154), // 115
- HmtxEntry(1150, 121), // 116
- HmtxEntry(438, 142), // 117
- HmtxEntry(473, 117), // 118
- HmtxEntry(933, 98), // 119
- HmtxEntry(954, 18), // 120
- HmtxEntry(1292, 82), // 121
- HmtxEntry(1292, 82), // 122
- HmtxEntry(1292, 82), // 123
- HmtxEntry(1292, 82), // 124
- HmtxEntry(1292, 82), // 125
- HmtxEntry(1292, 82), // 126
- HmtxEntry(1388, 83), // 127
- HmtxEntry(1220, 120), // 128
- HmtxEntry(1146, 131), // 129
- HmtxEntry(1146, 131), // 130
- HmtxEntry(1146, 131), // 131
- HmtxEntry(1146, 131), // 132
- HmtxEntry(440, -53), // 133
- HmtxEntry(440, 164), // 134
- HmtxEntry(440, -103), // 135
- HmtxEntry(440, -90), // 136
- HmtxEntry(3969, 144), // 137
- HmtxEntry(1292, 131), // 138
- HmtxEntry(1329, 102), // 139
- HmtxEntry(1329, 102), // 140
- HmtxEntry(1329, 102), // 141
- HmtxEntry(1329, 102), // 142
- HmtxEntry(1329, 102), // 143
- HmtxEntry(833, 108), // 144
- HmtxEntry(2416, 96), // 145
- HmtxEntry(1298, 131), // 146
- HmtxEntry(1298, 131), // 147
- HmtxEntry(1298, 131), // 148
- HmtxEntry(1298, 131), // 149
- HmtxEntry(1179, 86), // 150
- HmtxEntry(1329, 145), // 151
- HmtxEntry(1212, 92), // 152
- HmtxEntry(1036, 94), // 153
- HmtxEntry(1036, 94), // 154
- HmtxEntry(1036, 94), // 155
- HmtxEntry(1036, 94), // 156
- HmtxEntry(1036, 94), // 157
- HmtxEntry(1036, 94), // 158
- HmtxEntry(1486, 84), // 159
- HmtxEntry(1011, 86), // 160
- HmtxEntry(1046, 108), // 161
- HmtxEntry(1046, 108), // 162
- HmtxEntry(1046, 108), // 163
- HmtxEntry(1046, 108), // 164
- HmtxEntry(428, -75), // 165
- HmtxEntry(421, 150), // 166
- HmtxEntry(888, 115), // 167
- HmtxEntry(667, 8), // 168
- HmtxEntry(1030, 82), // 169
- HmtxEntry(1044, 139), // 170
- HmtxEntry(1060, 112), // 171
- HmtxEntry(1062, 112), // 172
- HmtxEntry(1062, 112), // 173
- HmtxEntry(1062, 112), // 174
- HmtxEntry(1060, 112), // 175
- HmtxEntry(911, 119), // 176
- HmtxEntry(1024, 86), // 177
- HmtxEntry(1032, 130), // 178
- HmtxEntry(1064, 130), // 179
- HmtxEntry(1064, 130), // 180
- HmtxEntry(1064, 130), // 181
- HmtxEntry(1064, 130), // 182
- HmtxEntry(1003, 129), // 183
- HmtxEntry(1064, 130), // 184
- HmtxEntry(1087, 170), // 185
- HmtxEntry(1001, 170), // 186
- HmtxEntry(1290, 150), // 187
- HmtxEntry(385, 83), // 188
- HmtxEntry(385, 95), // 189
- HmtxEntry(385, 99), // 190
- HmtxEntry(385, 106), // 191
- HmtxEntry(677, 81), // 192
- HmtxEntry(677, 97), // 193
- HmtxEntry(688, 113), // 194
- HmtxEntry(688, 91), // 195
- HmtxEntry(1089, 135), // 196
-
- HmtxEntry(32768, 0) // 197: no such element, used to check the logic.
};
+const int32_t NUM_HMTX_ENTRIES = 10;
static bool VerifyHMTX(Table* table) {
HorizontalMetricsTablePtr hmtx = down_cast<HorizontalMetricsTable*>(table);
@@ -243,11 +55,15 @@ static bool VerifyHMTX(Table* table) {
EXPECT_EQ(hmtx->NumberOfHMetrics(), HMTX_ENTRIES_COUNT);
EXPECT_EQ(hmtx->NumberOfLSBs(), HMTX_LSB_COUNT);
- for (int32_t i = 0; i < HMTX_ENTRIES_COUNT + 1; ++i) {
+ for (int32_t i = 0; i < NUM_HMTX_ENTRIES; ++i) {
EXPECT_EQ(hmtx->AdvanceWidth(i), HMTX_ENTRIES[i].advance_width_);
EXPECT_EQ(hmtx->LeftSideBearing(i), HMTX_ENTRIES[i].lsb_);
}
+ // No such element case.
+ EXPECT_EQ(hmtx->AdvanceWidth(HMTX_ENTRIES_COUNT),
+ HMTX_ENTRIES[0].advance_width_);
+ EXPECT_EQ(hmtx->LeftSideBearing(HMTX_ENTRIES_COUNT), HMTX_ENTRIES[0].lsb_);
return true;
}
diff --git a/test/verify_loca.cc b/test/verify_loca.cc
index 3090841..4a32928 100644
--- a/test/verify_loca.cc
+++ b/test/verify_loca.cc
@@ -21,207 +21,21 @@
namespace sfntly {
-const int32_t LOCA_NUM_LOCAS = 198;
+const int32_t LOCA_NUM_LOCAS = 1503;
const int32_t LOCAS[] = {
0x00000, // 0
- 0x00000, // 1
- 0x00000, // 2
- 0x00000, // 3
- 0x00000, // 4
- 0x00060, // 5
- 0x000E0, // 6
- 0x0014C, // 7
- 0x001FC, // 8
- 0x002C8, // 9
- 0x00358, // 10
- 0x0039C, // 11
- 0x003D4, // 12
- 0x0040C, // 13
- 0x004B4, // 14
- 0x004E4, // 15
- 0x00530, // 16
- 0x0054C, // 17
- 0x00584, // 18
- 0x005A0, // 19
- 0x0061C, // 20
- 0x0063C, // 21
- 0x006C4, // 22
- 0x0074C, // 23
- 0x0078C, // 24
- 0x00804, // 25
- 0x00888, // 26
- 0x008AC, // 27
- 0x0096C, // 28
- 0x009F0, // 29
- 0x00A08, // 30
- 0x00A20, // 31
- 0x00A48, // 32
- 0x00A70, // 33
- 0x00A98, // 34
- 0x00B44, // 35
- 0x00C40, // 36
- 0x00C78, // 37
- 0x00D24, // 38
- 0x00D9C, // 39
- 0x00DF8, // 40
- 0x00E28, // 41
- 0x00E54, // 42
- 0x00EDC, // 43
- 0x00F0C, // 44
- 0x00F24, // 45
- 0x00F6C, // 46
- 0x00FA4, // 47
- 0x00FC4, // 48
- 0x00FFC, // 49
- 0x01028, // 50
- 0x010BC, // 51
- 0x01114, // 52
- 0x011C0, // 53
- 0x0121C, // 54
- 0x012C0, // 55
- 0x012E8, // 56
- 0x0133C, // 57
- 0x01364, // 58
- 0x013A0, // 59
- 0x013E0, // 60
- 0x01410, // 61
- 0x0143C, // 62
- 0x01460, // 63
- 0x01480, // 64
- 0x014A4, // 65
- 0x014C8, // 66
- 0x014E0, // 67
- 0x0152C, // 68
- 0x015AC, // 69
- 0x01618, // 70
- 0x01680, // 71
- 0x016EC, // 72
- 0x0175C, // 73
- 0x017B0, // 74
- 0x01848, // 75
- 0x01898, // 76
- 0x018DC, // 77
- 0x01948, // 78
- 0x01980, // 79
- 0x019B0, // 80
- 0x01A28, // 81
- 0x01A74, // 82
- 0x01AE0, // 83
- 0x01B4C, // 84
- 0x01BC0, // 85
- 0x01BFC, // 86
- 0x01C94, // 87
- 0x01CCC, // 88
- 0x01D1C, // 89
- 0x01D48, // 90
- 0x01D84, // 91
- 0x01DBC, // 92
- 0x01E2C, // 93
- 0x01E54, // 94
- 0x01F04, // 95
- 0x01F1C, // 96
- 0x01FCC, // 97
- 0x02028, // 98
- 0x02044, // 99
- 0x020AC, // 100
- 0x02128, // 101
- 0x021B8, // 102
- 0x0220C, // 103
- 0x02234, // 104
- 0x022E0, // 105
- 0x02348, // 106
- 0x023F4, // 107
- 0x02430, // 108
- 0x02450, // 109
- 0x02464, // 110
- 0x02540, // 111
- 0x0255C, // 112
- 0x025C0, // 113
- 0x025DC, // 114
- 0x02628, // 115
- 0x02680, // 116
- 0x0270C, // 117
- 0x02720, // 118
- 0x02768, // 119
- 0x027A4, // 120
- 0x027B8, // 121
- 0x027D0, // 122
- 0x027E8, // 123
- 0x02800, // 124
- 0x02818, // 125
- 0x02830, // 126
- 0x02848, // 127
- 0x02898, // 128
- 0x028B0, // 129
- 0x028C8, // 130
- 0x028E0, // 131
- 0x028F8, // 132
- 0x02910, // 133
- 0x02928, // 134
- 0x02940, // 135
- 0x02958, // 136
- 0x02970, // 137
- 0x029D8, // 138
- 0x029F0, // 139
- 0x02A08, // 140
- 0x02A20, // 141
- 0x02A38, // 142
- 0x02A50, // 143
- 0x02A68, // 144
- 0x02A84, // 145
- 0x02B30, // 146
- 0x02B48, // 147
- 0x02B60, // 148
- 0x02B78, // 149
- 0x02B90, // 150
- 0x02BA8, // 151
- 0x02C00, // 152
- 0x02CCC, // 153
- 0x02CE4, // 154
- 0x02CFC, // 155
- 0x02D14, // 156
- 0x02D2C, // 157
- 0x02D44, // 158
- 0x02D5C, // 159
- 0x02E6C, // 160
- 0x02E84, // 161
- 0x02E9C, // 162
- 0x02EB4, // 163
- 0x02ECC, // 164
- 0x02EE4, // 165
- 0x02F3C, // 166
- 0x02F94, // 167
- 0x02FC8, // 168
- 0x0303C, // 169
- 0x030FC, // 170
- 0x03114, // 171
- 0x0312C, // 172
- 0x03144, // 173
- 0x0315C, // 174
- 0x03174, // 175
- 0x0318C, // 176
- 0x031A4, // 177
- 0x03240, // 178
- 0x03258, // 179
- 0x03270, // 180
- 0x03288, // 181
- 0x032A0, // 182
- 0x032B8, // 183
- 0x0333C, // 184
- 0x03354, // 185
- 0x03370, // 186
- 0x0338C, // 187
- 0x033A8, // 188
- 0x033BC, // 189
- 0x033D0, // 190
- 0x033E4, // 191
- 0x033F4, // 192
- 0x0340C, // 193
- 0x03424, // 194
- 0x03438, // 195
- 0x03448, // 196
- 0x034D4 // 197
+ 0x00058, // 1
+ 0x00058, // 2
+ 0x00058, // 3
+ 0x00058, // 4
+ 0x000B8, // 5
+ 0x00138, // 6
+ 0x001A4, // 7
+ 0x0025C, // 8
+ 0x00328, // 9
+ 0x003B8, // 10
};
+const int32_t NUM_TEST_LOCAS = 11;
static bool VerifyLOCA(Table* table) {
LocaTablePtr loca = down_cast<LocaTable*>(table);
@@ -232,7 +46,7 @@ static bool VerifyLOCA(Table* table) {
EXPECT_EQ(loca->NumLocas(), LOCA_NUM_LOCAS);
EXPECT_EQ(loca->num_glyphs(), LOCA_NUM_LOCAS - 1);
- for (int32_t i = 0; i < LOCA_NUM_LOCAS - 1; ++i) {
+ for (int32_t i = 0; i < NUM_TEST_LOCAS - 1; ++i) {
EXPECT_EQ(loca->GlyphOffset(i), LOCAS[i]);
EXPECT_EQ(loca->GlyphLength(i), LOCAS[i + 1] - LOCAS[i]);
}
diff --git a/test/verify_maxp.cc b/test/verify_maxp.cc
index 3b8e183..437c0dd 100644
--- a/test/verify_maxp.cc
+++ b/test/verify_maxp.cc
@@ -21,19 +21,19 @@
namespace sfntly {
-const int32_t MAXP_NUM_GLYPHS = 197;
-const int32_t MAXP_MAX_POINTS = 98;
-const int32_t MAXP_MAX_CONTOURS = 5;
-const int32_t MAXP_MAX_COMPOSITE_POINTS = 84;
-const int32_t MAXP_MAX_COMPOSITE_CONTOURS = 4;
+const int32_t MAXP_NUM_GLYPHS = 1502;
+const int32_t MAXP_MAX_POINTS = 181;
+const int32_t MAXP_MAX_CONTOURS = 9;
+const int32_t MAXP_MAX_COMPOSITE_POINTS = 172;
+const int32_t MAXP_MAX_COMPOSITE_CONTOURS = 5;
const int32_t MAXP_MAX_ZONES = 2;
const int32_t MAXP_MAX_TWILIGHT_POINTS = 0;
const int32_t MAXP_MAX_STORAGE = 1;
const int32_t MAXP_MAX_FUNCTION_DEFS = 1;
const int32_t MAXP_MAX_INSTR_DEFS = 0;
const int32_t MAXP_MAX_STACK_ELEMENTS = 64;
-const int32_t MAXP_MAX_INSTR_SIZE = 0;
-const int32_t MAXP_MAX_COMPONENT_ELEMENTS = 2;
+const int32_t MAXP_MAX_INSTR_SIZE = 46;
+const int32_t MAXP_MAX_COMPONENT_ELEMENTS = 4;
const int32_t MAXP_MAX_COMPONENT_DEPTH = 3;
static bool VerifyMAXP(Table* table) {
diff --git a/test/verify_name.cc b/test/verify_name.cc
index fa56de5..e1101c0 100644
--- a/test/verify_name.cc
+++ b/test/verify_name.cc
@@ -22,7 +22,7 @@
namespace sfntly {
const int32_t NAME_FORMAT = 0;
-const int32_t NAME_COUNT = 31;
+const int32_t NAME_COUNT = 75;
const NameTable::NameEntryId NAME_IDS[] = {
NameTable::NameEntryId(1, 0, 0, 0), // 0
NameTable::NameEntryId(1, 0, 0, 1), // 1
@@ -34,28 +34,8 @@ const NameTable::NameEntryId NAME_IDS[] = {
NameTable::NameEntryId(1, 0, 0, 9), // 7
NameTable::NameEntryId(1, 0, 0, 11), // 8
NameTable::NameEntryId(1, 0, 0, 12), // 9
- NameTable::NameEntryId(1, 0, 0, 13), // 10
- NameTable::NameEntryId(3, 1, 1031, 2), // 11
- NameTable::NameEntryId(3, 1, 1033, 0), // 12
- NameTable::NameEntryId(3, 1, 1033, 1), // 13
- NameTable::NameEntryId(3, 1, 1033, 2), // 14
- NameTable::NameEntryId(3, 1, 1033, 3), // 15
- NameTable::NameEntryId(3, 1, 1033, 4), // 16
- NameTable::NameEntryId(3, 1, 1033, 5), // 17
- NameTable::NameEntryId(3, 1, 1033, 6), // 18
- NameTable::NameEntryId(3, 1, 1033, 9), // 19
- NameTable::NameEntryId(3, 1, 1033, 11), // 20
- NameTable::NameEntryId(3, 1, 1033, 12), // 21
- NameTable::NameEntryId(3, 1, 1033, 13), // 22
- NameTable::NameEntryId(3, 1, 1034, 2), // 23
- NameTable::NameEntryId(3, 1, 1036, 2), // 24
- NameTable::NameEntryId(3, 1, 1038, 2), // 25
- NameTable::NameEntryId(3, 1, 1040, 2), // 26
- NameTable::NameEntryId(3, 1, 1043, 2), // 27
- NameTable::NameEntryId(3, 1, 1044, 2), // 28
- NameTable::NameEntryId(3, 1, 1049, 2), // 29
- NameTable::NameEntryId(3, 1, 1053, 2), // 30
};
+const int32_t NAME_IDS_TEST = 10;
static bool VerifyNAME(Table* table) {
// TODO(arthurhsu): Better testing can be done here. Right now we just
@@ -68,7 +48,7 @@ static bool VerifyNAME(Table* table) {
EXPECT_EQ(name->Format(), NAME_FORMAT);
EXPECT_EQ(name->NameCount(), NAME_COUNT);
fprintf(stderr, "checking name entry: ");
- for (int32_t i = 0; i < NAME_COUNT; ++i) {
+ for (int32_t i = 0; i < NAME_IDS_TEST; ++i) {
fprintf(stderr, "%d ", i);
EXPECT_EQ(name->PlatformId(i), NAME_IDS[i].platform_id());
EXPECT_EQ(name->EncodingId(i), NAME_IDS[i].encoding_id());
diff --git a/test/verify_os2.cc b/test/verify_os2.cc
index 4713e44..4897e87 100644
--- a/test/verify_os2.cc
+++ b/test/verify_os2.cc
@@ -38,21 +38,21 @@ const int32_t OS2_YSTRIKEOUT_SIZE = 12312;
const int32_t OS2_YSTRIKEOUT_POS = -16224;
const int32_t OS2_SFAMILY_CLASS = 0;
const byte_t OS2_PANOSE[] = { 2, 11, 6, 3, 6, 1, 0, 0, 0, 0 };
-const int64_t OS2_UL_UNICODE_RANGE1 = 0x80000003L;
-const int64_t OS2_UL_UNICODE_RANGE2 = 2L;
+const int64_t OS2_UL_UNICODE_RANGE1 = 0xE00002FFL;
+const int64_t OS2_UL_UNICODE_RANGE2 = 0x520020FBL;
const int64_t OS2_UL_UNICODE_RANGE3 = 0L;
const int64_t OS2_UL_UNICODE_RANGE4 = 0L;
const byte_t OS2_ACH_VEND_ID[] = { 'P', 'f', 'E', 'd' };
-const int32_t OS2_FS_SELECTION = 0;
-const int32_t OS2_US_FIRST_CHAR_IDX = 0x20;
-const int32_t OS2_US_LAST_CHAR_IDX = 0x20AC;
+const int32_t OS2_FS_SELECTION = 0x0040;
+const int32_t OS2_US_FIRST_CHAR_IDX = 0x0020;
+const int32_t OS2_US_LAST_CHAR_IDX = 0xFFFF;
const int32_t OS2_STYPO_ASCENDER = 1597;
const int32_t OS2_STYPO_DESCENDER = -451;
const int32_t OS2_STYPO_LINE_GAP = 0;
-const int32_t OS2_US_WIN_ASCENT = 1993;
-const int32_t OS2_US_WIN_DESCENT = 449;
-const int64_t OS2_UL_CODE_PAGE_RANGE1 = 1L;
-const int64_t OS2_UL_CODE_PAGE_RANGE2 = 0x80D40000L;
+const int32_t OS2_US_WIN_ASCENT = 2023;
+const int32_t OS2_US_WIN_DESCENT = 648;
+const int64_t OS2_UL_CODE_PAGE_RANGE1 = 0x2000019FL;
+const int64_t OS2_UL_CODE_PAGE_RANGE2 = 0x00000000L;
static bool VerifyOS_2(Table* table) {
OS2TablePtr os2 = down_cast<OS2Table*>(table);