Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkFontMgr_custom.h
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
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 SkFontMgr_custom_DEFINED
9#define SkFontMgr_custom_DEFINED
10
18
19class SkData;
21class SkStreamAsset;
22class SkTypeface;
23
24/** The base SkTypeface implementation for the custom font manager. */
26public:
28 bool sysFont, SkString familyName, int index);
29 bool isSysFont() const;
30
31protected:
32 void onGetFamilyName(SkString* familyName) const override;
33 void onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const override;
34 int getIndex() const;
35
36private:
37 const bool fIsSysFont;
38 const SkString fFamilyName;
39 const int fIndex;
40
42};
43
44/** The empty SkTypeface implementation for the custom font manager.
45 * Used as the last resort fallback typeface.
46 */
48public:
50
51protected:
52 std::unique_ptr<SkStreamAsset> onOpenStream(int*) const override;
54 std::unique_ptr<SkFontData> onMakeFontData() const override;
55
56private:
58};
59
60/** The file SkTypeface implementation for the custom font manager. */
62public:
63 SkTypeface_File(const SkFontStyle& style, bool isFixedPitch, bool sysFont,
64 SkString familyName, const char path[], int index);
65
66protected:
67 std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override;
69 std::unique_ptr<SkFontData> onMakeFontData() const override;
70
71private:
72 SkString fPath;
73
75};
76
77///////////////////////////////////////////////////////////////////////////////
78
79/**
80 * SkFontStyleSet_Custom
81 *
82 * This class is used by SkFontMgr_Custom to hold SkTypeface_Custom families.
83 */
85public:
86 explicit SkFontStyleSet_Custom(SkString familyName);
87
88 /** Should only be called during the initial build phase. */
89 void appendTypeface(sk_sp<SkTypeface> typeface);
90 int count() override;
91 void getStyle(int index, SkFontStyle* style, SkString* name) override;
92 sk_sp<SkTypeface> createTypeface(int index) override;
93 sk_sp<SkTypeface> matchStyle(const SkFontStyle& pattern) override;
95
96private:
98 SkString fFamilyName;
99
100 friend class SkFontMgr_Custom;
101};
102
103/**
104 * SkFontMgr_Custom
105 *
106 * This class is essentially a collection of SkFontStyleSet_Custom,
107 * one SkFontStyleSet_Custom for each family. This class may be modified
108 * to load fonts from any source by changing the initialization.
109 */
111public:
114 public:
115 virtual ~SystemFontLoader() { }
116 virtual void loadSystemFonts(const SkFontScanner*, Families*) const = 0;
117 };
118 explicit SkFontMgr_Custom(const SystemFontLoader& loader);
119
120protected:
121 int onCountFamilies() const override;
122 void onGetFamilyName(int index, SkString* familyName) const override;
123 sk_sp<SkFontStyleSet> onCreateStyleSet(int index) const override;
124 sk_sp<SkFontStyleSet> onMatchFamily(const char familyName[]) const override;
125 sk_sp<SkTypeface> onMatchFamilyStyle(const char familyName[],
126 const SkFontStyle& fontStyle) const override;
127 sk_sp<SkTypeface> onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&,
128 const char* bcp47[], int bcp47Count,
129 SkUnichar character) const override;
130 sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData> data, int ttcIndex) const override;
131 sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset>, int ttcIndex) const override;
132 sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset>, const SkFontArguments&) const override;
133 sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override;
134 sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle style) const override;
135
136private:
137 Families fFamilies;
138 sk_sp<SkFontStyleSet> fDefaultFamily;
139 std::unique_ptr<SkFontScanner> fScanner;
140};
141
142#endif
int32_t SkUnichar
Definition SkTypes.h:175
virtual void loadSystemFonts(const SkFontScanner *, Families *) const =0
sk_sp< SkTypeface > onMakeFromStreamIndex(std::unique_ptr< SkStreamAsset >, int ttcIndex) const override
int onCountFamilies() const override
sk_sp< SkFontStyleSet > onCreateStyleSet(int index) const override
skia_private::TArray< sk_sp< SkFontStyleSet_Custom > > Families
sk_sp< SkTypeface > onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle &, const char *bcp47[], int bcp47Count, SkUnichar character) const override
sk_sp< SkTypeface > onMatchFamilyStyle(const char familyName[], const SkFontStyle &fontStyle) const override
sk_sp< SkTypeface > onLegacyMakeTypeface(const char familyName[], SkFontStyle style) const override
sk_sp< SkTypeface > onMakeFromData(sk_sp< SkData > data, int ttcIndex) const override
sk_sp< SkTypeface > onMakeFromFile(const char path[], int ttcIndex) const override
sk_sp< SkTypeface > onMakeFromStreamArgs(std::unique_ptr< SkStreamAsset >, const SkFontArguments &) const override
void onGetFamilyName(int index, SkString *familyName) const override
sk_sp< SkFontStyleSet > onMatchFamily(const char familyName[]) const override
void appendTypeface(sk_sp< SkTypeface > typeface)
void getStyle(int index, SkFontStyle *style, SkString *name) override
sk_sp< SkTypeface > matchStyle(const SkFontStyle &pattern) override
sk_sp< SkTypeface > createTypeface(int index) override
void onGetFamilyName(SkString *familyName) const override
void onGetFontDescriptor(SkFontDescriptor *desc, bool *isLocal) const override
sk_sp< SkTypeface > onMakeClone(const SkFontArguments &args) const override
std::unique_ptr< SkStreamAsset > onOpenStream(int *) const override
std::unique_ptr< SkFontData > onMakeFontData() const override
sk_sp< SkTypeface > onMakeClone(const SkFontArguments &args) const override
std::unique_ptr< SkStreamAsset > onOpenStream(int *ttcIndex) const override
std::unique_ptr< SkFontData > onMakeFontData() const override
bool isFixedPitch() const
Definition SkTypeface.h:68
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const char * name
Definition fuchsia.cc:50