25#include <unordered_map>
27#include "flutter/fml/logging.h"
28#include "flutter/fml/trace_event.h"
36FontCollection::~FontCollection() {
37 if (skt_collection_) {
38 skt_collection_->clearCaches();
42size_t FontCollection::GetFontManagersCount()
const {
43 return GetFontManagerOrder().size();
46void FontCollection::SetupDefaultFontManager(
47 uint32_t font_initialization_data) {
49 skt_collection_.reset();
53 default_font_manager_ = font_manager;
54 skt_collection_.
reset();
58 asset_font_manager_ = font_manager;
59 skt_collection_.
reset();
63 dynamic_font_manager_ = font_manager;
64 skt_collection_.
reset();
68 test_font_manager_ = font_manager;
69 skt_collection_.
reset();
73std::vector<sk_sp<SkFontMgr>> FontCollection::GetFontManagerOrder()
const {
74 std::vector<sk_sp<SkFontMgr>> order;
75 if (dynamic_font_manager_)
76 order.push_back(dynamic_font_manager_);
77 if (asset_font_manager_)
78 order.push_back(asset_font_manager_);
79 if (test_font_manager_)
80 order.push_back(test_font_manager_);
81 if (default_font_manager_)
82 order.push_back(default_font_manager_);
86void FontCollection::DisableFontFallback() {
87 enable_font_fallback_ =
false;
88 if (skt_collection_) {
89 skt_collection_->disableFontFallback();
93void FontCollection::ClearFontFamilyCache() {
94 if (skt_collection_) {
95 skt_collection_->clearCaches();
100FontCollection::CreateSktFontCollection() {
101 if (!skt_collection_) {
102 skt_collection_ = sk_make_sp<skia::textlayout::FontCollection>();
104 std::vector<SkString> default_font_families;
106 default_font_families.emplace_back(family);
108 skt_collection_->setDefaultFontManager(default_font_manager_,
109 default_font_families);
110 skt_collection_->setAssetFontManager(asset_font_manager_);
111 skt_collection_->setDynamicFontManager(dynamic_font_manager_);
112 skt_collection_->setTestFontManager(test_font_manager_);
113 if (!enable_font_fallback_) {
114 skt_collection_->disableFontFallback();
118 return skt_collection_;
void reset(T *ptr=nullptr)
std::vector< std::string > GetDefaultFontFamilies()
sk_sp< SkFontMgr > GetDefaultFontManager(uint32_t font_initialization_data)