Flutter Engine
 
Loading...
Searching...
No Matches
typeface_font_asset_provider.h
Go to the documentation of this file.
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_TXT_SRC_TXT_TYPEFACE_FONT_ASSET_PROVIDER_H_
6#define FLUTTER_TXT_SRC_TXT_TYPEFACE_FONT_ASSET_PROVIDER_H_
7
8#include <string>
9#include <unordered_map>
10#include <vector>
11
12#include "flutter/fml/macros.h"
13#include "third_party/skia/include/core/SkFontMgr.h"
15
16namespace txt {
17
18class TypefaceFontStyleSet : public SkFontStyleSet {
19 public:
21
23
24 void registerTypeface(sk_sp<SkTypeface> typeface);
25
26 // |SkFontStyleSet|
27 int count() override;
28
29 // |SkFontStyleSet|
30 void getStyle(int index, SkFontStyle* style, SkString* name) override;
31
32 // |SkFontStyleSet|
33 sk_sp<SkTypeface> createTypeface(int index) override;
34
35 // |SkFontStyleSet|
36 sk_sp<SkTypeface> matchStyle(const SkFontStyle& pattern) override;
37
38 private:
39 std::vector<sk_sp<SkTypeface>> typefaces_;
40
42};
43
45 public:
48
49 void RegisterTypeface(sk_sp<SkTypeface> typeface);
50
51 void RegisterTypeface(sk_sp<SkTypeface> typeface,
52 const std::string& family_name_alias);
53
54 // |FontAssetProvider|
55 size_t GetFamilyCount() const override;
56
57 // |FontAssetProvider|
58 std::string GetFamilyName(int index) const override;
59
60 // |FontAssetProvider|
61 sk_sp<SkFontStyleSet> MatchFamily(const std::string& family_name) override;
62
63 private:
64 std::unordered_map<std::string, sk_sp<TypefaceFontStyleSet>>
65 registered_families_;
66 std::vector<std::string> family_names_;
67
69};
70
71} // namespace txt
72
73#endif // FLUTTER_TXT_SRC_TXT_TYPEFACE_FONT_ASSET_PROVIDER_H_
void RegisterTypeface(sk_sp< SkTypeface > typeface)
std::string GetFamilyName(int index) const override
sk_sp< SkFontStyleSet > MatchFamily(const std::string &family_name) override
sk_sp< SkTypeface > matchStyle(const SkFontStyle &pattern) override
~TypefaceFontStyleSet() override
void getStyle(int index, SkFontStyle *style, SkString *name) override
sk_sp< SkTypeface > createTypeface(int index) override
void registerTypeface(sk_sp< SkTypeface > typeface)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27