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