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_BITMAP_BIG_GLYPH_METRICS_H_
18#define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_BIG_GLYPH_METRICS_H_
19
20#include "sfntly/table/bitmap/glyph_metrics.h"
21
22namespace sfntly {
23
24class BigGlyphMetrics : public GlyphMetrics,
25                        public RefCounted<BigGlyphMetrics> {
26 public:
27  struct Offset {
28    enum {
29      kMetricsLength = 8,
30
31      kHeight = 0,
32      kWidth = 1,
33      kHoriBearingX = 2,
34      kHoriBearingY = 3,
35      kHoriAdvance = 4,
36      kVertBearingX = 5,
37      kVertBearingY = 6,
38      kVertAdvance = 7,
39    };
40  };
41
42  class Builder : public GlyphMetrics::Builder,
43                  public RefCounted<Builder> {
44   public:
45    // Constructor scope altered to public because C++ does not allow base
46    // class to instantiate derived class with protected constructors.
47    explicit Builder(WritableFontData* data);
48    explicit Builder(ReadableFontData* data);
49
50    virtual ~Builder();
51
52    int32_t Height();
53    void SetHeight(byte_t height);
54    int32_t Width();
55    void SetWidth(byte_t width);
56    int32_t HoriBearingX();
57    void SetHoriBearingX(byte_t bearing);
58    int32_t HoriBearingY();
59    void SetHoriBearingY(byte_t bearing);
60    int32_t HoriAdvance();
61    void SetHoriAdvance(byte_t advance);
62    int32_t VertBearingX();
63    void SetVertBearingX(byte_t bearing);
64    int32_t VertBearingY();
65    void SetVertBearingY(byte_t bearing);
66    int32_t VertAdvance();
67    void SetVertAdvance(byte_t advance);
68
69    virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data);
70    virtual void SubDataSet();
71    virtual int32_t SubDataSizeToSerialize();
72    virtual bool SubReadyToSerialize();
73    virtual int32_t SubSerialize(WritableFontData* new_data);
74
75    // Static instantiation function.
76    static CALLER_ATTACH Builder* CreateBuilder();
77  };
78
79  explicit BigGlyphMetrics(ReadableFontData* data);
80  virtual ~BigGlyphMetrics();
81
82  int32_t Height();
83  int32_t Width();
84  int32_t HoriBearingX();
85  int32_t HoriBearingY();
86  int32_t HoriAdvance();
87  int32_t VertBearingX();
88  int32_t VertBearingY();
89  int32_t VertAdvance();
90};
91typedef Ptr<BigGlyphMetrics> BigGlyphMetricsPtr;
92typedef Ptr<BigGlyphMetrics::Builder> BigGlyphMetricsBuilderPtr;
93
94}  // namespace sfntly
95
96#endif  // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_BIG_GLYPH_METRICS_H_
97