Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::AssetManagerFontProvider Class Reference

#include <asset_manager_font_provider.h>

Inheritance diagram for flutter::AssetManagerFontProvider:
txt::FontAssetProvider

Public Member Functions

 AssetManagerFontProvider (std::shared_ptr< AssetManager > asset_manager)
 
 ~AssetManagerFontProvider () override
 
void RegisterAsset (const std::string &family_name, const std::string &asset)
 
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 65 of file asset_manager_font_provider.h.

Constructor & Destructor Documentation

◆ AssetManagerFontProvider()

flutter::AssetManagerFontProvider::AssetManagerFontProvider ( std::shared_ptr< AssetManager asset_manager)
explicit

Definition at line 27 of file asset_manager_font_provider.cc.

29 : asset_manager_(std::move(asset_manager)) {}

◆ ~AssetManagerFontProvider()

flutter::AssetManagerFontProvider::~AssetManagerFontProvider ( )
overridedefault

Member Function Documentation

◆ GetFamilyCount()

size_t flutter::AssetManagerFontProvider::GetFamilyCount ( ) const
overridevirtual

Implements txt::FontAssetProvider.

Definition at line 34 of file asset_manager_font_provider.cc.

34 {
35 return family_names_.size();
36}

◆ GetFamilyName()

std::string flutter::AssetManagerFontProvider::GetFamilyName ( int  index) const
overridevirtual

Implements txt::FontAssetProvider.

Definition at line 39 of file asset_manager_font_provider.cc.

39 {
40 FML_DCHECK(index >= 0 && static_cast<size_t>(index) < family_names_.size());
41 return family_names_[index];
42}
#define FML_DCHECK(condition)
Definition: logging.h:103

◆ MatchFamily()

sk_sp< SkFontStyleSet > flutter::AssetManagerFontProvider::MatchFamily ( const std::string &  family_name)
overridevirtual

Implements txt::FontAssetProvider.

Definition at line 45 of file asset_manager_font_provider.cc.

46 {
47 auto found = registered_families_.find(CanonicalFamilyName(family_name));
48 if (found == registered_families_.end()) {
49 return nullptr;
50 }
51 return found->second;
52}
static std::string CanonicalFamilyName(std::string family_name)

◆ RegisterAsset()

void flutter::AssetManagerFontProvider::RegisterAsset ( const std::string &  family_name,
const std::string &  asset 
)

Definition at line 54 of file asset_manager_font_provider.cc.

55 {
56 std::string canonical_name = CanonicalFamilyName(family_name);
57 auto family_it = registered_families_.find(canonical_name);
58
59 if (family_it == registered_families_.end()) {
60 family_names_.push_back(family_name);
61 auto value = std::make_pair(
62 canonical_name,
63 sk_make_sp<AssetManagerFontStyleSet>(asset_manager_, family_name));
64 family_it = registered_families_.emplace(value).first;
65 }
66
67 family_it->second->registerAsset(asset);
68}
uint8_t value

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