• 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_CORE_MAXIMUM_PROFILE_TABLE_H_
18 #define SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_MAXIMUM_PROFILE_TABLE_H_
19 
20 #include "sfntly/port/refcount.h"
21 #include "sfntly/table/table.h"
22 #include "sfntly/table/table_based_table_builder.h"
23 
24 namespace sfntly {
25 
26 // A Maximum Profile table - 'maxp'.
27 class MaximumProfileTable : public Table,
28                             public RefCounted<MaximumProfileTable> {
29  public:
30   // Builder for a Maximum Profile table - 'maxp'.
31   class Builder : public TableBasedTableBuilder, public RefCounted<Builder> {
32    public:
33     // Constructor scope altered to public because C++ does not allow base
34     // class to instantiate derived class with protected constructors.
35     Builder(Header* header, WritableFontData* data);
36     Builder(Header* header, ReadableFontData* data);
37     virtual ~Builder();
38 
39     virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data);
40     static CALLER_ATTACH Builder* CreateBuilder(Header* header,
41                                                 WritableFontData* data);
42 
43     int32_t TableVersion();
44     void SetTableVersion(int32_t version);
45     int32_t NumGlyphs();
46     void SetNumGlyphs(int32_t num_glyphs);
47     int32_t MaxPoints();
48     void SetMaxPoints(int32_t max_points);
49     int32_t MaxContours();
50     void SetMaxContours(int32_t max_contours);
51     int32_t MaxCompositePoints();
52     void SetMaxCompositePoints(int32_t max_composite_points);
53     int32_t MaxCompositeContours();
54     void SetMaxCompositeContours(int32_t max_composite_contours);
55     int32_t MaxZones();
56     void SetMaxZones(int32_t max_zones);
57     int32_t MaxTwilightPoints();
58     void SetMaxTwilightPoints(int32_t max_twilight_points);
59     int32_t MaxStorage();
60     void SetMaxStorage(int32_t max_storage);
61     int32_t MaxFunctionDefs();
62     void SetMaxFunctionDefs(int32_t max_function_defs);
63     int32_t MaxStackElements();
64     void SetMaxStackElements(int32_t max_stack_elements);
65     int32_t MaxSizeOfInstructions();
66     void SetMaxSizeOfInstructions(int32_t max_size_of_instructions);
67     int32_t MaxComponentElements();
68     void SetMaxComponentElements(int32_t max_component_elements);
69     int32_t MaxComponentDepth();
70     void SetMaxComponentDepth(int32_t max_component_depth);
71   };
72 
73   virtual ~MaximumProfileTable();
74   int32_t TableVersion();
75   int32_t NumGlyphs();
76   int32_t MaxPoints();
77   int32_t MaxContours();
78   int32_t MaxCompositePoints();
79   int32_t MaxCompositeContours();
80   int32_t MaxZones();
81   int32_t MaxTwilightPoints();
82   int32_t MaxStorage();
83   int32_t MaxFunctionDefs();
84   int32_t MaxStackElements();
85   int32_t MaxSizeOfInstructions();
86   int32_t MaxComponentElements();
87   int32_t MaxComponentDepth();
88 
89  private:
90   struct Offset {
91     enum {
92       // version 0.5 and 1.0
93       kVersion = 0,
94       kNumGlyphs = 4,
95 
96       // version 1.0
97       kMaxPoints = 6,
98       kMaxContours = 8,
99       kMaxCompositePoints = 10,
100       kMaxCompositeContours = 12,
101       kMaxZones = 14,
102       kMaxTwilightPoints = 16,
103       kMaxStorage = 18,
104       kMaxFunctionDefs = 20,
105       kMaxInstructionDefs = 22,
106       kMaxStackElements = 24,
107       kMaxSizeOfInstructions = 26,
108       kMaxComponentElements = 28,
109       kMaxComponentDepth = 30,
110     };
111   };
112 
113   MaximumProfileTable(Header* header, ReadableFontData* data);
114 };
115 typedef Ptr<MaximumProfileTable> MaximumProfileTablePtr;
116 typedef Ptr<MaximumProfileTable::Builder> MaximumProfileTableBuilderPtr;
117 
118 }  // namespace sfntly
119 
120 #endif  // SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_MAXIMUM_PROFILE_TABLE_H_
121