Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
SkFontConfigInterface Class Referenceabstract

#include <SkFontConfigInterface.h>

Inheritance diagram for SkFontConfigInterface:
SkRefCnt SkRefCntBase SkFontConfigInterfaceDirect

Classes

struct  FontIdentity
 

Public Types

using INHERITED = SkRefCnt
 

Public Member Functions

virtual bool matchFamilyName (const char familyName[], SkFontStyle requested, FontIdentity *outFontIdentifier, SkString *outFamilyName, SkFontStyle *outStyle)=0
 
virtual SkStreamAssetopenStream (const FontIdentity &)=0
 
virtual sk_sp< SkTypefacemakeTypeface (const FontIdentity &identity, sk_sp< SkFontMgr > mgr)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< SkFontConfigInterfaceRefGlobal ()
 
static void SetGlobal (sk_sp< SkFontConfigInterface > fc)
 
static SkFontConfigInterfaceGetSingletonDirectInterface ()
 

Detailed Description

A simple interface for remotable font management. The global instance can be found with RefGlobal().

Definition at line 24 of file SkFontConfigInterface.h.

Member Typedef Documentation

◆ INHERITED

Definition at line 109 of file SkFontConfigInterface.h.

Member Function Documentation

◆ GetSingletonDirectInterface()

SkFontConfigInterface * SkFontConfigInterface::GetSingletonDirectInterface ( )
static

Return a singleton instance of a direct subclass that calls into libfontconfig. This does not affect the refcnt of the returned instance.

Definition at line 11 of file SkFontConfigInterface_direct_factory.cpp.

11 {
12 static SkFontConfigInterface* singleton;
13 static SkOnce once;
14 once([]{ singleton = new SkFontConfigInterfaceDirect(nullptr); });
15 return singleton;
16}
Definition: SkOnce.h:22

◆ makeTypeface()

sk_sp< SkTypeface > SkFontConfigInterface::makeTypeface ( const FontIdentity identity,
sk_sp< SkFontMgr mgr 
)
virtual

Return an SkTypeface for the given FontIdentity.

The default implementation simply returns a new typeface built using data obtained from openStream() using the provided SkFontMgr, but derived classes may implement more complex caching schemes.

Definition at line 35 of file SkFontConfigInterface.cpp.

36 {
37 return mgr->makeFromStream(std::unique_ptr<SkStreamAsset>(this->openStream(identity)),
38 identity.fTTCIndex);
39}
virtual SkStreamAsset * openStream(const FontIdentity &)=0
sk_sp< SkTypeface > makeFromStream(std::unique_ptr< SkStreamAsset >, int ttcIndex=0) const
Definition: SkFontMgr.cpp:127

◆ matchFamilyName()

virtual bool SkFontConfigInterface::matchFamilyName ( const char  familyName[],
SkFontStyle  requested,
FontIdentity outFontIdentifier,
SkString outFamilyName,
SkFontStyle outStyle 
)
pure virtual

Given a familyName and style, find the best match.

If a match is found, return true and set its outFontIdentifier. If outFamilyName is not null, assign the found familyName to it (which may differ from the requested familyName). If outStyle is not null, assign the found style to it (which may differ from the requested style).

If a match is not found, return false, and ignore all out parameters.

Implemented in SkFontConfigInterfaceDirect.

◆ openStream()

virtual SkStreamAsset * SkFontConfigInterface::openStream ( const FontIdentity )
pure virtual

Given a FontRef, open a stream to access its data, or return null if the FontRef's data is not available. The caller is responsible for deleting the stream when it is done accessing the data.

Implemented in SkFontConfigInterfaceDirect.

◆ RefGlobal()

sk_sp< SkFontConfigInterface > SkFontConfigInterface::RefGlobal ( )
static

Returns the global SkFontConfigInterface instance. If it is not nullptr, calls ref() on it. The caller must balance this with a call to unref(). The default SkFontConfigInterface is the result of calling GetSingletonDirectInterface.

Definition at line 19 of file SkFontConfigInterface.cpp.

19 {
21
24 }
26}
static SkMutex & font_config_interface_mutex()
static SkFontConfigInterface * gFontConfigInterface
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
static SkFontConfigInterface * GetSingletonDirectInterface()

◆ SetGlobal()

void SkFontConfigInterface::SetGlobal ( sk_sp< SkFontConfigInterface fc)
static

Replace the current global instance with the specified one.

Definition at line 28 of file SkFontConfigInterface.cpp.

28 {
30
33}
static void SkSafeUnref(T *obj)
Definition: SkRefCnt.h:149
T * release()
Definition: SkRefCnt.h:324

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