Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
SkFontMgr_Custom Class Reference

#include <SkFontMgr_custom.h>

Inheritance diagram for SkFontMgr_Custom:
SkFontMgr SkRefCnt SkRefCntBase

Classes

class  SystemFontLoader
 

Public Types

typedef skia_private::TArray< sk_sp< SkFontStyleSet_Custom > > Families
 

Public Member Functions

 SkFontMgr_Custom (const SystemFontLoader &loader)
 
- Public Member Functions inherited from SkFontMgr
int countFamilies () const
 
void getFamilyName (int index, SkString *familyName) const
 
sk_sp< SkFontStyleSetcreateStyleSet (int index) const
 
sk_sp< SkFontStyleSetmatchFamily (const char familyName[]) const
 
sk_sp< SkTypefacematchFamilyStyle (const char familyName[], const SkFontStyle &) const
 
sk_sp< SkTypefacematchFamilyStyleCharacter (const char familyName[], const SkFontStyle &, const char *bcp47[], int bcp47Count, SkUnichar character) const
 
sk_sp< SkTypefacemakeFromData (sk_sp< SkData >, int ttcIndex=0) const
 
sk_sp< SkTypefacemakeFromStream (std::unique_ptr< SkStreamAsset >, int ttcIndex=0) const
 
sk_sp< SkTypefacemakeFromStream (std::unique_ptr< SkStreamAsset >, const SkFontArguments &) const
 
sk_sp< SkTypefacemakeFromFile (const char path[], int ttcIndex=0) const
 
sk_sp< SkTypefacelegacyMakeTypeface (const char familyName[], SkFontStyle style) const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

int onCountFamilies () const override
 
void onGetFamilyName (int index, SkString *familyName) const override
 
sk_sp< SkFontStyleSetonCreateStyleSet (int index) const override
 
sk_sp< SkFontStyleSetonMatchFamily (const char familyName[]) const override
 
sk_sp< SkTypefaceonMatchFamilyStyle (const char familyName[], const SkFontStyle &fontStyle) const override
 
sk_sp< SkTypefaceonMatchFamilyStyleCharacter (const char familyName[], const SkFontStyle &, const char *bcp47[], int bcp47Count, SkUnichar character) const override
 
sk_sp< SkTypefaceonMakeFromData (sk_sp< SkData > data, int ttcIndex) const override
 
sk_sp< SkTypefaceonMakeFromStreamIndex (std::unique_ptr< SkStreamAsset >, int ttcIndex) const override
 
sk_sp< SkTypefaceonMakeFromStreamArgs (std::unique_ptr< SkStreamAsset >, const SkFontArguments &) const override
 
sk_sp< SkTypefaceonMakeFromFile (const char path[], int ttcIndex) const override
 
sk_sp< SkTypefaceonLegacyMakeTypeface (const char familyName[], SkFontStyle style) const override
 

Additional Inherited Members

- Static Public Member Functions inherited from SkFontMgr
static sk_sp< SkFontMgrRefEmpty ()
 

Detailed Description

SkFontMgr_Custom

This class is essentially a collection of SkFontStyleSet_Custom, one SkFontStyleSet_Custom for each family. This class may be modified to load fonts from any source by changing the initialization.

Definition at line 110 of file SkFontMgr_custom.h.

Member Typedef Documentation

◆ Families

Definition at line 112 of file SkFontMgr_custom.h.

Constructor & Destructor Documentation

◆ SkFontMgr_Custom()

SkFontMgr_Custom::SkFontMgr_Custom ( const SystemFontLoader loader)
explicit

Definition at line 128 of file SkFontMgr_custom.cpp.

129 : fDefaultFamily(nullptr)
130 , fScanner(std::make_unique<SkFontScanner_FreeType>()) {
131
132 loader.loadSystemFonts(fScanner.get(), &fFamilies);
133
134 // Try to pick a default font.
135 static const char* defaultNames[] = {
136 "Arial", "Verdana", "Times New Roman", "Droid Sans", "DejaVu Serif", nullptr
137 };
138 for (size_t i = 0; i < std::size(defaultNames); ++i) {
139 sk_sp<SkFontStyleSet> set(this->onMatchFamily(defaultNames[i]));
140 if (nullptr == set) {
141 continue;
142 }
143
147 if (nullptr == tf) {
148 continue;
149 }
150
151 fDefaultFamily = set;
152 break;
153 }
154 if (nullptr == fDefaultFamily) {
155 fDefaultFamily = fFamilies[0];
156 }
157}
sk_sp< SkFontStyleSet > onMatchFamily(const char familyName[]) const override
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition switches.h:76

Member Function Documentation

◆ onCountFamilies()

int SkFontMgr_Custom::onCountFamilies ( ) const
overrideprotectedvirtual

Implements SkFontMgr.

Definition at line 159 of file SkFontMgr_custom.cpp.

159 {
160 return fFamilies.size();
161}
int size() const
Definition SkTArray.h:416

◆ onCreateStyleSet()

sk_sp< SkFontStyleSet > SkFontMgr_Custom::onCreateStyleSet ( int  index) const
overrideprotectedvirtual

Implements SkFontMgr.

