Flutter Engine
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 (std::string family_name, std::string asset)
 
size_t GetFamilyCount () const override
 
std::string GetFamilyName (int index) const override
 
SkFontStyleSet * MatchFamily (const std::string &family_name) override
 
- Public Member Functions inherited from txt::FontAssetProvider
virtual ~FontAssetProvider ()=default
 

Additional Inherited Members

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

Detailed Description

Definition at line 61 of file asset_manager_font_provider.h.

Constructor & Destructor Documentation

◆ AssetManagerFontProvider()

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

Definition at line 23 of file asset_manager_font_provider.cc.

References ~AssetManagerFontProvider().

25  : asset_manager_(asset_manager) {}

◆ ~AssetManagerFontProvider()

flutter::AssetManagerFontProvider::~AssetManagerFontProvider ( )
overridedefault

Member Function Documentation

◆ GetFamilyCount()

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

Implements txt::FontAssetProvider.

Definition at line 30 of file asset_manager_font_provider.cc.

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

◆ GetFamilyName()

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

Implements txt::FontAssetProvider.

Definition at line 35 of file asset_manager_font_provider.cc.

References FML_DCHECK.

35  {
36  FML_DCHECK(index >= 0 && static_cast<size_t>(index) < family_names_.size());
37  return family_names_[index];
38 }
#define FML_DCHECK(condition)
Definition: logging.h:86

◆ MatchFamily()

SkFontStyleSet * flutter::AssetManagerFontProvider::MatchFamily ( const std::string &  family_name)
overridevirtual

Implements txt::FontAssetProvider.

Definition at line 41 of file asset_manager_font_provider.cc.

References txt::FontAssetProvider::CanonicalFamilyName().

42  {
43  auto found = registered_families_.find(CanonicalFamilyName(family_name));
44  if (found == registered_families_.end()) {
45  return nullptr;
46  }
47  sk_sp<SkFontStyleSet> font_style_set = found->second;
48  return font_style_set.release();
49 }
static std::string CanonicalFamilyName(std::string family_name)

◆ RegisterAsset()

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

Definition at line 51 of file asset_manager_font_provider.cc.

References txt::FontAssetProvider::CanonicalFamilyName(), and value.

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

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