Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
txt::TypefaceFontAssetProvider Class Reference

#include <typeface_font_asset_provider.h>

Inheritance diagram for txt::TypefaceFontAssetProvider:
txt::FontAssetProvider

Public Member Functions

 TypefaceFontAssetProvider ()
 
 ~TypefaceFontAssetProvider () override
 
void RegisterTypeface (sk_sp< SkTypeface > typeface)
 
void RegisterTypeface (sk_sp< SkTypeface > typeface, std::string family_name_alias)
 
size_t GetFamilyCount () const override
 
std::string GetFamilyName (int index) const override
 
sk_sp< SkFontStyleSetMatchFamily (const std::string &family_name) override
 
- Public Member Functions inherited from txt::FontAssetProvider
virtual ~FontAssetProvider ()=default
 
virtual size_t GetFamilyCount () const =0
 
virtual std::string GetFamilyName (int index) const =0
 
virtual sk_sp< SkFontStyleSetMatchFamily (const std::string &family_name)=0
 

Additional Inherited Members

- Static Protected Member Functions inherited from txt::FontAssetProvider
static std::string CanonicalFamilyName (std::string family_name)
 

Detailed Description

Definition at line 56 of file typeface_font_asset_provider.h.

Constructor & Destructor Documentation

◆ TypefaceFontAssetProvider()

txt::TypefaceFontAssetProvider::TypefaceFontAssetProvider ( )
default

◆ ~TypefaceFontAssetProvider()

txt::TypefaceFontAssetProvider::~TypefaceFontAssetProvider ( )
overridedefault

Member Function Documentation

◆ GetFamilyCount()

size_t txt::TypefaceFontAssetProvider::GetFamilyCount ( ) const
overridevirtual

Implements txt::FontAssetProvider.

Definition at line 30 of file typeface_font_asset_provider.cc.

30 {
31 return family_names_.size();
32}

◆ GetFamilyName()

std::string txt::TypefaceFontAssetProvider::GetFamilyName ( int  index) const
overridevirtual

Implements txt::FontAssetProvider.

Definition at line 35 of file typeface_font_asset_provider.cc.

35 {
36 return family_names_[index];
37}

◆ MatchFamily()

sk_sp< SkFontStyleSet > txt::TypefaceFontAssetProvider::MatchFamily ( const std::string &  family_name)
overridevirtual

Implements txt::FontAssetProvider.

Definition at line 40 of file typeface_font_asset_provider.cc.

41 {
42 auto found = registered_families_.find(CanonicalFamilyName(family_name));
43 if (found == registered_families_.end()) {
44 return nullptr;
45 }
46 return found->second;
47}
static std::string CanonicalFamilyName(std::string family_name)

◆ RegisterTypeface() [1/2]

void txt::TypefaceFontAssetProvider::RegisterTypeface ( sk_sp< SkTypeface typeface)

Definition at line 49 of file typeface_font_asset_provider.cc.

49 {
50 if (typeface == nullptr) {
51 return;
52 }
53
54 SkString sk_family_name;
55 typeface->getFamilyName(&sk_family_name);
56
57 std::string family_name(sk_family_name.c_str(), sk_family_name.size());
58 RegisterTypeface(std::move(typeface), std::move(family_name));
59}
size_t size() const
Definition: SkString.h:131
const char * c_str() const
Definition: SkString.h:133
void getFamilyName(SkString *name) const
Definition: SkTypeface.cpp:459
void RegisterTypeface(sk_sp< SkTypeface > typeface)

◆ RegisterTypeface() [2/2]

void txt::TypefaceFontAssetProvider::RegisterTypeface ( sk_sp< SkTypeface typeface,
std::string  family_name_alias 
)

Definition at line 61 of file typeface_font_asset_provider.cc.

63 {
64 if (family_name_alias.empty()) {
65 return;
66 }
67
68 std::string canonical_name = CanonicalFamilyName(family_name_alias);
69 auto family_it = registered_families_.find(canonical_name);
70 if (family_it == registered_families_.end()) {
71 family_names_.push_back(family_name_alias);
72 auto value =
73 std::make_pair(canonical_name, sk_make_sp<TypefaceFontStyleSet>());
74 family_it = registered_families_.emplace(value).first;
75 }
76 family_it->second->registerTypeface(std::move(typeface));
77}
uint8_t value

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