summaryrefslogtreecommitdiff
path: root/sfntly/table/core/horizontal_header_table.h
blob: 3a3eb6f944eaf51e5e073db90062e609dd4d2a82 (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
/*
 * 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_HORIZONTAL_HEADER_TABLE_H_
#define SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_HORIZONTAL_HEADER_TABLE_H_

#include "sfntly/table/table.h"

namespace sfntly {

class HorizontalHeaderTable : public Table,
                              public RefCounted<HorizontalHeaderTable> {
 public:
  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(FontDataTableBuilderContainer* font_builder,
            Header* header,
            WritableFontData* data);
    Builder(FontDataTableBuilderContainer* font_builder,
            Header* header,
            ReadableFontData* data);
    virtual ~Builder();
    virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data);

    int32_t Version();
    void SetVersion(int32_t version);
    int32_t Ascender();
    void SetAscender(int32_t ascender);
    int32_t Descender();
    void SetDescender(int32_t descender);
    int32_t LineGap();
    void SetLineGap(int32_t line_gap);
    int32_t AdvanceWidthMax();
    void SetAdvanceWidthMax(int32_t value);
    int32_t MinLeftSideBearing();
    void SetMinLeftSideBearing(int32_t value);
    int32_t MinRightSideBearing();
    void SetMinRightSideBearing(int32_t value);
    int32_t XMaxExtent();
    void SetXMaxExtent(int32_t value);
    int32_t CaretSlopeRise();
    void SetCaretSlopeRise(int32_t value);
    int32_t CaretSlopeRun();
    void SetCaretSlopeRun(int32_t value);
    int32_t CaretOffset();
    void SetCaretOffset(int32_t value);
    int32_t MetricDataFormat();
    void SetMetricDataFormat(int32_t value);
    int32_t NumberOfHMetrics();
    void SetNumberOfHMetrics(int32_t value);
  };

  virtual ~HorizontalHeaderTable();
  int32_t Version();
  int32_t Ascender();
  int32_t Descender();
  int32_t LineGap();
  int32_t AdvanceWidthMax();
  int32_t MinLeftSideBearing();
  int32_t MinRightSideBearing();
  int32_t XMaxExtent();
  int32_t CaretSlopeRise();
  int32_t CaretSlopeRun();
  int32_t CaretOffset();
  int32_t MetricDataFormat();
  int32_t NumberOfHMetrics();

 private:
  struct Offset {
    enum {
      kVersion = 0,
      kAscender = 4,
      kDescender = 6,
      kLineGap = 8,
      kAdvanceWidthMax = 10,
      kMinLeftSideBearing = 12,
      kMinRightSideBearing = 14,
      kXMaxExtent = 16,
      kCaretSlopeRise = 18,
      kCaretSlopeRun = 20,
      kCaretOffset = 22,
      kMetricDataFormat = 32,
      kNumberOfHMetrics = 34,
    };
  };

  HorizontalHeaderTable(Header* header, ReadableFontData* data);
};
typedef Ptr<HorizontalHeaderTable> HorizontalHeaderTablePtr;
typedef Ptr<HorizontalHeaderTable::Builder> HorizontalHeaderTableBuilderPtr;

}  // namespace sfntly

#endif  // SFNTLY_CPP_SRC_SFNTLY_TABLE_CORE_HORIZONTAL_HEADER_TABLE_H_