Line data Source code
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_FORMAT1_H_
18 : #define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT1_H_
19 :
20 : #include "sfntly/port/java_iterator.h"
21 : #include "sfntly/table/bitmap/index_sub_table.h"
22 :
23 : namespace sfntly {
24 : // Format 1 Index Subtable Entry.
25 : class IndexSubTableFormat1 : public IndexSubTable,
26 : public RefCounted<IndexSubTableFormat1> {
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);
35 0 : 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 GlyphLength(int32_t glyph_id);
47 : virtual int32_t GlyphStartOffset(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 : IntegerList* OffsetArray();
57 : void SetOffsetArray(const IntegerList& offset_array);
58 : CALLER_ATTACH BitmapGlyphInfoIter* Iterator();
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 :
70 : protected:
71 : void Revert();
72 :
73 : private:
74 : Builder();
75 : Builder(WritableFontData* data,
76 : int32_t first_glyph_index,
77 : int32_t last_glyph_index);
78 : Builder(ReadableFontData* data,
79 : int32_t first_glyph_index,
80 : int32_t last_glyph_index);
81 : IntegerList* GetOffsetArray();
82 : void Initialize(ReadableFontData* data);
83 :
84 : static int32_t DataLength(ReadableFontData* data,
85 : int32_t index_sub_table_offset,
86 : int32_t first_glyph_index,
87 : int32_t last_glyph_index);
88 :
89 : IntegerList offset_array_;
90 : };
91 :
92 : virtual ~IndexSubTableFormat1();
93 :
94 : virtual int32_t NumGlyphs();
95 : virtual int32_t GlyphStartOffset(int32_t glyph_id);
96 : virtual int32_t GlyphLength(int32_t glyph_id);
97 :
98 : static int32_t GetDataLength(ReadableFontData* data,
99 : int32_t offset,
100 : int32_t first,
101 : int32_t last);
102 :
103 : private:
104 : IndexSubTableFormat1(ReadableFontData* data,
105 : int32_t first_glyph_index,
106 : int32_t last_glyph_index);
107 : int32_t Loca(int32_t loca_index);
108 :
109 : friend class Builder;
110 : };
111 : typedef Ptr<IndexSubTableFormat1> IndexSubTableFormat1Ptr;
112 : typedef Ptr<IndexSubTableFormat1::Builder> IndexSubTableFormat1BuilderPtr;
113 :
114 : } // namespace sfntly
115 :
116 : #endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_INDEX_SUBTABLE_FORMAT1_H_
|