1 /* 2 * Copyright 2011 Google Inc. All Rights Reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT2_H_ 18 #define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT2_H_ 19 20 #include "sfntly/table/bitmap/index_sub_table.h" 21 #include "sfntly/table/bitmap/big_glyph_metrics.h" 22 23 namespace sfntly { 24 // Format 2 Index Subtable Entry. 25 class IndexSubTableFormat2 : public IndexSubTable, 26 public RefCounted<IndexSubTableFormat2> { 27 public: 28 class Builder : public IndexSubTable::Builder, 29 public RefCounted<Builder> { 30 public: 31 class BitmapGlyphInfoIterator 32 : public RefIterator<BitmapGlyphInfo, Builder, IndexSubTable::Builder> { 33 public: 34 explicit BitmapGlyphInfoIterator(Builder* container); ~BitmapGlyphInfoIterator()35 virtual ~BitmapGlyphInfoIterator() {} 36 37 virtual bool HasNext(); 38 CALLER_ATTACH virtual BitmapGlyphInfo* Next(); 39 40 private: 41 int32_t glyph_id_; 42 }; 43 44 virtual ~Builder(); 45 virtual int32_t NumGlyphs(); 46 virtual int32_t GlyphStartOffset(int32_t glyph_id); 47 virtual int32_t GlyphLength(int32_t glyph_id); 48 CALLER_ATTACH virtual BitmapGlyphInfoIterator* GetIterator(); 49 50 virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data); 51 virtual void SubDataSet(); 52 virtual int32_t SubDataSizeToSerialize(); 53 virtual bool SubReadyToSerialize(); 54 virtual int32_t SubSerialize(WritableFontData* new_data); 55 56 int32_t ImageSize(); 57 void SetImageSize(int32_t image_size); 58 BigGlyphMetrics::Builder* BigMetrics(); 59 60 static CALLER_ATTACH Builder* CreateBuilder(); 61 static CALLER_ATTACH Builder* CreateBuilder(ReadableFontData* data, 62 int32_t index_sub_table_offset, 63 int32_t first_glyph_index, 64 int32_t last_glyph_index); 65 static CALLER_ATTACH Builder* CreateBuilder(WritableFontData* data, 66 int32_t index_sub_table_offset, 67 int32_t first_glyph_index, 68 int32_t last_glyph_index); 69 private: 70 Builder(); 71 Builder(WritableFontData* data, 72 int32_t first_glyph_index, 73 int32_t last_glyph_index); 74 Builder(ReadableFontData* data, 75 int32_t first_glyph_index, 76 int32_t last_glyph_index); 77 78 static int32_t DataLength(ReadableFontData* data, 79 int32_t index_sub_table_offset, 80 int32_t first_glyph_index, 81 int32_t last_glyph_index); 82 83 BigGlyphMetricsBuilderPtr metrics_; 84 }; 85 86 virtual ~IndexSubTableFormat2(); 87 88 int32_t ImageSize(); 89 CALLER_ATTACH BigGlyphMetrics* BigMetrics(); 90 91 virtual int32_t NumGlyphs(); 92 virtual int32_t GlyphStartOffset(int32_t glyph_id); 93 virtual int32_t GlyphLength(int32_t glyph_id); 94 95 private: 96 IndexSubTableFormat2(ReadableFontData* data, int32_t first, int32_t last); 97 98 int32_t image_size_; 99 friend class Builder; 100 }; 101 typedef Ptr<IndexSubTableFormat2> IndexSubTableFormat2Ptr; 102 typedef Ptr<IndexSubTableFormat2::Builder> IndexSubTableFormat2BuilderPtr; 103 104 } // namespace sfntly 105 106 #endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT1_H_ 107