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