From c3a85cd75f8261b63dac9d5557783fddec07e18d Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Wed, 5 Mar 2025 18:56:20 +0000 Subject: [PATCH 1/4] Make ENABLE_IM_FONT_ATLAS_SNAPSHOT CMake option Signed-off-by: Isaac Marovitz --- UnleashedRecomp/CMakeLists.txt | 16 +++++++++++++++- UnleashedRecomp/gpu/imgui/imgui_font_builder.cpp | 4 ++++ UnleashedRecomp/gpu/imgui/imgui_snapshot.h | 5 ----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index ce05eb1..0829543 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -8,6 +8,11 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux") option(UNLEASHED_RECOMP_FLATPAK "Configure the build for Flatpak compatibility." OFF) endif() +# Undefine this to generate a font atlas file in working directory. +# You also need to do this if you are testing localization, as only +# characters in the locale get added to the atlas. +option(ENABLE_IM_FONT_ATLAS_SNAPSHOT "Use font atlas snapshot instead of generating one." ON) + function(BIN2C) cmake_parse_arguments(BIN2C_ARGS "" "TARGET_OBJ;SOURCE_FILE;DEST_FILE;ARRAY_NAME;COMPRESSION_TYPE" "" ${ARGN}) @@ -317,6 +322,10 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux") target_compile_definitions(UnleashedRecomp PRIVATE SDL_VULKAN_ENABLED) endif() +if (ENABLE_IM_FONT_ATLAS_SNAPSHOT) + target_compile_definitions(UnleashedRecomp PRIVATE -DENABLE_IM_FONT_ATLAS_SNAPSHOT) +else() + find_package(directx-dxc REQUIRED) find_package(CURL REQUIRED) @@ -357,7 +366,6 @@ endif() target_link_libraries(UnleashedRecomp PRIVATE fmt::fmt libzstd_static - msdf-atlas-gen::msdf-atlas-gen nfd::nfd o1heap XenonUtils @@ -369,6 +377,12 @@ target_link_libraries(UnleashedRecomp PRIVATE CURL::libcurl ) +if (NOT ENABLE_IM_FONT_ATLAS_SNAPSHOT) + target_link_libraries(UnleashedRecomp PRIVATE + msdf-atlas-gen::msdf-atlas-gen + ) +endif() + target_include_directories(UnleashedRecomp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/api" diff --git a/UnleashedRecomp/gpu/imgui/imgui_font_builder.cpp b/UnleashedRecomp/gpu/imgui/imgui_font_builder.cpp index 1ac5131..8fce4c7 100644 --- a/UnleashedRecomp/gpu/imgui/imgui_font_builder.cpp +++ b/UnleashedRecomp/gpu/imgui/imgui_font_builder.cpp @@ -1,5 +1,7 @@ #include "imgui_font_builder.h" +#ifndef ENABLE_IM_FONT_ATLAS_SNAPSHOT + #include // Taken directly from msdf-atlas-gen, modified to support custom rectangles. @@ -321,3 +323,5 @@ static bool FontBuilder_Build(ImFontAtlas* atlas) } ImFontBuilderIO g_fontBuilderIO = { FontBuilder_Build }; + +#endif \ No newline at end of file diff --git a/UnleashedRecomp/gpu/imgui/imgui_snapshot.h b/UnleashedRecomp/gpu/imgui/imgui_snapshot.h index a777451..f40ad88 100644 --- a/UnleashedRecomp/gpu/imgui/imgui_snapshot.h +++ b/UnleashedRecomp/gpu/imgui/imgui_snapshot.h @@ -1,10 +1,5 @@ #pragma once -// Undefine this to generate a font atlas file in working directory. -// You also need to do this if you are testing localization, as only -// characters in the locale get added to the atlas. -#define ENABLE_IM_FONT_ATLAS_SNAPSHOT - struct ImFontAtlasSnapshot { std::vector data; From 7f051eb5f240f43810c5190b842eb214727aabca Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 6 Mar 2025 22:28:01 +0000 Subject: [PATCH 2/4] Address review Signed-off-by: Isaac Marovitz --- UnleashedRecomp/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index 0829543..b837711 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -11,7 +11,7 @@ endif() # Undefine this to generate a font atlas file in working directory. # You also need to do this if you are testing localization, as only # characters in the locale get added to the atlas. -option(ENABLE_IM_FONT_ATLAS_SNAPSHOT "Use font atlas snapshot instead of generating one." ON) +option(UNLEASHED_RECOMP_ENABLE_IM_FONT_ATLAS_SNAPSHOT "Use font atlas snapshot instead of generating one." ON) function(BIN2C) cmake_parse_arguments(BIN2C_ARGS "" "TARGET_OBJ;SOURCE_FILE;DEST_FILE;ARRAY_NAME;COMPRESSION_TYPE" "" ${ARGN}) @@ -322,7 +322,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux") target_compile_definitions(UnleashedRecomp PRIVATE SDL_VULKAN_ENABLED) endif() -if (ENABLE_IM_FONT_ATLAS_SNAPSHOT) +if (UNLEASHED_RECOMP_ENABLE_IM_FONT_ATLAS_SNAPSHOT) target_compile_definitions(UnleashedRecomp PRIVATE -DENABLE_IM_FONT_ATLAS_SNAPSHOT) else() From cae03f17aea3f0daf1ab96a5913cefac952d5840 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Fri, 7 Mar 2025 10:11:24 +0000 Subject: [PATCH 3/4] Review Signed-off-by: Isaac Marovitz --- UnleashedRecomp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index b837711..ccb3300 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -377,7 +377,7 @@ target_link_libraries(UnleashedRecomp PRIVATE CURL::libcurl ) -if (NOT ENABLE_IM_FONT_ATLAS_SNAPSHOT) +if (NOT UNLEASHED_RECOMP_ENABLE_IM_FONT_ATLAS_SNAPSHOT) target_link_libraries(UnleashedRecomp PRIVATE msdf-atlas-gen::msdf-atlas-gen ) From 9f4f3f96a43dfdba45fe2e7c59e31a4ce2bd121c Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Wed, 12 Mar 2025 10:39:46 -0400 Subject: [PATCH 4/4] Correct typo Signed-off-by: Isaac Marovitz --- UnleashedRecomp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index ccb3300..6a663e3 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -324,7 +324,7 @@ endif() if (UNLEASHED_RECOMP_ENABLE_IM_FONT_ATLAS_SNAPSHOT) target_compile_definitions(UnleashedRecomp PRIVATE -DENABLE_IM_FONT_ATLAS_SNAPSHOT) -else() +endif() find_package(directx-dxc REQUIRED) find_package(CURL REQUIRED)