48 lines
1.4 KiB
C++
48 lines
1.4 KiB
C++
/*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include <catch2/catch_all.hpp>
|
|
#include "Host/SystemFontResolver.hpp"
|
|
#include "Host/SystemInfo.hpp"
|
|
#include "Base/Logger.hpp"
|
|
#include <filesystem>
|
|
|
|
using namespace OpenVulkano;
|
|
|
|
TEST_CASE("Search system fonts")
|
|
{
|
|
Logger::SetupLogger("", "tests.log");
|
|
|
|
OsVersion version = SystemInfo::GetOsVersion();
|
|
std::array<std::string, 2> fontFiles = { "/usr/share/fonts/truetype/ubuntu/", "/usr/share/fonts/truetype/ubuntu/" };
|
|
if (version.major <= 22)
|
|
{
|
|
fontFiles[0] += "Ubuntu-R.ttf";
|
|
fontFiles[1] += "UbuntuMono-BI.ttf";
|
|
}
|
|
else
|
|
{
|
|
fontFiles[0] += "Ubuntu[wdth,wght].ttf";
|
|
fontFiles[1] += "UbuntuMono-Italic[wght].ttf";
|
|
}
|
|
|
|
// assume these fonts are present since they are default
|
|
std::string path = SystemFontResolver::GetSystemFontPath("Ubuntu Regular");
|
|
REQUIRE(path == fontFiles[0]);
|
|
|
|
path = SystemFontResolver::GetSystemFontPath("ubuntu regular");
|
|
REQUIRE(path == fontFiles[0]);
|
|
|
|
path = SystemFontResolver::GetSystemFontPath("Ubuntu Mono Bold Italic");
|
|
REQUIRE(path == fontFiles[1]);
|
|
|
|
path = SystemFontResolver::GetSystemFontPath("ubuntu mono bold italic");
|
|
REQUIRE(path == fontFiles[1]);
|
|
|
|
path = SystemFontResolver::GetSystemFontPath("NON-EXISTING Font");
|
|
REQUIRE(path.empty());
|
|
}
|