70 {
71#if FML_OS_MACOSX || FML_OS_IOS
73#endif
74 std::unique_ptr<fml::Mapping> manifest_mapping =
75 asset_manager->GetAsMapping("FontManifest.json");
76 if (manifest_mapping == nullptr) {
77 FML_DLOG(WARNING) <<
"Could not find the font manifest in the asset store.";
78 return;
79 }
80
81 rapidjson::Document document;
82 static_assert(sizeof(decltype(document)::Ch) == sizeof(uint8_t), "");
83 document.Parse(reinterpret_cast<const decltype(document)::Ch*>(
84 manifest_mapping->GetMapping()),
85 manifest_mapping->GetSize());
86
87 if (document.HasParseError()) {
88 FML_DLOG(WARNING) <<
"Error parsing the font manifest in the asset store.";
89 return;
90 }
91
92 if (!document.IsArray()) {
93 return;
94 }
95
96 auto font_provider =
97 std::make_unique<AssetManagerFontProvider>(asset_manager);
98
99 for (const auto& family : document.GetArray()) {
100 auto family_name = family.FindMember("family");
101 if (family_name == family.MemberEnd() || !family_name->value.IsString()) {
102 continue;
103 }
104
105 auto family_fonts = family.FindMember("fonts");
106 if (family_fonts == family.MemberEnd() || !family_fonts->value.IsArray()) {
107 continue;
108 }
109
110 for (const auto& family_font : family_fonts->value.GetArray()) {
111 if (!family_font.IsObject()) {
112 continue;
113 }
114
115 auto font_asset = family_font.FindMember("asset");
116 if (font_asset == family_font.MemberEnd() ||
117 !font_asset->value.IsString()) {
118 continue;
119 }
120
121
122 font_provider->RegisterAsset(family_name->value.GetString(),
123 font_asset->value.GetString());
124 }
125 }
126
127 collection_->SetAssetFontManager(
128 sk_make_sp<txt::AssetFontManager>(std::move(font_provider)));
129}
#define FML_DLOG(severity)
void RegisterSystemFonts(const DynamicFontManager &dynamic_font_manager)