LCOV - code coverage report
Current view: top level - gfx/sfntly/cpp/src/sfntly/table/bitmap - composite_bitmap_glyph.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 50 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 20 0.0 %
Legend: Lines: hit not hit

          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/composite_bitmap_glyph.h"
      18             : 
      19             : namespace sfntly {
      20             : /******************************************************************************
      21             :  * CompositeBitmapGlyph class
      22             :  ******************************************************************************/
      23           0 : CompositeBitmapGlyph::CompositeBitmapGlyph(ReadableFontData* data,
      24           0 :                                            int32_t format)
      25           0 :     : BitmapGlyph(data, format) {
      26           0 :   Initialize(format);
      27           0 : }
      28             : 
      29           0 : CompositeBitmapGlyph::~CompositeBitmapGlyph() {
      30           0 : }
      31             : 
      32           0 : int32_t CompositeBitmapGlyph::NumComponents() {
      33           0 :   return data_->ReadUShort(num_components_offset_);
      34             : }
      35             : 
      36           0 : CompositeBitmapGlyph::Component CompositeBitmapGlyph::GetComponent(
      37             :     int32_t component_num) const {
      38           0 :   int32_t component_offset = component_array_offset_ +
      39           0 :                              component_num * Offset::kEbdtComponentLength;
      40             :   return CompositeBitmapGlyph::Component(
      41           0 :       data_->ReadUShort(component_offset + Offset::kEbdtComponent_glyphCode),
      42           0 :       data_->ReadChar(component_offset + Offset::kEbdtComponent_xOffset),
      43           0 :       data_->ReadChar(component_offset + Offset::kEbdtComponent_yOffset));
      44             : }
      45             : 
      46           0 : void CompositeBitmapGlyph::Initialize(int32_t format) {
      47           0 :   if (format == 8) {
      48           0 :     num_components_offset_ = Offset::kGlyphFormat8_numComponents;
      49           0 :     component_array_offset_ = Offset::kGlyphFormat8_componentArray;
      50           0 :   } else if (format == 9) {
      51           0 :     num_components_offset_ = Offset::kGlyphFormat9_numComponents;
      52           0 :     component_array_offset_ = Offset::kGlyphFormat9_componentArray;
      53             :   } else {
      54             : #if !defined (SFNTLY_NO_EXCEPTION)
      55             :     throw IllegalStateException("Attempt to create a Composite Bitmap Glyph "
      56             :                                 "with a non-composite format.");
      57             : #endif
      58             :   }
      59           0 : }
      60             : 
      61             : /******************************************************************************
      62             :  * CompositeBitmapGlyph::Component class
      63             :  ******************************************************************************/
      64           0 : CompositeBitmapGlyph::Component::Component(const Component& rhs)
      65           0 :     : glyph_code_(rhs.glyph_code_),
      66           0 :       x_offset_(rhs.x_offset_),
      67           0 :       y_offset_(rhs.y_offset_) {
      68           0 : }
      69             : 
      70           0 : bool CompositeBitmapGlyph::Component::operator==(
      71             :     const CompositeBitmapGlyph::Component& rhs) {
      72           0 :   return glyph_code_ == rhs.glyph_code_;
      73             : }
      74             : 
      75           0 : CompositeBitmapGlyph::Component& CompositeBitmapGlyph::Component::operator=(
      76             :     const CompositeBitmapGlyph::Component& rhs) {
      77           0 :   glyph_code_ = rhs.glyph_code_;
      78           0 :   x_offset_ = rhs.x_offset_;
      79           0 :   y_offset_ = rhs.y_offset_;
      80           0 :   return *this;
      81             : }
      82             : 
      83           0 : CompositeBitmapGlyph::Component::Component(int32_t glyph_code,
      84             :                                            int32_t x_offset,
      85           0 :                                            int32_t y_offset)
      86           0 :     : glyph_code_(glyph_code), x_offset_(x_offset), y_offset_(y_offset) {
      87           0 : }
      88             : 
      89             : /******************************************************************************
      90             :  * CompositeBitmapGlyph::Builder class
      91             :  ******************************************************************************/
      92           0 : CompositeBitmapGlyph::Builder::Builder(ReadableFontData* data, int32_t format)
      93           0 :     : BitmapGlyph::Builder(data, format) {
      94           0 : }
      95             : 
      96           0 : CompositeBitmapGlyph::Builder::Builder(WritableFontData* data, int32_t format)
      97           0 :     : BitmapGlyph::Builder(data, format) {
      98           0 : }
      99             : 
     100           0 : CompositeBitmapGlyph::Builder::~Builder() {
     101           0 : }
     102             : 
     103             : CALLER_ATTACH FontDataTable*
     104           0 : CompositeBitmapGlyph::Builder::SubBuildTable(ReadableFontData* data) {
     105           0 :   Ptr<CompositeBitmapGlyph> glyph = new CompositeBitmapGlyph(data, format());
     106           0 :   return glyph.Detach();
     107             : }
     108             : 
     109             : }  // namespace sfntly

Generated by: LCOV version 1.13