Update to FontAtlasFactory for more eficent loading

This commit is contained in:
Georg Hagen
2025-03-02 18:35:36 +01:00
parent ba2570d444
commit ee82919293
5 changed files with 69 additions and 56 deletions

View File

@@ -36,13 +36,19 @@ namespace OpenVulkano::Scene
}
template<int Channels>
void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset,
void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& inCs,
const std::optional<std::string>& pngOutput)
{
msdfgen::FreetypeHandle* ft;
msdfgen::FontHandle* font;
InitFreetypeFromBuffer(ft, font, (const msdfgen::byte*)(fontData.Data()), fontData.Size());
msdf_atlas::Charset s;
std::set<uint32_t> fallback;
if (inCs.empty())
{
FontAtlasGeneratorBase::LoadAllGlyphs(fallback, fontData.AsBytes());
}
const auto& charset = inCs.empty() ? fallback : inCs;
std::for_each(charset.begin(), charset.end(), [&](uint32_t unicode) { s.add(unicode); });
Generate(ft, font, s, pngOutput);
}