Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
skia::textlayout::TestFontCollection Class Reference

#include <TestFontCollection.h>

Inheritance diagram for skia::textlayout::TestFontCollection:
skia::textlayout::FontCollection SkRefCnt SkRefCntBase

Public Member Functions

 TestFontCollection (const std::string &resourceDir, bool testOnly=false, bool loadFonts=true)
 
size_t fontsFound () const
 
bool addFontFromFile (const std::string &path, const std::string &familyName="")
 
- Public Member Functions inherited from skia::textlayout::FontCollection
 FontCollection ()
 
size_t getFontManagersCount () const
 
void setAssetFontManager (sk_sp< SkFontMgr > fontManager)
 
void setDynamicFontManager (sk_sp< SkFontMgr > fontManager)
 
void setTestFontManager (sk_sp< SkFontMgr > fontManager)
 
void setDefaultFontManager (sk_sp< SkFontMgr > fontManager)
 
void setDefaultFontManager (sk_sp< SkFontMgr > fontManager, const char defaultFamilyName[])
 
void setDefaultFontManager (sk_sp< SkFontMgr > fontManager, const std::vector< SkString > &defaultFamilyNames)
 
sk_sp< SkFontMgrgetFallbackManager () const
 
std::vector< sk_sp< SkTypeface > > findTypefaces (const std::vector< SkString > &familyNames, SkFontStyle fontStyle)
 
std::vector< sk_sp< SkTypeface > > findTypefaces (const std::vector< SkString > &familyNames, SkFontStyle fontStyle, const std::optional< FontArguments > &fontArgs)
 
sk_sp< SkTypefacedefaultFallback (SkUnichar unicode, SkFontStyle fontStyle, const SkString &locale)
 
sk_sp< SkTypefacedefaultEmojiFallback (SkUnichar emojiStart, SkFontStyle fontStyle, const SkString &locale)
 
sk_sp< SkTypefacedefaultFallback ()
 
void disableFontFallback ()
 
void enableFontFallback ()
 
bool fontFallbackEnabled ()
 
ParagraphCachegetParagraphCache ()
 
void clearCaches ()
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Detailed Description

Definition at line 10 of file TestFontCollection.h.

Constructor & Destructor Documentation

◆ TestFontCollection()

skia::textlayout::TestFontCollection::TestFontCollection ( const std::string &  resourceDir,
bool  testOnly = false,
bool  loadFonts = true 
)

Definition at line 24 of file TestFontCollection.cpp.

25 : fResourceDir(resourceDir)
26 , fFontsFound(0) {
27 if (fDirs == resourceDir) {
28 return;
29 }
30
31 fFontProvider = sk_make_sp<TypefaceFontProvider>();
32
33 if (loadFonts) {
34 SkOSFile::Iter iter(fResourceDir.c_str());
36 while (iter.next(&path)) {
37 addFontFromFile(path.c_str());
38 }
39 }
40
41 fFontsFound = fFontProvider->countFamilies();
42 if (testOnly) {
43 this->setTestFontManager(fFontProvider);
44 } else {
45 this->setAssetFontManager(fFontProvider);
46 }
47 this->disableFontFallback();
48 fDirs = resourceDir;
49}
void setAssetFontManager(sk_sp< SkFontMgr > fontManager)
void setTestFontManager(sk_sp< SkFontMgr > fontManager)
bool addFontFromFile(const std::string &path, const std::string &familyName="")
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

Member Function Documentation

◆ addFontFromFile()

bool skia::textlayout::TestFontCollection::addFontFromFile ( const std::string &  path,
const std::string &  familyName = "" 
)

Definition at line 51 of file TestFontCollection.cpp.

51 {
52
53 SkString file_path;
54 file_path.printf("%s/%s", fResourceDir.c_str(), path.c_str());
55
56 std::unique_ptr<SkStreamAsset> file = SkFILEStream::Make(file_path.c_str());
57 if (!file) {
58 return false;
59 }
60#if defined(SK_TYPEFACE_FACTORY_FREETYPE)
63#elif defined(SK_TYPEFACE_FACTORY_CORETEXT)
64 sk_sp<SkTypeface> face = SkTypeface_Mac::MakeFromStream(std::move(file), SkFontArguments());
65#elif defined(SK_TYPEFACE_FACTORY_DIRECTWRITE)
67#else
68 sk_sp<SkTypeface> face = nullptr;
69#endif
70 if (familyName.empty()) {
71 fFontProvider->registerTypeface(std::move(face));
72 } else {
73 fFontProvider->registerTypeface(std::move(face), SkString(familyName.c_str()));
74 }
75
76 return true;
77}
static sk_sp< SkTypeface > SK_SPI MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
static std::unique_ptr< SkFILEStream > Make(const char path[])
Definition SkStream.h:314
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:534
const char * c_str() const
Definition SkString.h:133
static sk_sp< SkTypeface > MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)

◆ fontsFound()

size_t skia::textlayout::TestFontCollection::fontsFound ( ) const
inline

Definition at line 16 of file TestFontCollection.h.

16{ return fFontsFound; }

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