| 315 | } |
| 316 | |
| 317 | void TextPainter::reloadFonts() { |
| 318 | m_fontTextureGroup.clearFonts(); |
| 319 | m_fontTextureGroup.cleanup(0); |
| 320 | auto assets = Root::singleton().assets(); |
| 321 | auto loadFontsByExtension = [&](String const& ext) { |
| 322 | for (auto& fontPath : assets->scanExtension(ext)) { |
| 323 | auto font = assets->font(fontPath); |
| 324 | auto name = AssetPath::filename(fontPath); |
| 325 | name = name.substr(0, name.findLast(".")); |
| 326 | addFont(loadFont(fontPath, name), name); |
| 327 | } |
| 328 | }; |
| 329 | loadFontsByExtension("ttf"); |
| 330 | loadFontsByExtension("woff2"); |
| 331 | m_fontTextureGroup.setFixedFonts( |
| 332 | assets->json("/interface.config:font.defaultFont").toString(), |
| 333 | assets->json("/interface.config:font.fallbackFont").toString(), |
| 334 | assets->json("/interface.config:font.emojiFont").toString()); |
| 335 | } |
| 336 | |
| 337 | void TextPainter::cleanup(int64_t timeout) { |
| 338 | m_fontTextureGroup.cleanup(timeout); |
nothing calls this directly
no test coverage detected