Add FontResolver
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include "FontAtlasFactory.hpp"
|
||||
#include "SdfFontAtlasGenerator.hpp"
|
||||
#include "BitmapFontAtlasGenerator.hpp"
|
||||
#include "Host/SystemFontResolver.hpp"
|
||||
#include "Host/FontResolver.hpp"
|
||||
#include "Base/Logger.hpp"
|
||||
#include "Host/ResourceLoader.hpp"
|
||||
#include <utility>
|
||||
@@ -45,7 +45,7 @@ namespace OpenVulkano::Scene
|
||||
return atlas;
|
||||
}
|
||||
|
||||
const auto& fontData = FindFont(fontIdentifier);
|
||||
const auto& fontData = FontResolver::GetFontData(fontIdentifier, m_allowSystemFonts);
|
||||
if (fontData.Empty())
|
||||
{
|
||||
Logger::DATA->warn("Could not find font {}", fontIdentifier);
|
||||
@@ -82,7 +82,7 @@ namespace OpenVulkano::Scene
|
||||
return it->second;
|
||||
}
|
||||
|
||||
const auto& fontData = FindFont(fontIdentifier);
|
||||
const auto& fontData = FontResolver::GetFontData(fontIdentifier, m_allowSystemFonts);
|
||||
if (fontData.Empty())
|
||||
{
|
||||
Logger::DATA->warn("Could not find font {}", fontIdentifier);
|
||||
@@ -95,22 +95,4 @@ namespace OpenVulkano::Scene
|
||||
if (charset.empty()) m_atlasesCache.emplace(id, bitmapGen.GetAtlas());
|
||||
return bitmapGen.GetAtlas();
|
||||
}
|
||||
|
||||
Array<char> FontAtlasFactory::FindFont(const std::string& fontIdentifier) const
|
||||
{
|
||||
Array<char> resource = ResourceLoader::GetInstance().GetResource(fontIdentifier);
|
||||
if (resource.Empty())
|
||||
{
|
||||
if (!std::filesystem::exists(fontIdentifier))
|
||||
{
|
||||
if (!m_allowSystemFonts)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
return Utils::ReadFile(SystemFontResolver::GetSystemFontPath(fontIdentifier), true);
|
||||
}
|
||||
return Utils::ReadFile(fontIdentifier);
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user