summaryrefslogtreecommitdiff
path: root/sfntly/table/bitmap/bitmap_size_table.cc
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 /sfntly/table/bitmap/bitmap_size_table.cc
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
Diffstat (limited to 'sfntly/table/bitmap/bitmap_size_table.cc')
-rw-r--r--sfntly/table/bitmap/bitmap_size_table.cc147
1 files changed, 147 insertions, 0 deletions
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