Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
skia::textlayout::TypefaceFontProvider Class Reference

#include <TypefaceFontProvider.h>

Inheritance diagram for skia::textlayout::TypefaceFontProvider:
SkFontMgr SkRefCnt SkRefCntBase

Public Member Functions

size_t registerTypeface (sk_sp< SkTypeface > typeface)
 
size_t registerTypeface (sk_sp< SkTypeface > typeface, const SkString &alias)
 
int onCountFamilies () const override
 
void onGetFamilyName (int index, SkString *familyName) const override
 
sk_sp< SkFontStyleSetonMatchFamily (const char familyName[]) const override
 
sk_sp< SkFontStyleSetonCreateStyleSet (int) const override
 
sk_sp< SkTypefaceonMatchFamilyStyle (const char familyName[], const SkFontStyle &pattern) const override
 
sk_sp< SkTypefaceonMatchFamilyStyleCharacter (const char[], const SkFontStyle &, const char *[], int, SkUnichar) const override
 
sk_sp< SkTypefaceonMakeFromData (sk_sp< SkData >, int) const override
 
sk_sp< SkTypefaceonMakeFromStreamIndex (std::unique_ptr< SkStreamAsset >, int) const override
 
sk_sp< SkTypefaceonMakeFromStreamArgs (std::unique_ptr< SkStreamAsset >, const SkFontArguments &) const override
 
sk_sp< SkTypefaceonMakeFromFile (const char[], int) const override
 
sk_sp< SkTypefaceonLegacyMakeTypeface (const char[], SkFontStyle) const override
 
- 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
 

Additional Inherited Members

- Static Public Member Functions inherited from SkFontMgr
static sk_sp< SkFontMgrRefEmpty ()
 
virtual int onCountFamilies () const =0
 
virtual void onGetFamilyName (int index, SkString *familyName) const =0
 
virtual sk_sp< SkFontStyleSetonCreateStyleSet (int index) const =0
 
virtual sk_sp< SkFontStyleSetonMatchFamily (const char familyName[]) const =0
 
virtual sk_sp< SkTypefaceonMatchFamilyStyle (const char familyName[], const SkFontStyle &) const =0
 
virtual sk_sp< SkTypefaceonMatchFamilyStyleCharacter (const char familyName[], const SkFontStyle &, const char *bcp47[], int bcp47Count, SkUnichar character) const =0
 
virtual sk_sp< SkTypefaceonMakeFromData (sk_sp< SkData >, int ttcIndex) const =0
 
virtual sk_sp< SkTypefaceonMakeFromStreamIndex (std::unique_ptr< SkStreamAsset >, int ttcIndex) const =0
 
virtual sk_sp< SkTypefaceonMakeFromStreamArgs (std::unique_ptr< SkStreamAsset >, const SkFontArguments &) const =0
 
virtual sk_sp< SkTypefaceonMakeFromFile (const char path[], int ttcIndex) const =0
 
virtual sk_sp< SkTypefaceonLegacyMakeTypeface (const char familyName[], SkFontStyle) const =0
 

Detailed Description

Definition at line 38 of file TypefaceFontProvider.h.

Member Function Documentation

◆ onCountFamilies()

int skia::textlayout::TypefaceFontProvider::onCountFamilies ( ) const
overridevirtual

Implements SkFontMgr.

Definition at line 12 of file TypefaceFontProvider.cpp.

12{ return fRegisteredFamilies.count(); }

◆ onCreateStyleSet()

sk_sp< SkFontStyleSet > skia::textlayout::TypefaceFontProvider::onCreateStyleSet ( int  index) const
overridevirtual

Implements SkFontMgr.

Definition at line 24 of file TypefaceFontProvider.cpp.

24 {
25 SkASSERT(index < fRegisteredFamilies.count());
26 auto found = fRegisteredFamilies.find(fFamilyNames[index]);
27 return found ? *found : nullptr;
28}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ onGetFamilyName()

void skia::textlayout::TypefaceFontProvider::onGetFamilyName ( int  index,
SkString familyName 
) const
overridevirtual

Implements SkFontMgr.

Definition at line 14 of file TypefaceFontProvider.cpp.

14 {
15 SkASSERT(index < fRegisteredFamilies.count());
16 familyName->set(fFamilyNames[index]);
17}
void set(const SkString &src)
Definition: SkString.h:186

◆ onLegacyMakeTypeface()

sk_sp< SkTypeface > skia::textlayout::TypefaceFontProvider::onLegacyMakeTypeface ( const char  familyName[],
SkFontStyle  style 
) const
overridevirtual

Implements SkFontMgr.

Definition at line 66 of file TypefaceFontProvider.cpp.

