Cleanup font generators
This commit is contained in:
@@ -18,15 +18,9 @@ namespace OpenVulkano::Scene
|
||||
SdfFontAtlasGeneratorConfig SdfFontAtlasGeneratorConfig::msdfDefaultConfig = { 32, 1.0, 3 };
|
||||
|
||||
template<int Channels>
|
||||
void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset,
|
||||
const std::optional<std::string>& pngOutput)
|
||||
void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& inCs)
|
||||
{
|
||||
msdfgen::FreetypeHandle* ft;
|
||||
msdfgen::FontHandle* font;
|
||||
InitFreetypeFromFile(ft, font, fontFile);
|
||||
msdf_atlas::Charset s;
|
||||
std::for_each(charset.begin(), charset.end(), [&](uint32_t unicode) { s.add(unicode); });
|
||||
Generate(ft, font, s, pngOutput);
|
||||
GenerateAtlas(Utils::ReadFile(fontFile), inCs);
|
||||
}
|
||||
|
||||
template<int Channels> SdfFontAtlasGeneratorGeneric<Channels>::SdfFontAtlasGeneratorGeneric() : FontAtlasGeneratorBase(Channels)
|
||||
@@ -36,8 +30,7 @@ namespace OpenVulkano::Scene
|
||||
}
|
||||
|
||||
template<int Channels>
|
||||
void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& inCs,
|
||||
const std::optional<std::string>& pngOutput)
|
||||
void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& inCs)
|
||||
{
|
||||
msdfgen::FreetypeHandle* ft;
|
||||
msdfgen::FontHandle* font;
|
||||
@@ -50,30 +43,26 @@ namespace OpenVulkano::Scene
|
||||
}
|
||||
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);
|
||||
Generate(ft, font, s);
|
||||
}
|
||||
|
||||
template<int Channels>
|
||||
void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const std::string& fontFile,
|
||||
const msdf_atlas::Charset& charset,
|
||||
const std::optional<std::string>& pngOutput)
|
||||
void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const std::string& fontFile, const msdf_atlas::Charset& charset)
|
||||
{
|
||||
// TODO: dynamic atlas and add only those symbols which are not present yet in current atlas
|
||||
msdfgen::FreetypeHandle* ft;
|
||||
msdfgen::FontHandle* font;
|
||||
InitFreetypeFromFile(ft, font, fontFile);
|
||||
Generate(ft, font, charset, pngOutput);
|
||||
Generate(ft, font, charset);
|
||||
}
|
||||
|
||||
template<int Channels>
|
||||
void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const msdfgen::byte* fontData, int length,
|
||||
const msdf_atlas::Charset& charset,
|
||||
const std::optional<std::string>& pngOutput)
|
||||
void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const msdfgen::byte* fontData, int length, const msdf_atlas::Charset& charset)
|
||||
{
|
||||
msdfgen::FreetypeHandle* ft;
|
||||
msdfgen::FontHandle* font;
|
||||
InitFreetypeFromBuffer(ft, font, fontData, length);
|
||||
Generate(ft, font, charset, pngOutput);
|
||||
Generate(ft, font, charset);
|
||||
}
|
||||
|
||||
template<int Channels>
|
||||
@@ -115,9 +104,7 @@ namespace OpenVulkano::Scene
|
||||
}
|
||||
|
||||
template<int Channels>
|
||||
void SdfFontAtlasGeneratorGeneric<Channels>::Generate(msdfgen::FreetypeHandle* ft, msdfgen::FontHandle* font,
|
||||
const msdf_atlas::Charset& chset,
|
||||
const std::optional<std::string>& pngOutput)
|
||||
void SdfFontAtlasGeneratorGeneric<Channels>::Generate(msdfgen::FreetypeHandle* ft, msdfgen::FontHandle* font, const msdf_atlas::Charset& chset)
|
||||
{
|
||||
std::vector<msdf_atlas::GlyphGeometry> glyphsGeometry;
|
||||
// FontGeometry is a helper class that loads a set of glyphs from a single font.
|
||||
@@ -212,10 +199,6 @@ namespace OpenVulkano::Scene
|
||||
SetGlyphData(info, { bearingX, bearingY }, { w, h }, glyphAtlasAABB, glyphBox.advance);
|
||||
}
|
||||
|
||||
if (pngOutput && !pngOutput->empty())
|
||||
{
|
||||
m_atlasData->Save(*pngOutput);
|
||||
}
|
||||
destroyFont(font);
|
||||
deinitializeFreetype(ft);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user