Flutter Impeller
impeller::interop::TypographyContext Class Referencefinal

#include <typography_context.h>

Inheritance diagram for impeller::interop::TypographyContext:
impeller::interop::Object< TypographyContext, IMPELLER_INTERNAL_HANDLE_NAME(ImpellerTypographyContext)> impeller::interop::ObjectBase

Public Member Functions

 TypographyContext ()
 
 ~TypographyContext () override
 
 TypographyContext (const TypographyContext &)=delete
 
TypographyContextoperator= (const TypographyContext &)=delete
 
bool IsValid () const
 
const std::shared_ptr< txt::FontCollection > & GetFontCollection () const
 
bool RegisterFont (std::unique_ptr< fml::Mapping > font_data, const char *family_name_alias)
 Registers custom font data. If an alias for the family name is provided, subsequent lookups will need to use that same alias. If not, the family name will be read from the font data. More...
 
- Public Member Functions inherited from impeller::interop::ObjectBase
 ObjectBase ()=default
 
virtual ~ObjectBase ()=default
 
 ObjectBase (const ObjectBase &)=delete
 
 ObjectBase (ObjectBase &&)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
ObjectBaseoperator= (ObjectBase &&)=delete
 
void Retain ()
 
void Release ()
 
uint64_t GetRefCountForTests () const
 

Additional Inherited Members

- Public Types inherited from impeller::interop::Object< TypographyContext, IMPELLER_INTERNAL_HANDLE_NAME(ImpellerTypographyContext)>
using InteropClass = TypographyContext
 
using InteropCSibling = IMPELLER_INTERNAL_HANDLE_NAME(ImpellerTypographyContext)
 
- Static Public Member Functions inherited from impeller::interop::ObjectBase
static void SafeRetain (void *ptr)
 
static void SafeRelease (void *ptr)
 

Detailed Description

Definition at line 17 of file typography_context.h.

Constructor & Destructor Documentation

◆ TypographyContext() [1/2]

impeller::interop::TypographyContext::TypographyContext ( )

Definition at line 16 of file typography_context.cc.

17  : collection_(std::make_shared<txt::FontCollection>()) {
18  static std::once_flag sICUInitOnceFlag;
19  std::call_once(sICUInitOnceFlag, []() {
20  auto icu_data = std::make_unique<fml::NonOwnedMapping>(
21  impeller_embedded_icu_data_data, impeller_embedded_icu_data_length);
22  fml::icu::InitializeICUFromMapping(std::move(icu_data));
23  });
24  // The fallback for all fonts. Looks in platform specific locations.
25  collection_->SetupDefaultFontManager(0u);
26 
27  // Looks for fonts in user supplied blobs.
28  asset_font_manager_ = sk_make_sp<skia::textlayout::TypefaceFontProvider>();
29  collection_->SetAssetFontManager(asset_font_manager_);
30 }

◆ ~TypographyContext()

impeller::interop::TypographyContext::~TypographyContext ( )
overridedefault

◆ TypographyContext() [2/2]

impeller::interop::TypographyContext::TypographyContext ( const TypographyContext )
delete

Member Function Documentation

◆ GetFontCollection()

const std::shared_ptr< txt::FontCollection > & impeller::interop::TypographyContext::GetFontCollection ( ) const

Definition at line 39 of file typography_context.cc.

39  {
40  return collection_;
41 }

◆ IsValid()

bool impeller::interop::TypographyContext::IsValid ( ) const

Definition at line 34 of file typography_context.cc.

34  {
35  return !!collection_;
36 }

◆ operator=()

TypographyContext& impeller::interop::TypographyContext::operator= ( const TypographyContext )
delete

◆ RegisterFont()

bool impeller::interop::TypographyContext::RegisterFont ( std::unique_ptr< fml::Mapping >  font_data,
const char *  family_name_alias 
)

Registers custom font data. If an alias for the family name is provided, subsequent lookups will need to use that same alias. If not, the family name will be read from the font data.

Parameters
[in]font_dataThe font data
[in]family_name_aliasThe family name alias
Returns
If the font data could be successfully registered.

Definition at line 68 of file typography_context.cc.

69  {
70  auto typeface = CreateTypefaceFromFontData(std::move(font_data));
71  if (typeface == nullptr) {
72  return false;
73  }
74  size_t result = 0u;
75  if (family_name_alias == nullptr) {
76  result = asset_font_manager_->registerTypeface(std::move(typeface));
77  } else {
78  result = asset_font_manager_->registerTypeface(std::move(typeface),
79  SkString{family_name_alias});
80  }
81  return result != 0;
82 }
static sk_sp< SkTypeface > CreateTypefaceFromFontData(std::unique_ptr< fml::Mapping > font_data)

References impeller::interop::CreateTypefaceFromFontData().


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