67 {
68 if (familyName) {
69 sk_sp<SkTypeface> matchedByFamily = this->matchFamilyStyle(familyName, style);
70 if (matchedByFamily) {
71 return matchedByFamily;
72 }
73 }
74 if (this->countFamilies() == 0) {
75 return nullptr;
76 }
77 sk_sp<SkFontStyleSet> defaultFamily = this->createStyleSet(0);
78 if (!defaultFamily) {
79 return nullptr;
80 }
81 return defaultFamily->matchStyle(style);
82}
sk_sp< SkFontStyleSet > createStyleSet(int index) const
Definition: SkFontMgr.cpp:101
int countFamilies() const
Definition: SkFontMgr.cpp:93
sk_sp< SkTypeface > matchFamilyStyle(const char familyName[], const SkFontStyle &) const
Definition: SkFontMgr.cpp:109
virtual sk_sp< SkTypeface > matchStyle(const SkFontStyle &pattern)=0

◆ onMakeFromData()

sk_sp< SkTypeface > skia::textlayout::TypefaceFontProvider::onMakeFromData ( sk_sp< SkData ,
int   
) const
inlineoverridevirtual

Implements SkFontMgr.

Definition at line 57 of file TypefaceFontProvider.h.

57{ return nullptr; }

◆ onMakeFromFile()

sk_sp< SkTypeface > skia::textlayout::TypefaceFontProvider::onMakeFromFile ( const char  [],
int   
) const
inlineoverridevirtual

Implements SkFontMgr.

Definition at line 65 of file TypefaceFontProvider.h.

65 {
66 return nullptr;
67 }

◆ onMakeFromStreamArgs()

sk_sp< SkTypeface > skia::textlayout::TypefaceFontProvider::onMakeFromStreamArgs ( std::unique_ptr< SkStreamAsset ,
const SkFontArguments  
) const
inlineoverridevirtual

Implements SkFontMgr.

Definition at line 61 of file TypefaceFontProvider.h.

62 {
63 return nullptr;
64 }

◆ onMakeFromStreamIndex()

sk_sp< SkTypeface > skia::textlayout::TypefaceFontProvider::onMakeFromStreamIndex ( std::unique_ptr< SkStreamAsset ,
int   
) const
inlineoverridevirtual

Implements SkFontMgr.

Definition at line 58 of file TypefaceFontProvider.h.

58 {
59 return nullptr;
60 }

◆ onMatchFamily()

sk_sp< SkFontStyleSet > skia::textlayout::TypefaceFontProvider::onMatchFamily ( const char  familyName[]) const
overridevirtual

May return NULL if the name is not found.

Implements SkFontMgr.

Definition at line 19 of file TypefaceFontProvider.cpp.

19 {
20 auto found = fRegisteredFamilies.find(SkString(familyName));
21 return found ? *found : nullptr;
22}

◆ onMatchFamilyStyle()

sk_sp< SkTypeface > skia::textlayout::TypefaceFontProvider::onMatchFamilyStyle ( const char  familyName[],
const SkFontStyle pattern 
) const
overridevirtual

Implements SkFontMgr.

Definition at line 30 of file TypefaceFontProvider.cpp.

30 {
31 sk_sp<SkFontStyleSet> sset(this->matchFamily(familyName));
32 if (sset) {
33 return sset->matchStyle(pattern);
34 }
35
36 return nullptr;
37}
sk_sp< SkFontStyleSet > matchFamily(const char familyName[]) const
Definition: SkFontMgr.cpp:105

◆ onMatchFamilyStyleCharacter()

sk_sp< SkTypeface > skia::textlayout::TypefaceFontProvider::onMatchFamilyStyleCharacter ( const char  [],
const SkFontStyle ,
const char *  [],
int  ,
SkUnichar   
) const
inlineoverridevirtual

Implements SkFontMgr.

Definition at line 51 of file TypefaceFontProvider.h.

53 {
54 return nullptr;
55 }

◆ registerTypeface() [1/2]

size_t skia::textlayout::TypefaceFontProvider::registerTypeface ( sk_sp< SkTypeface typeface)

Definition at line 39 of file TypefaceFontProvider.cpp.

39 {
40 if (typeface == nullptr) {
41 return 0;
42 }
43
44 SkString familyName;
45 typeface->getFamilyName(&familyName);
46
47 return registerTypeface(std::move(typeface), std::move(familyName));
48}
void getFamilyName(SkString *name) const
Definition: SkTypeface.cpp:459
size_t registerTypeface(sk_sp< SkTypeface > typeface)

◆ registerTypeface() [2/2]

size_t skia::textlayout::TypefaceFontProvider::registerTypeface ( sk_sp< SkTypeface typeface,
const SkString alias 
)

Definition at line 50 of file TypefaceFontProvider.cpp.

50 {
51 if (familyName.size() == 0) {
52 return 0;
53 }
54
55 auto found = fRegisteredFamilies.find(familyName);
56 if (found == nullptr) {
57 found = fRegisteredFamilies.set(familyName, sk_make_sp<TypefaceFontStyleSet>(familyName));
58 fFamilyNames.emplace_back(familyName);
59 }
60
61 (*found)->appendTypeface(std::move(typeface));
62
63 return 1;
64}
T & emplace_back(Args &&... args)
Definition: SkTArray.h:248

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