summaryrefslogtreecommitdiff
path: root/sfntly/table/core/maximum_profile_table.h
blob: 9b8961789d18fc8841d6edec34ea98933ab7d57f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 * Copyright 2011 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_MAXIMUM_PROFILE_TABLE_H_
#define SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_MAXIMUM_PROFILE_TABLE_H_

#include "sfntly/port/refcount.h"
#include "sfntly/table/table.h"

namespace sfntly {

// A Maximum Profile table - 'maxp'.
class MaximumProfileTable : public Table,
                            public RefCounted<MaximumProfileTable> {
 public:
  // Builder for a Maximum Profile table - 'maxp'.
  class Builder : public Table::TableBasedTableBuilder,
                  public RefCounted<Builder> {
   public:
    // Constructor scope altered to public because C++ does not allow base
    // class to instantiate derived class with protected constructors.
    Builder(Header* header, WritableFontData* data);
    Builder(Header* header, ReadableFontData* data);
    virtual ~Builder();

    virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data);
    static CALLER_ATTACH Builder* CreateBuilder(Header* header,
                                                WritableFontData* data);

    int32_t TableVersion();
    void SetTableVersion(int32_t version);
    int32_t NumGlyphs();
    void SetNumGlyphs(int32_t num_glyphs);
    int32_t MaxPoints();
    void SetMaxPoints(int32_t max_points);
    int32_t MaxContours();
    void SetMaxContours(int32_t max_contours);
    int32_t MaxCompositePoints();
    void SetMaxCompositePoints(int32_t max_composite_points);
    int32_t MaxCompositeContours();
    void SetMaxCompositeContours(int32_t max_composite_contours);
    int32_t MaxZones();
    void SetMaxZones(int32_t max_zones);
    int32_t MaxTwilightPoints();
    void SetMaxTwilightPoints(int32_t max_twilight_points);
    int32_t MaxStorage();
    void SetMaxStorage(int32_t max_storage);
    int32_t MaxFunctionDefs();
    void SetMaxFunctionDefs(int32_t max_function_defs);
    int32_t MaxStackElements();
    void SetMaxStackElements(int32_t max_stack_elements);
    int32_t MaxSizeOfInstructions();
    void SetMaxSizeOfInstructions(int32_t max_size_of_instructions);
    int32_t MaxComponentElements();
    void SetMaxComponentElements(int32_t max_component_elements);
    int32_t MaxComponentDepth();
    void SetMaxComponentDepth(int32_t max_component_depth);
  };

  virtual ~MaximumProfileTable();
  int32_t TableVersion();
  int32_t NumGlyphs();
  int32_t MaxPoints();
  int32_t MaxContours();
  int32_t MaxCompositePoints();
  int32_t MaxCompositeContours();
  int32_t MaxZones();
  int32_t MaxTwilightPoints();
  int32_t MaxStorage();
  int32_t MaxFunctionDefs();
  int32_t MaxStackElements();
  int32_t MaxSizeOfInstructions();
  int32_t MaxComponentElements();
  int32_t MaxComponentDepth();

 private:
  struct Offset {
    enum {
      // version 0.5 and 1.0
      kVersion = 0,
      kNumGlyphs = 4,

      // version 1.0
      kMaxPoints = 6,
      kMaxContours = 8,
      kMaxCompositePoints = 10,
      kMaxCompositeContours = 12,
      kMaxZones = 14,
      kMaxTwilightPoints = 16,
      kMaxStorage = 18,
      kMaxFunctionDefs = 20,
      kMaxInstructionDefs = 22,
      kMaxStackElements = 24,
      kMaxSizeOfInstructions = 26,
      kMaxComponentElements = 28,
      kMaxComponentDepth = 30,
    };
  };

  MaximumProfileTable(Header* header, ReadableFontData* data);
};
typedef Ptr<MaximumProfileTable> MaximumProfileTablePtr;
typedef Ptr<MaximumProfileTable::Builder> MaximumProfileTableBuilderPtr;

}  // namespace sfntly

#endif  // SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_MAXIMUM_PROFILE_TABLE_H_