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/core/maximum_profile_table.h"
18 
19 namespace sfntly {
20 /******************************************************************************
21  * MaximumProfileTable class
22  ******************************************************************************/
~MaximumProfileTable()23 MaximumProfileTable::~MaximumProfileTable() {}
24 
TableVersion()25 int32_t MaximumProfileTable::TableVersion() {
26   return data_->ReadFixed(Offset::kVersion);
27 }
28 
NumGlyphs()29 int32_t MaximumProfileTable::NumGlyphs() {
30   return data_->ReadUShort(Offset::kNumGlyphs);
31 }
32 
MaxPoints()33 int32_t MaximumProfileTable::MaxPoints() {
34   return data_->ReadUShort(Offset::kMaxPoints);
35 }
36 
MaxContours()37 int32_t MaximumProfileTable::MaxContours() {
38   return data_->ReadUShort(Offset::kMaxContours);
39 }
40 
MaxCompositePoints()41 int32_t MaximumProfileTable::MaxCompositePoints() {
42   return data_->ReadUShort(Offset::kMaxCompositePoints);
43 }
44 
MaxCompositeContours()45 int32_t MaximumProfileTable::MaxCompositeContours() {
46   return data_->ReadUShort(Offset::kMaxCompositeContours);
47 }
48 
MaxZones()49 int32_t MaximumProfileTable::MaxZones() {
50   return data_->ReadUShort(Offset::kMaxZones);
51 }
52 
MaxTwilightPoints()53 int32_t MaximumProfileTable::MaxTwilightPoints() {
54   return data_->ReadUShort(Offset::kMaxTwilightPoints);
55 }
56 
MaxStorage()57 int32_t MaximumProfileTable::MaxStorage() {
58   return data_->ReadUShort(Offset::kMaxStorage);
59 }
60 
MaxFunctionDefs()61 int32_t MaximumProfileTable::MaxFunctionDefs() {
62   return data_->ReadUShort(Offset::kMaxFunctionDefs);
63 }
64 
MaxStackElements()65 int32_t MaximumProfileTable::MaxStackElements() {
66   return data_->ReadUShort(Offset::kMaxStackElements);
67 }
68 
MaxSizeOfInstructions()69 int32_t MaximumProfileTable::MaxSizeOfInstructions() {
70   return data_->ReadUShort(Offset::kMaxSizeOfInstructions);
71 }
72 
MaxComponentElements()73 int32_t MaximumProfileTable::MaxComponentElements() {
74   return data_->ReadUShort(Offset::kMaxComponentElements);
75 }
76 
MaxComponentDepth()77 int32_t MaximumProfileTable::MaxComponentDepth() {
78   return data_->ReadUShort(Offset::kMaxComponentDepth);
79 }
80 
MaximumProfileTable(Header * header,ReadableFontData * data)81 MaximumProfileTable::MaximumProfileTable(Header* header,
82                                          ReadableFontData* data)
83     : Table(header, data) {
84 }
85 
86 /******************************************************************************
87  * MaximumProfileTable::Builder class
88  ******************************************************************************/
Builder(Header * header,WritableFontData * data)89 MaximumProfileTable::Builder::Builder(Header* header, WritableFontData* data)
90     : TableBasedTableBuilder(header, data) {
91 }
92 
Builder(Header * header,ReadableFontData * data)93 MaximumProfileTable::Builder::Builder(Header* header, ReadableFontData* data)
94     : TableBasedTableBuilder(header, data) {
95 }
96 
~Builder()97 MaximumProfileTable::Builder::~Builder() {}
98 
99 CALLER_ATTACH FontDataTable*
SubBuildTable(ReadableFontData * data)100     MaximumProfileTable::Builder::SubBuildTable(ReadableFontData* data) {
101   FontDataTablePtr table = new MaximumProfileTable(header(), data);
102   return table.Detach();
103 }
104 
105 CALLER_ATTACH MaximumProfileTable::Builder*
CreateBuilder(Header * header,WritableFontData * data)106     MaximumProfileTable::Builder::CreateBuilder(Header* header,
107                                                 WritableFontData* data) {
108   Ptr<MaximumProfileTable::Builder> builder;
109   builder = new MaximumProfileTable::Builder(header, data);
110   return builder.Detach();
111 }
112 
TableVersion()113 int32_t MaximumProfileTable::Builder::TableVersion() {
114   return InternalReadData()->ReadUShort(Offset::kVersion);
115 }
116 
SetTableVersion(int32_t version)117 void MaximumProfileTable::Builder::SetTableVersion(int32_t version) {
118   InternalWriteData()->WriteUShort(Offset::kVersion, version);
119 }
120 
NumGlyphs()121 int32_t MaximumProfileTable::Builder::NumGlyphs() {
122   return InternalReadData()->ReadUShort(Offset::kNumGlyphs);
123 }
124 
SetNumGlyphs(int32_t num_glyphs)125 void MaximumProfileTable::Builder::SetNumGlyphs(int32_t num_glyphs) {
126   InternalWriteData()->WriteUShort(Offset::kNumGlyphs, num_glyphs);
127 }
128 
MaxPoints()129 int32_t MaximumProfileTable::Builder::MaxPoints() {
130   return InternalReadData()->ReadUShort(Offset::kMaxPoints);
131 }
132 
SetMaxPoints(int32_t max_points)133 void MaximumProfileTable::Builder::SetMaxPoints(int32_t max_points) {
134   InternalWriteData()->WriteUShort(Offset::kMaxPoints, max_points);
135 }
136 
MaxContours()137 int32_t MaximumProfileTable::Builder::MaxContours() {
138   return InternalReadData()->ReadUShort(Offset::kMaxContours);
139 }
140 
SetMaxContours(int32_t max_contours)141 void MaximumProfileTable::Builder::SetMaxContours(int32_t max_contours) {
142   InternalWriteData()->WriteUShort(Offset::kMaxContours, max_contours);
143 }
144 
MaxCompositePoints()145 int32_t MaximumProfileTable::Builder::MaxCompositePoints() {
146   return InternalReadData()->ReadUShort(Offset::kMaxCompositePoints);
147 }
148 
SetMaxCompositePoints(int32_t max_composite_points)149 void MaximumProfileTable::Builder::SetMaxCompositePoints(
150     int32_t max_composite_points) {
151   InternalWriteData()->WriteUShort(Offset::kMaxCompositePoints,
152                                    max_composite_points);
153 }
154 
MaxCompositeContours()155 int32_t MaximumProfileTable::Builder::MaxCompositeContours() {
156   return InternalReadData()->ReadUShort(Offset::kMaxCompositeContours);
157 }
158 
SetMaxCompositeContours(int32_t max_composite_contours)159 void MaximumProfileTable::Builder::SetMaxCompositeContours(
160     int32_t max_composite_contours) {
161   InternalWriteData()->WriteUShort(Offset::kMaxCompositeContours,
162       max_composite_contours);
163 }
164 
MaxZones()165 int32_t MaximumProfileTable::Builder::MaxZones() {
166   return InternalReadData()->ReadUShort(Offset::kMaxZones);
167 }
168 
SetMaxZones(int32_t max_zones)169 void MaximumProfileTable::Builder::SetMaxZones(int32_t max_zones) {
170   InternalWriteData()->WriteUShort(Offset::kMaxZones, max_zones);
171 }
172 
MaxTwilightPoints()173 int32_t MaximumProfileTable::Builder::MaxTwilightPoints() {
174   return InternalReadData()->ReadUShort(Offset::kMaxTwilightPoints);
175 }
176 
SetMaxTwilightPoints(int32_t max_twilight_points)177 void MaximumProfileTable::Builder::SetMaxTwilightPoints(
178     int32_t max_twilight_points) {
179   InternalWriteData()->WriteUShort(Offset::kMaxTwilightPoints,
180                                    max_twilight_points);
181 }
182 
MaxStorage()183 int32_t MaximumProfileTable::Builder::MaxStorage() {
184   return InternalReadData()->ReadUShort(Offset::kMaxStorage);
185 }
186 
SetMaxStorage(int32_t max_storage)187 void MaximumProfileTable::Builder::SetMaxStorage(int32_t max_storage) {
188   InternalWriteData()->WriteUShort(Offset::kMaxStorage, max_storage);
189 }
190 
MaxFunctionDefs()191 int32_t MaximumProfileTable::Builder::MaxFunctionDefs() {
192   return InternalReadData()->ReadUShort(Offset::kMaxFunctionDefs);
193 }
194 
SetMaxFunctionDefs(int32_t max_function_defs)195 void MaximumProfileTable::Builder::SetMaxFunctionDefs(
196     int32_t max_function_defs) {
197   InternalWriteData()->WriteUShort(Offset::kMaxFunctionDefs, max_function_defs);
198 }
199 
MaxStackElements()200 int32_t MaximumProfileTable::Builder::MaxStackElements() {
201   return InternalReadData()->ReadUShort(Offset::kMaxStackElements);
202 }
203 
SetMaxStackElements(int32_t max_stack_elements)204 void MaximumProfileTable::Builder::SetMaxStackElements(
205     int32_t max_stack_elements) {
206   InternalWriteData()->WriteUShort(Offset::kMaxStackElements,
207                                    max_stack_elements);
208 }
209 
MaxSizeOfInstructions()210 int32_t MaximumProfileTable::Builder::MaxSizeOfInstructions() {
211   return InternalReadData()->ReadUShort(Offset::kMaxSizeOfInstructions);
212 }
213 
SetMaxSizeOfInstructions(int32_t max_size_of_instructions)214 void MaximumProfileTable::Builder::SetMaxSizeOfInstructions(
215     int32_t max_size_of_instructions) {
216   InternalWriteData()->WriteUShort(Offset::kMaxSizeOfInstructions,
217                                    max_size_of_instructions);
218 }
219 
MaxComponentElements()220 int32_t MaximumProfileTable::Builder::MaxComponentElements() {
221   return InternalReadData()->ReadUShort(Offset::kMaxComponentElements);
222 }
223 
SetMaxComponentElements(int32_t max_component_elements)224 void MaximumProfileTable::Builder::SetMaxComponentElements(
225     int32_t max_component_elements) {
226   InternalWriteData()->WriteUShort(Offset::kMaxComponentElements,
227                                    max_component_elements);
228 }
229 
MaxComponentDepth()230 int32_t MaximumProfileTable::Builder::MaxComponentDepth() {
231   return InternalReadData()->ReadUShort(Offset::kMaxComponentDepth);
232 }
233 
SetMaxComponentDepth(int32_t max_component_depth)234 void MaximumProfileTable::Builder::SetMaxComponentDepth(
235     int32_t max_component_depth) {
236   InternalWriteData()->WriteUShort(Offset::kMaxComponentDepth,
237                                    max_component_depth);
238 }
239 
240 }  // namespace sfntly
241