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