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 #include "sfntly/table/table_based_table_builder.h"
18 
19 namespace sfntly {
20 
21 /******************************************************************************
22  * TableBasedTableBuilder class
23  ******************************************************************************/
~TableBasedTableBuilder()24 TableBasedTableBuilder::~TableBasedTableBuilder() {}
25 
SubSerialize(WritableFontData * data)26 int32_t TableBasedTableBuilder::SubSerialize(WritableFontData* data) {
27   UNREFERENCED_PARAMETER(data);
28   return 0;
29 }
30 
SubReadyToSerialize()31 bool TableBasedTableBuilder::SubReadyToSerialize() {
32   return false;
33 }
34 
SubDataSizeToSerialize()35 int32_t TableBasedTableBuilder::SubDataSizeToSerialize() {
36   return 0;
37 }
38 
SubDataSet()39 void TableBasedTableBuilder::SubDataSet() {
40   table_ = NULL;
41 }
42 
Build()43 CALLER_ATTACH FontDataTable* TableBasedTableBuilder::Build() {
44   FontDataTablePtr table = static_cast<FontDataTable*>(GetTable());
45   return table.Detach();
46 }
47 
TableBasedTableBuilder(Header * header,WritableFontData * data)48 TableBasedTableBuilder::TableBasedTableBuilder(Header* header,
49                                                WritableFontData* data)
50     : Table::Builder(header, data) {
51 }
52 
TableBasedTableBuilder(Header * header,ReadableFontData * data)53 TableBasedTableBuilder::TableBasedTableBuilder(Header* header,
54                                                ReadableFontData* data)
55     : Table::Builder(header, data) {
56 }
57 
TableBasedTableBuilder(Header * header)58 TableBasedTableBuilder::TableBasedTableBuilder(Header* header)
59     : Table::Builder(header) {
60 }
61 
GetTable()62 Table* TableBasedTableBuilder::GetTable() {
63   if (!table_) {
64     ReadableFontData* data = InternalReadData();
65     if (data)
66       table_.Attach(down_cast<Table*>(SubBuildTable(data)));
67   }
68   return table_;
69 }
70 
71 }  // namespace sfntly
72