summaryrefslogtreecommitdiff
path: root/sample/subtly/font_assembler.h
blob: c53c21fd07b67c1bc7ecfbe3d46967ec5b87666d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * Copyright 2011 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef TYPOGRAPHY_FONT_SFNTLY_SRC_SAMPLE_SUBTLY_FONT_ASSEMBLER_H_
#define TYPOGRAPHY_FONT_SFNTLY_SRC_SAMPLE_SUBTLY_FONT_ASSEMBLER_H_

#include <set>
#include <map>

#include "subtly/font_info.h"

#include "sfntly/tag.h"
#include "sfntly/font.h"
#include "sfntly/port/type.h"
#include "sfntly/port/refcount.h"
#include "sfntly/table/core/cmap_table.h"
#include "sfntly/table/truetype/glyph_table.h"
#include "sfntly/table/truetype/loca_table.h"

namespace subtly {
// Assembles FontInfo into font builders.
// Does not take ownership of data passed to it.
class FontAssembler : public sfntly::RefCounted<FontAssembler> {
 public:
  // font_info is the FontInfo which will be used for the new font
  // table_blacklist is used to decide which tables to exclude from the
  // final font.
  FontAssembler(FontInfo* font_info, sfntly::IntegerSet* table_blacklist);
  explicit FontAssembler(FontInfo* font_info);
  ~FontAssembler() { }

  // Assemble a new font from the font info object.
  virtual CALLER_ATTACH sfntly::Font* Assemble();

  sfntly::IntegerSet* table_blacklist() const { return table_blacklist_; }
  void set_table_blacklist(sfntly::IntegerSet* table_blacklist) {
    table_blacklist_ = table_blacklist;
  }

 protected:
  virtual bool AssembleCMapTable();
  virtual bool AssembleGlyphAndLocaTables();

  virtual void Initialize();

 private:
  sfntly::Ptr<FontInfo> font_info_;
  sfntly::Ptr<sfntly::FontFactory> font_factory_;
  sfntly::Ptr<sfntly::Font::Builder> font_builder_;
  sfntly::IntegerSet* table_blacklist_;
};
}

#endif  // TYPOGRAPHY_FONT_SFNTLY_SRC_SAMPLE_SUBTLY_FONT_ASSEMBLER_H_