• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_LIB_UI_TEXT_FONT_COLLECTION_H_
6 #define FLUTTER_LIB_UI_TEXT_FONT_COLLECTION_H_
7 
8 #include <memory>
9 #include <vector>
10 
11 #include "flutter/assets/asset_manager.h"
12 #include "flutter/fml/macros.h"
13 #include "flutter/fml/memory/ref_ptr.h"
14 #include "txt/font_collection.h"
15 
16 namespace tonic {
17 class DartLibraryNatives;
18 }  // namespace tonic
19 
20 namespace flutter {
21 
22 class FontCollection {
23  public:
24   FontCollection();
25 
26   ~FontCollection();
27 
28   static void RegisterNatives(tonic::DartLibraryNatives* natives);
29 
30   std::shared_ptr<txt::FontCollection> GetFontCollection() const;
31 
32   void RegisterFonts(std::shared_ptr<AssetManager> asset_manager);
33 
34   void RegisterTestFonts();
35 
36   void LoadFontFromList(const uint8_t* font_data,
37                         int length,
38                         std::string family_name);
39 
40  private:
41   std::shared_ptr<txt::FontCollection> collection_;
42   sk_sp<txt::DynamicFontManager> dynamic_font_manager_;
43 
44   FML_DISALLOW_COPY_AND_ASSIGN(FontCollection);
45 };
46 
47 }  // namespace flutter
48 
49 #endif  // FLUTTER_LIB_UI_TEXT_FONT_COLLECTION_H_
50