• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_GLYPH_INFO_H_
18 #define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_GLYPH_INFO_H_
19 
20 #include <vector>
21 #include <map>
22 
23 #include "sfntly/table/subtable.h"
24 
25 namespace sfntly {
26 
27 // An immutable class holding bitmap glyph information.
28 class BitmapGlyphInfo : public RefCounted<BitmapGlyphInfo> {
29  public:
30   // Constructor for a relative located glyph. The glyph's position in the EBDT
31   // table is a combination of it's block offset and it's own start offset.
32   // @param glyphId the glyph id
33   // @param blockOffset the offset of the block to which the glyph belongs
34   // @param startOffset the offset of the glyph within the block
35   // @param length the byte length
36   // @param format the glyph image format
37   BitmapGlyphInfo(int32_t glyph_id,
38                   int32_t block_offset,
39                   int32_t start_offset,
40                   int32_t length,
41                   int32_t format);
42 
43   // Constructor for an absolute located glyph. The glyph's position in the EBDT
44   // table is only given by it's own start offset.
45   // @param glyphId the glyph id
46   // @param startOffset the offset of the glyph within the block
47   // @param length the byte length
48   // @param format the glyph image format
49   BitmapGlyphInfo(int32_t glyph_id,
50                   int32_t start_offset,
51                   int32_t length,
52                   int32_t format);
53 
glyph_id()54   int32_t glyph_id() const { return glyph_id_; }
relative()55   bool relative() const { return relative_; }
block_offset()56   int32_t block_offset() const { return block_offset_; }
offset()57   int32_t offset() const { return block_offset() + start_offset(); }
start_offset()58   int32_t start_offset() const { return start_offset_; }
length()59   int32_t length() const { return length_; }
format()60   int32_t format() const { return format_; }
61 
62   // UNIMPLEMENTED: hashCode()
63   bool operator==(const BitmapGlyphInfo& rhs) const;
64   bool operator==(BitmapGlyphInfo* rhs);
65 
66  private:
67   int32_t glyph_id_;
68   bool relative_;
69   int32_t block_offset_;
70   int32_t start_offset_;
71   int32_t length_;
72   int32_t format_;
73 };
74 typedef Ptr<BitmapGlyphInfo> BitmapGlyphInfoPtr;
75 typedef std::map<int32_t, BitmapGlyphInfoPtr> BitmapGlyphInfoMap;
76 typedef std::vector<BitmapGlyphInfoMap> BitmapLocaList;
77 
78 class StartOffsetComparator {
79  public:
80   bool operator()(BitmapGlyphInfo* lhs, BitmapGlyphInfo* rhs);
81 };
82 
83 }  // namespace sfntly
84 
85 #endif  // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_GLYPH_INFO_H_
86