Debian Codegraph @

include/utils/SkOrderedFontMgr.h

raw
1 /*
2 * Copyright 2021 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkOrderedFontMgr_DEFINED
9 #define SkOrderedFontMgr_DEFINED
10
11 #include "include/core/SkFontMgr.h"
12 #include "include/core/SkRefCnt.h"
13 #include "include/core/SkTypes.h"
14
15 #include <memory>
16 #include <vector>
17
18 class SkData;
19 class SkFontStyle;
20 class SkStreamAsset;
21 class SkString;
22 class SkTypeface;
23 struct SkFontArguments;
24
25 /**
26 * Collects an order list of other font managers, and visits them in order
27 * when a request to find or match is issued.
28 *
29 * Note: this explicitly fails on any attempt to Make a typeface: all of
30 * those requests will return null.
31 */
32 class SK_API SkOrderedFontMgr : public SkFontMgr {
33 public:
34 SkOrderedFontMgr();
35 ~SkOrderedFontMgr() override;
36
37 void append(sk_sp<SkFontMgr>);
38
39 protected:
40 int onCountFamilies() const override;
41 void onGetFamilyName(int index, SkString* familyName) const override;
42 sk_sp<SkFontStyleSet> onCreateStyleSet(int index)const override;
43
44 sk_sp<SkFontStyleSet> onMatchFamily(const char familyName[]) const override;
45
46 sk_sp<SkTypeface> onMatchFamilyStyle(const char familyName[],
47 const SkFontStyle&) const override;
48 sk_sp<SkTypeface> onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&,
49 const char* bcp47[], int bcp47Count,
50 SkUnichar character) const override;
51
52 // Note: all of these always return null
53 sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData>, int ttcIndex) const override;
54 sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset>,
55 int ttcIndex) const override;
56 sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset>,
57 const SkFontArguments&) const override;
58 sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override;
59
60 sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle) const override;
61
62 private:
63 std::vector<sk_sp<SkFontMgr>> fList;
64 };
65
66 #endif