implement system fonts search for Linux
This commit is contained in:
@@ -15,6 +15,17 @@ if (APPLE)
|
||||
list(FILTER SOURCES EXCLUDE REGEX "ExeAppendedZipResourceLoader")
|
||||
endif()
|
||||
|
||||
if (LINUX)
|
||||
find_program(LSB_RELEASE_EXEC lsb_release)
|
||||
execute_process(COMMAND ${LSB_RELEASE_EXEC} -is
|
||||
OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if (NOT ${LSB_RELEASE_ID_SHORT} STREQUAL "Ubuntu")
|
||||
list(FILTER SOURCES EXCLUDE REGEX "*Ubuntu*")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SOURCES})
|
||||
file(GLOB_RECURSE RESOURCES "${ROOT_FOLDER}/resources/*.rc" "${ROOT_FOLDER}/resources/*.h")
|
||||
list(APPEND SOURCES ${RESOURCES})
|
||||
|
||||
28
tests/Host/Linux/SystemFontsSearchTestsUbuntu.cpp
Normal file
28
tests/Host/Linux/SystemFontsSearchTestsUbuntu.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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 "Base/Logger.hpp"
|
||||
#include "Host/SystemInfo.hpp"
|
||||
#include "Scene/Text/FontAtlasFactory.hpp"
|
||||
#include <filesystem>
|
||||
|
||||
using namespace OpenVulkano;
|
||||
|
||||
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");
|
||||
REQUIRE(path == "/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf");
|
||||
|
||||
path = SystemInfo::GetSystemFontPath("UbuntuMono-BI");
|
||||
REQUIRE(!path.empty());
|
||||
|
||||
path = SystemInfo::GetSystemFontPath("NON-EXISTING Font");
|
||||
REQUIRE(path.empty());
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <filesystem>
|
||||
|
||||
#include "Scene/Text/FontAtlasFactory.hpp"
|
||||
#include "Host/ResourceLoader.hpp"
|
||||
|
||||
using namespace OpenVulkano;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user