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 #ifndef SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_SMALL_GLYPH_METRICS_H_ 18 #define SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_SMALL_GLYPH_METRICS_H_ 19 20 #include "sfntly/port/refcount.h" 21 #include "sfntly/table/bitmap/glyph_metrics.h" 22 23 namespace sfntly { 24 25 class SmallGlyphMetrics : public GlyphMetrics, 26 public RefCounted<SmallGlyphMetrics> { 27 public: 28 struct Offset { 29 enum { 30 kMetricsLength = 5, 31 kHeight = 0, 32 kWidth = 1, 33 kBearingX = 2, 34 kBearingY = 3, 35 kAdvance = 4, 36 }; 37 }; 38 39 class Builder : public GlyphMetrics::Builder, 40 public RefCounted<Builder> { 41 public: 42 // Constructor scope altered to public because C++ does not allow base 43 // class to instantiate derived class with protected constructors. 44 explicit Builder(WritableFontData* data); 45 explicit Builder(ReadableFontData* data); 46 virtual ~Builder(); 47 48 int32_t Height(); 49 void SetHeight(byte_t height); 50 int32_t Width(); 51 void SetWidth(byte_t width); 52 int32_t BearingX(); 53 void SetBearingX(byte_t bearing); 54 int32_t BearingY(); 55 void SetBearingY(byte_t bearing); 56 int32_t Advance(); 57 void SetAdvance(byte_t advance); 58 59 virtual CALLER_ATTACH FontDataTable* SubBuildTable(ReadableFontData* data); 60 virtual void SubDataSet(); 61 virtual int32_t SubDataSizeToSerialize(); 62 virtual bool SubReadyToSerialize(); 63 virtual int32_t SubSerialize(WritableFontData* new_data); 64 }; 65 66 explicit SmallGlyphMetrics(ReadableFontData* data); 67 virtual ~SmallGlyphMetrics(); 68 69 int32_t Height(); 70 int32_t Width(); 71 int32_t BearingX(); 72 int32_t BearingY(); 73 int32_t Advance(); 74 }; 75 typedef Ptr<SmallGlyphMetrics> SmallGlyphMetricsPtr; 76 77 } // namespace sfntly 78 79 #endif // SFNTLY_CPP_SRC_SFNTLY_TABLE_BITMAP_SMALL_GLYPH_METRICS_H_ 80