reimplement system fonts retrieval for Linux using fontconfig

This commit is contained in:
ohyzha
2025-01-18 16:56:00 +02:00
parent 5a5bac8479
commit 7670100d81
3 changed files with 142 additions and 8 deletions

View File

@@ -5,9 +5,8 @@
*/
#include <catch2/catch_all.hpp>
#include "Host/SystemFontResolver.hpp"
#include "Base/Logger.hpp"
#include "Host/SystemInfo.hpp"
#include "Scene/Text/FontAtlasFactory.hpp"
#include <filesystem>
using namespace OpenVulkano;
@@ -17,12 +16,12 @@ TEST_CASE("Search system fonts")
Logger::SetupLogger("", "tests.log");
// assume these fonts are present since they are default
std::filesystem::path path = SystemInfo::GetSystemFontPath("Ubuntu-R");
std::string path = SystemFontResolver::GetSystemFontPath("Ubuntu Regular");
REQUIRE(path == "/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf");
path = SystemInfo::GetSystemFontPath("UbuntuMono-BI");
REQUIRE(!path.empty());
path = SystemFontResolver::GetSystemFontPath("Ubuntu Mono Bold Italic");
REQUIRE(path == "/usr/share/fonts/truetype/ubuntu/UbuntuMono-BI.ttf");
path = SystemInfo::GetSystemFontPath("NON-EXISTING Font");
path = SystemFontResolver::GetSystemFontPath("NON-EXISTING Font");
REQUIRE(path.empty());
}