Definition at line 168 of file SkFontMgr_custom.cpp.

168 {
169 SkASSERT(index < fFamilies.size());
170 return fFamilies[index];
171}
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ onGetFamilyName()

void SkFontMgr_Custom::onGetFamilyName ( int  index,
SkString familyName 
) const
overrideprotectedvirtual

Implements SkFontMgr.

Definition at line 163 of file SkFontMgr_custom.cpp.

163 {
164 SkASSERT(index < fFamilies.size());
165 familyName->set(fFamilies[index]->getFamilyName());
166}
void getFamilyName(int index, SkString *familyName) const
Definition SkFontMgr.cpp:97
void set(const SkString &src)
Definition SkString.h:186

◆ onLegacyMakeTypeface()

sk_sp< SkTypeface > SkFontMgr_Custom::onLegacyMakeTypeface ( const char  familyName[],
SkFontStyle  style 
) const
overrideprotectedvirtual

Implements SkFontMgr.

Definition at line 216 of file SkFontMgr_custom.cpp.

217 {
219
220 if (familyName) {
221 tf = this->onMatchFamilyStyle(familyName, style);
222 }
223
224 if (!tf) {
225 tf = fDefaultFamily->matchStyle(style);
226 }
227
228 return tf;
229}
sk_sp< SkTypeface > onMatchFamilyStyle(const char familyName[], const SkFontStyle &fontStyle) const override
virtual sk_sp< SkTypeface > matchStyle(const SkFontStyle &pattern)=0

◆ onMakeFromData()

sk_sp< SkTypeface > SkFontMgr_Custom::onMakeFromData ( sk_sp< SkData data,
int  ttcIndex 
) const
overrideprotectedvirtual

Implements SkFontMgr.

Definition at line 197 of file SkFontMgr_custom.cpp.

197 {
198 return this->makeFromStream(std::make_unique<SkMemoryStream>(std::move(data)), ttcIndex);
199}
sk_sp< SkTypeface > makeFromStream(std::unique_ptr< SkStreamAsset >, int ttcIndex=0) const

◆ onMakeFromFile()

sk_sp< SkTypeface > SkFontMgr_Custom::onMakeFromFile ( const char  path[],
int  ttcIndex 
) const
overrideprotectedvirtual

Implements SkFontMgr.

Definition at line 211 of file SkFontMgr_custom.cpp.

211 {
212 std::unique_ptr<SkStreamAsset> stream = SkStream::MakeFromFile(path);
213 return stream ? this->makeFromStream(std::move(stream), ttcIndex) : nullptr;
214}
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
Definition SkStream.cpp:922

◆ onMakeFromStreamArgs()

sk_sp< SkTypeface > SkFontMgr_Custom::onMakeFromStreamArgs ( std::unique_ptr< SkStreamAsset stream,
const SkFontArguments args 
) const
overrideprotectedvirtual

Implements SkFontMgr.

Definition at line 206 of file SkFontMgr_custom.cpp.

207 {
208 return SkTypeface_FreeType::MakeFromStream(std::move(stream), args);
209}
static sk_sp< SkTypeface > MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ onMakeFromStreamIndex()

sk_sp< SkTypeface > SkFontMgr_Custom::onMakeFromStreamIndex ( std::unique_ptr< SkStreamAsset stream,
int  ttcIndex 
) const
overrideprotectedvirtual

Implements SkFontMgr.

Definition at line 201 of file SkFontMgr_custom.cpp.

202 {
203 return this->makeFromStream(std::move(stream), SkFontArguments().setCollectionIndex(ttcIndex));
204}

◆ onMatchFamily()

sk_sp< SkFontStyleSet > SkFontMgr_Custom::onMatchFamily ( const char  familyName[]) const
overrideprotectedvirtual

May return NULL if the name is not found.

Implements SkFontMgr.

Definition at line 173 of file SkFontMgr_custom.cpp.

173 {
174 for (int i = 0; i < fFamilies.size(); ++i) {
175 if (fFamilies[i]->getFamilyName().equals(familyName)) {
176 return fFamilies[i];
177 }
178 }
179 return nullptr;
180}
static bool equals(T *a, T *b)

◆ onMatchFamilyStyle()

sk_sp< SkTypeface > SkFontMgr_Custom::onMatchFamilyStyle ( const char  familyName[],
const SkFontStyle fontStyle 
) const
overrideprotectedvirtual

Implements SkFontMgr.

Definition at line 182 of file SkFontMgr_custom.cpp.

184{
185 sk_sp<SkFontStyleSet> sset(this->matchFamily(familyName));
186 return sset->matchStyle(fontStyle);
187}
sk_sp< SkFontStyleSet > matchFamily(const char familyName[]) const

◆ onMatchFamilyStyleCharacter()

sk_sp< SkTypeface > SkFontMgr_Custom::onMatchFamilyStyleCharacter ( const char  familyName[],
const SkFontStyle ,
const char *  bcp47[],
int  bcp47Count,
SkUnichar  character 
) const
overrideprotectedvirtual

Implements SkFontMgr.

Definition at line 189 of file SkFontMgr_custom.cpp.

193{
194 return nullptr;
195}

The documentation for this class was generated from the following files: