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/big_glyph_metrics.h"
18
19 namespace sfntly {
20 /******************************************************************************
21 * BigGlyphMetrics class
22 ******************************************************************************/
BigGlyphMetrics(ReadableFontData * data)23 BigGlyphMetrics::BigGlyphMetrics(ReadableFontData* data)
24 : GlyphMetrics(data) {
25 }
26
~BigGlyphMetrics()27 BigGlyphMetrics::~BigGlyphMetrics() {
28 }
29
Height()30 int32_t BigGlyphMetrics::Height() {
31 return data_->ReadByte(Offset::kHeight);
32 }
33
Width()34 int32_t BigGlyphMetrics::Width() {
35 return data_->ReadByte(Offset::kWidth);
36 }
37
HoriBearingX()38 int32_t BigGlyphMetrics::HoriBearingX() {
39 return data_->ReadByte(Offset::kHoriBearingX);
40 }
41
HoriBearingY()42 int32_t BigGlyphMetrics::HoriBearingY() {
43 return data_->ReadByte(Offset::kHoriBearingY);
44 }
45
HoriAdvance()46 int32_t BigGlyphMetrics::HoriAdvance() {
47 return data_->ReadByte(Offset::kHoriAdvance);
48 }
49
VertBearingX()50 int32_t BigGlyphMetrics::VertBearingX() {
51 return data_->ReadByte(Offset::kVertBearingX);
52 }
53
VertBearingY()54 int32_t BigGlyphMetrics::VertBearingY() {
55 return data_->ReadByte(Offset::kVertBearingY);
56 }
57
VertAdvance()58 int32_t BigGlyphMetrics::VertAdvance() {
59 return data_->ReadByte(Offset::kVertAdvance);
60 }
61
62 /******************************************************************************
63 * BigGlyphMetrics::Builder class
64 ******************************************************************************/
Builder(WritableFontData * data)65 BigGlyphMetrics::Builder::Builder(WritableFontData* data)
66 : GlyphMetrics::Builder(data) {
67 }
68
Builder(ReadableFontData * data)69 BigGlyphMetrics::Builder::Builder(ReadableFontData* data)
70 : GlyphMetrics::Builder(data) {
71 }
72
~Builder()73 BigGlyphMetrics::Builder::~Builder() {
74 }
75
Height()76 int32_t BigGlyphMetrics::Builder::Height() {
77 return InternalReadData()->ReadByte(Offset::kHeight);
78 }
79
SetHeight(byte_t height)80 void BigGlyphMetrics::Builder::SetHeight(byte_t height) {
81 InternalWriteData()->WriteByte(Offset::kHeight, height);
82 }
83
Width()84 int32_t BigGlyphMetrics::Builder::Width() {
85 return InternalReadData()->ReadByte(Offset::kWidth);
86 }
87
SetWidth(byte_t width)88 void BigGlyphMetrics::Builder::SetWidth(byte_t width) {
89 InternalWriteData()->WriteByte(Offset::kWidth, width);
90 }
91
HoriBearingX()92 int32_t BigGlyphMetrics::Builder::HoriBearingX() {
93 return InternalReadData()->ReadByte(Offset::kHoriBearingX);
94 }
95
SetHoriBearingX(byte_t bearing)96 void BigGlyphMetrics::Builder::SetHoriBearingX(byte_t bearing) {
97 InternalWriteData()->WriteByte(Offset::kHoriBearingX, bearing);
98 }
99
HoriBearingY()100 int32_t BigGlyphMetrics::Builder::HoriBearingY() {
101 return InternalReadData()->ReadByte(Offset::kHoriBearingY);
102 }
103
SetHoriBearingY(byte_t bearing)104 void BigGlyphMetrics::Builder::SetHoriBearingY(byte_t bearing) {
105 InternalWriteData()->WriteByte(Offset::kHoriBearingY, bearing);
106 }
107
HoriAdvance()108 int32_t BigGlyphMetrics::Builder::HoriAdvance() {
109 return InternalReadData()->ReadByte(Offset::kHoriAdvance);
110 }
111
SetHoriAdvance(byte_t advance)112 void BigGlyphMetrics::Builder::SetHoriAdvance(byte_t advance) {
113 InternalWriteData()->WriteByte(Offset::kHoriAdvance, advance);
114 }
115
VertBearingX()116 int32_t BigGlyphMetrics::Builder::VertBearingX() {
117 return InternalReadData()->ReadByte(Offset::kVertBearingX);
118 }
119
SetVertBearingX(byte_t bearing)120 void BigGlyphMetrics::Builder::SetVertBearingX(byte_t bearing) {
121 InternalWriteData()->WriteByte(Offset::kVertBearingX, bearing);
122 }
123
VertBearingY()124 int32_t BigGlyphMetrics::Builder::VertBearingY() {
125 return InternalReadData()->ReadByte(Offset::kVertBearingY);
126 }
127
SetVertBearingY(byte_t bearing)128 void BigGlyphMetrics::Builder::SetVertBearingY(byte_t bearing) {
129 InternalWriteData()->WriteByte(Offset::kVertBearingY, bearing);
130 }
131
VertAdvance()132 int32_t BigGlyphMetrics::Builder::VertAdvance() {
133 return InternalReadData()->ReadByte(Offset::kVertAdvance);
134 }
135
SetVertAdvance(byte_t advance)136 void BigGlyphMetrics::Builder::SetVertAdvance(byte_t advance) {
137 InternalWriteData()->WriteByte(Offset::kVertAdvance, advance);
138 }
139
140 CALLER_ATTACH FontDataTable*
SubBuildTable(ReadableFontData * data)141 BigGlyphMetrics::Builder::SubBuildTable(ReadableFontData* data) {
142 BigGlyphMetricsPtr output = new BigGlyphMetrics(data);
143 return output.Detach();
144 }
145
SubDataSet()146 void BigGlyphMetrics::Builder::SubDataSet() {
147 // NOP.
148 }
149
SubDataSizeToSerialize()150 int32_t BigGlyphMetrics::Builder::SubDataSizeToSerialize() {
151 return 0;
152 }
153
SubReadyToSerialize()154 bool BigGlyphMetrics::Builder::SubReadyToSerialize() {
155 return false;
156 }
157
SubSerialize(WritableFontData * new_data)158 int32_t BigGlyphMetrics::Builder::SubSerialize(WritableFontData* new_data) {
159 return Data()->CopyTo(new_data);
160 }
161
162 // static
163 CALLER_ATTACH
CreateBuilder()164 BigGlyphMetrics::Builder* BigGlyphMetrics::Builder::CreateBuilder() {
165 WritableFontDataPtr data;
166 data.Attach(WritableFontData::CreateWritableFontData(Offset::kMetricsLength));
167 BigGlyphMetricsBuilderPtr output = new BigGlyphMetrics::Builder(data);
168 return output.Detach();
169 }
170
171 } // namespace sfntly
172