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
16namespace tonic {
17class DartLibraryNatives;
18} // namespace tonic
19
20namespace flutter {
21
22class 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 SetupDefaultFontManager();
33
34 void RegisterFonts(std::shared_ptr<AssetManager> asset_manager);
35
36 void RegisterTestFonts();
37
38 void LoadFontFromList(const uint8_t* font_data,
39 int length,
40 std::string family_name);
41
42 private:
43 std::shared_ptr<txt::FontCollection> collection_;
44 sk_sp<txt::DynamicFontManager> dynamic_font_manager_;
45
46 FML_DISALLOW_COPY_AND_ASSIGN(FontCollection);
47};
48
49} // namespace flutter
50
51#endif // FLUTTER_LIB_UI_TEXT_FONT_COLLECTION_H_
52