• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 TYPOGRAPHY_FONT_SFNTLY_SRC_SAMPLE_SUBTLY_FONT_ASSEMBLER_H_
18 #define TYPOGRAPHY_FONT_SFNTLY_SRC_SAMPLE_SUBTLY_FONT_ASSEMBLER_H_
19 
20 #include <set>
21 #include <map>
22 
23 #include "subtly/font_info.h"
24 
25 #include "sfntly/tag.h"
26 #include "sfntly/font.h"
27 #include "sfntly/port/type.h"
28 #include "sfntly/port/refcount.h"
29 #include "sfntly/table/core/cmap_table.h"
30 #include "sfntly/table/truetype/glyph_table.h"
31 #include "sfntly/table/truetype/loca_table.h"
32 
33 namespace subtly {
34 // Assembles FontInfo into font builders.
35 // Does not take ownership of data passed to it.
36 class FontAssembler : public sfntly::RefCounted<FontAssembler> {
37  public:
38   // font_info is the FontInfo which will be used for the new font
39   // table_blacklist is used to decide which tables to exclude from the
40   // final font.
41   FontAssembler(FontInfo* font_info, sfntly::IntegerSet* table_blacklist);
42   explicit FontAssembler(FontInfo* font_info);
~FontAssembler()43   ~FontAssembler() { }
44 
45   // Assemble a new font from the font info object.
46   virtual CALLER_ATTACH sfntly::Font* Assemble();
47 
table_blacklist()48   sfntly::IntegerSet* table_blacklist() const { return table_blacklist_; }
set_table_blacklist(sfntly::IntegerSet * table_blacklist)49   void set_table_blacklist(sfntly::IntegerSet* table_blacklist) {
50     table_blacklist_ = table_blacklist;
51   }
52 
53  protected:
54   virtual bool AssembleCMapTable();
55   virtual bool AssembleGlyphAndLocaTables();
56 
57   virtual void Initialize();
58 
59  private:
60   sfntly::Ptr<FontInfo> font_info_;
61   sfntly::Ptr<sfntly::FontFactory> font_factory_;
62   sfntly::Ptr<sfntly::Font::Builder> font_builder_;
63   sfntly::IntegerSet* table_blacklist_;
64 };
65 }
66 
67 #endif  // TYPOGRAPHY_FONT_SFNTLY_SRC_SAMPLE_SUBTLY_FONT_ASSEMBLER_H_
68