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/bitmap_glyph.h" 18#include "sfntly/table/bitmap/simple_bitmap_glyph.h" 19#include "sfntly/table/bitmap/composite_bitmap_glyph.h" 20 21namespace sfntly { 22/****************************************************************************** 23 * BitmapGlyph class 24 ******************************************************************************/ 25BitmapGlyph::~BitmapGlyph() { 26} 27 28CALLER_ATTACH BitmapGlyph* BitmapGlyph::CreateGlyph(ReadableFontData* data, 29 int32_t format) { 30 BitmapGlyphPtr glyph; 31 BitmapGlyphBuilderPtr builder; 32 builder.Attach(Builder::CreateGlyphBuilder(data, format)); 33 if (builder) { 34 glyph.Attach(down_cast<BitmapGlyph*>(builder->Build())); 35 } 36 return glyph; 37} 38 39BitmapGlyph::BitmapGlyph(ReadableFontData* data, int32_t format) 40 : SubTable(data), format_(format) { 41} 42 43/****************************************************************************** 44 * BitmapGlyph::Builder class 45 ******************************************************************************/ 46BitmapGlyph::Builder::~Builder() { 47} 48 49CALLER_ATTACH BitmapGlyph::Builder* 50BitmapGlyph::Builder::CreateGlyphBuilder(ReadableFontData* data, 51 int32_t format) { 52 BitmapGlyphBuilderPtr builder; 53 switch (format) { 54 case 1: 55 case 2: 56 case 3: 57 case 4: 58 case 5: 59 case 6: 60 case 7: 61 builder = new SimpleBitmapGlyph::Builder(data, format); 62 break; 63 case 8: 64 case 9: 65 builder = new CompositeBitmapGlyph::Builder(data, format); 66 break; 67 } 68 return builder.Detach(); 69} 70 71BitmapGlyph::Builder::Builder(WritableFontData* data, int32_t format) 72 : SubTable::Builder(data), format_(format) { 73} 74 75BitmapGlyph::Builder::Builder(ReadableFontData* data, int32_t format) 76 : SubTable::Builder(data), format_(format) { 77} 78 79CALLER_ATTACH 80FontDataTable* BitmapGlyph::Builder::SubBuildTable(ReadableFontData* data) { 81 UNREFERENCED_PARAMETER(data); 82 return NULL; 83} 84 85void BitmapGlyph::Builder::SubDataSet() { 86 // NOP 87} 88 89int32_t BitmapGlyph::Builder::SubDataSizeToSerialize() { 90 return InternalReadData()->Length(); 91} 92 93bool BitmapGlyph::Builder::SubReadyToSerialize() { 94 return true; 95} 96 97int32_t BitmapGlyph::Builder::SubSerialize(WritableFontData* new_data) { 98 return InternalReadData()->CopyTo(new_data); 99} 100 101} // namespace sfntly 102