13#include <unordered_map>
24FontCollection::~FontCollection() {
25 if (skt_collection_) {
26 skt_collection_->clearCaches();
30size_t FontCollection::GetFontManagersCount()
const {
31 return GetFontManagerOrder().size();
34void FontCollection::SetupDefaultFontManager(
35 uint32_t font_initialization_data) {
37 skt_collection_.reset();
40void FontCollection::SetDefaultFontManager(sk_sp<SkFontMgr> font_manager) {
41 default_font_manager_ = std::move(font_manager);
42 skt_collection_.reset();
45void FontCollection::SetAssetFontManager(sk_sp<SkFontMgr> font_manager) {
46 asset_font_manager_ = std::move(font_manager);
47 skt_collection_.reset();
50void FontCollection::SetDynamicFontManager(sk_sp<SkFontMgr> font_manager) {
51 dynamic_font_manager_ = std::move(font_manager);
52 skt_collection_.reset();
55void FontCollection::SetTestFontManager(sk_sp<SkFontMgr> font_manager) {
56 test_font_manager_ = std::move(font_manager);
57 skt_collection_.reset();
61std::vector<sk_sp<SkFontMgr>> FontCollection::GetFontManagerOrder()
const {
62 std::vector<sk_sp<SkFontMgr>> order;
63 if (dynamic_font_manager_) {
64 order.push_back(dynamic_font_manager_);
66 if (asset_font_manager_) {
67 order.push_back(asset_font_manager_);
69 if (test_font_manager_) {
70 order.push_back(test_font_manager_);
72 if (default_font_manager_) {
73 order.push_back(default_font_manager_);
78void FontCollection::DisableFontFallback() {
79 enable_font_fallback_ =
false;
80 if (skt_collection_) {
81 skt_collection_->disableFontFallback();
85void FontCollection::ClearFontFamilyCache() {
86 if (skt_collection_) {
87 skt_collection_->clearCaches();
91sk_sp<skia::textlayout::FontCollection>
92FontCollection::CreateSktFontCollection() {
93 if (!skt_collection_) {
94 skt_collection_ = sk_make_sp<skia::textlayout::FontCollection>();
96 std::vector<SkString> default_font_families;
98 default_font_families.emplace_back(family);
100 skt_collection_->setDefaultFontManager(default_font_manager_,
101 default_font_families);
102 skt_collection_->setAssetFontManager(asset_font_manager_);
103 skt_collection_->setDynamicFontManager(dynamic_font_manager_);
104 skt_collection_->setTestFontManager(test_font_manager_);
105 if (!enable_font_fallback_) {
106 skt_collection_->disableFontFallback();
110 return skt_collection_;
std::vector< std::string > GetDefaultFontFamilies()
sk_sp< SkFontMgr > GetDefaultFontManager(uint32_t font_initialization_data)