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