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/bitmap/small_glyph_metrics.h"
18
19namespace sfntly {
20/******************************************************************************
21 * SmallGlyphMetrics class
22 ******************************************************************************/
23SmallGlyphMetrics::SmallGlyphMetrics(ReadableFontData* data)
24    : GlyphMetrics(data) {
25}
26
27SmallGlyphMetrics::~SmallGlyphMetrics() {
28}
29
30int32_t SmallGlyphMetrics::Height() {
31  return data_->ReadByte(Offset::kHeight);
32}
33
34int32_t SmallGlyphMetrics::Width() {
35  return data_->ReadByte(Offset::kWidth);
36}
37
38int32_t SmallGlyphMetrics::BearingX() {
39  return data_->ReadByte(Offset::kBearingX);
40}
41
42int32_t SmallGlyphMetrics::BearingY() {
43  return data_->ReadByte(Offset::kBearingY);
44}
45
46int32_t SmallGlyphMetrics::Advance() {
47  return data_->ReadByte(Offset::kAdvance);
48}
49
50/******************************************************************************
51 * SmallGlyphMetrics::Builder class
52 ******************************************************************************/
53SmallGlyphMetrics::Builder::Builder(WritableFontData* data)
54    : GlyphMetrics::Builder(data) {
55}
56
57SmallGlyphMetrics::Builder::Builder(ReadableFontData* data)
58    : GlyphMetrics::Builder(data) {
59}
60
61SmallGlyphMetrics::Builder::~Builder() {
62}
63
64int32_t SmallGlyphMetrics::Builder::Height() {
65  return InternalReadData()->ReadByte(Offset::kHeight);
66}
67
68void SmallGlyphMetrics::Builder::SetHeight(byte_t height) {
69  InternalWriteData()->WriteByte(Offset::kHeight, height);
70}
71
72int32_t SmallGlyphMetrics::Builder::Width() {
73  return InternalReadData()->ReadByte(Offset::kWidth);
74}
75
76void SmallGlyphMetrics::Builder::SetWidth(byte_t width) {
77  InternalWriteData()->WriteByte(Offset::kWidth, width);
78}
79
80int32_t SmallGlyphMetrics::Builder::BearingX() {
81  return InternalReadData()->ReadByte(Offset::kBearingX);
82}
83
84void SmallGlyphMetrics::Builder::SetBearingX(byte_t bearing) {
85  InternalWriteData()->WriteByte(Offset::kBearingX, bearing);
86}
87
88int32_t SmallGlyphMetrics::Builder::BearingY() {
89  return InternalReadData()->ReadByte(Offset::kBearingY);
90}
91
92void SmallGlyphMetrics::Builder::SetBearingY(byte_t bearing) {
93  InternalWriteData()->WriteByte(Offset::kBearingY, bearing);
94}
95
96int32_t SmallGlyphMetrics::Builder::Advance() {
97  return InternalReadData()->ReadByte(Offset::kAdvance);
98}
99
100void SmallGlyphMetrics::Builder::SetAdvance(byte_t advance) {
101  InternalWriteData()->WriteByte(Offset::kAdvance, advance);
102}
103
104CALLER_ATTACH FontDataTable*
105    SmallGlyphMetrics::Builder::SubBuildTable(ReadableFontData* data) {
106  SmallGlyphMetricsPtr output = new SmallGlyphMetrics(data);
107  return output.Detach();
108}
109
110void SmallGlyphMetrics::Builder::SubDataSet() {
111  // NOP.
112}
113
114int32_t SmallGlyphMetrics::Builder::SubDataSizeToSerialize() {
115  return 0;
116}
117
118bool SmallGlyphMetrics::Builder::SubReadyToSerialize() {
119  return false;
120}
121
122int32_t SmallGlyphMetrics::Builder::SubSerialize(WritableFontData* new_data) {
123  return Data()->CopyTo(new_data);
124}
125
126}  // namespace sfntly
127