• 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_EBDT_TABLE_H_
18 #define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_EBDT_TABLE_H_
19 
20 #include "sfntly/table/bitmap/bitmap_glyph.h"
21 #include "sfntly/table/bitmap/bitmap_glyph_info.h"
22 #include "sfntly/table/subtable_container_table.h"
23 
24 namespace sfntly {
25 
26 class EbdtTable : public SubTableContainerTable,
27                   public RefCounted<EbdtTable> {
28  public:
29   struct Offset {
30     enum {
31       kVersion = 0,
32       kHeaderLength = DataSize::kFixed,
33     };
34   };
35 
36   class Builder : public SubTableContainerTable::Builder,
37                   public RefCounted<Builder> {
38    public:
39     // Constructor scope altered to public because C++ does not allow base
40     // class to instantiate derived class with protected constructors.
41     Builder(Header* header, WritableFontData* data);
42     Builder(Header* header, ReadableFontData* data);
43     virtual ~Builder();
44 
45     virtual int32_t SubSerialize(WritableFontData* new_data);
46     virtual bool SubReadyToSerialize();
47     virtual int32_t SubDataSizeToSerialize();
48     virtual void SubDataSet();
49     virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data);
50 
51     void SetLoca(BitmapLocaList* loca_list);
52     void GenerateLocaList(BitmapLocaList* output);
53 
54     // Gets the List of glyph builders for the glyph table builder. These may be
55     // manipulated in any way by the caller and the changes will be reflected in
56     // the final glyph table produced.
57     // If there is no current data for the glyph builder or the glyph builders
58     // have not been previously set then this will return an empty glyph builder
59     // List. If there is current data (i.e. data read from an existing font) and
60     // the loca list has not been set or is null, empty, or invalid, then an
61     // empty glyph builder List will be returned.
62     // @return the list of glyph builders
63     BitmapGlyphBuilderList* GlyphBuilders();
64 
65     // Replace the internal glyph builders with the one provided. The provided
66     // list and all contained objects belong to this builder.
67     // This call is only required if the entire set of glyphs in the glyph
68     // table builder are being replaced. If the glyph builder list provided from
69     // the {@link EbdtTable.Builder#glyphBuilders()} is being used and modified
70     // then those changes will already be reflected in the glyph table builder.
71     // @param glyphBuilders the new glyph builders
72     void SetGlyphBuilders(BitmapGlyphBuilderList* glyph_builders);
73 
74     void Revert();
75 
76     // Create a new builder using the header information and data provided.
77     // @param header the header information
78     // @param data the data holding the table
79     static CALLER_ATTACH Builder* CreateBuilder(Header* header,
80                                                 WritableFontData* data);
81     static CALLER_ATTACH Builder* CreateBuilder(Header* header,
82                                                 ReadableFontData* data);
83 
84    private:
85     BitmapGlyphBuilderList* GetGlyphBuilders();
86     static void Initialize(ReadableFontData* data,
87                            BitmapLocaList* loca_list,
88                            BitmapGlyphBuilderList* output);
89 
90     static const int32_t kVersion = 0x00020000;  // TODO(stuartg): const/enum
91     BitmapLocaList glyph_loca_;
92     BitmapGlyphBuilderList glyph_builders_;
93   };
94 
95   virtual ~EbdtTable();
96   int32_t Version();
97   CALLER_ATTACH BitmapGlyph* Glyph(int32_t offset,
98                                    int32_t length,
99                                    int32_t format);
100  protected:
101   EbdtTable(Header* header, ReadableFontData* data);
102 };
103 typedef Ptr<EbdtTable> EbdtTablePtr;
104 typedef Ptr<EbdtTable::Builder> EbdtTableBuilderPtr;
105 
106 }  // namespace sfntly
107 
108 #endif  // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_EBDT_TABLE_H_
109