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