diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9bd671452..d576f03f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,7 +46,7 @@ jobs: sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" sudo apt-get -y install ninja-build clang lld libcurl4-openssl-dev intel-oneapi-ipp-devel \ zlib1g-dev libglu1-mesa-dev libdbus-1-dev libvulkan-dev libxi-dev libxrandr-dev libasound2-dev \ - libpulse-dev libudev-dev libpng-dev libncurses5-dev libx11-xcb-dev qt5-default + libpulse-dev libudev-dev libpng-dev libncurses5-dev libx11-xcb-dev qt5-default libfreetype-dev yarn global add @sentry/cli echo "$(yarn global bin)" >> $GITHUB_PATH @@ -103,7 +103,7 @@ jobs: run: | brew update brew upgrade --formula - brew install ninja graphicsmagick imagemagick + brew install ninja graphicsmagick imagemagick freetype yarn global add create-dmg # universal qt5 from macports diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f1d2d5a15..963b827af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,7 +46,7 @@ jobs: sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" sudo apt-get -y install ninja-build clang lld libcurl4-openssl-dev intel-oneapi-ipp-devel \ zlib1g-dev libglu1-mesa-dev libdbus-1-dev libvulkan-dev libxi-dev libxrandr-dev libasound2-dev \ - libpulse-dev libudev-dev libpng-dev libncurses5-dev libx11-xcb-dev qt5-default + libpulse-dev libudev-dev libpng-dev libncurses5-dev libx11-xcb-dev qt5-default libfreetype-dev yarn global add @sentry/cli echo "$(yarn global bin)" >> $GITHUB_PATH @@ -121,7 +121,7 @@ jobs: run: | brew update brew upgrade --formula - brew install ninja graphicsmagick imagemagick getsentry/tools/sentry-cli + brew install ninja graphicsmagick imagemagick getsentry/tools/sentry-cli freetype yarn global add create-dmg # universal qt5 from macports diff --git a/README.md b/README.md index c1f0dec70..91c2930bd 100644 --- a/README.md +++ b/README.md @@ -75,11 +75,11 @@ NFS files dumped from Metroid Prime Trilogy on Wii U VC can be used directly wit build-essential curl git ninja-build clang lld zlib1g-dev libcurl4-openssl-dev \ libglu1-mesa-dev libdbus-1-dev libvulkan-dev libxi-dev libxrandr-dev libasound2-dev libpulse-dev \ libudev-dev libpng-dev libncurses5-dev cmake libx11-xcb-dev python3 python-is-python3 \ - qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libclang-dev + qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libclang-dev libfreetype-dev ``` * Arch Linux packages ``` - base-devel cmake ninja llvm vulkan-headers python3 qt6 clang lld alsa-lib libpulse libxrandr + base-devel cmake ninja llvm vulkan-headers python3 qt6 clang lld alsa-lib libpulse libxrandr freetype2 ``` * Fedora packages ``` @@ -168,4 +168,4 @@ We currently do not have a good fix for this issue, however a workaround is to p and executing from there e.g: `D:\HECLProjects\` Another work around is to install a version of python that matches the one blender ships with and renaming the python directory in the blender directory to `python.bak`. -This will force blender to use the system's python if it's available and will not have the same path limitation \ No newline at end of file +This will force blender to use the system's python if it's available and will not have the same path limitation diff --git a/Runtime/ImGuiConsole.cpp b/Runtime/ImGuiConsole.cpp index c55a95a37..c3b75fc21 100644 --- a/Runtime/ImGuiConsole.cpp +++ b/Runtime/ImGuiConsole.cpp @@ -32,7 +32,7 @@ void ImGuiStringViewText(std::string_view text) { void ImGuiTextCenter(std::string_view text) { ImGui::NewLine(); - float fontSize = ImGui::GetFontSize() * float(text.size()) / 2; + float fontSize = ImGui::CalcTextSize(text.data(), text.data() + text.size()).x; ImGui::SameLine(ImGui::GetWindowSize().x / 2 - fontSize + fontSize / 2); ImGuiStringViewText(text); } diff --git a/imgui/CMakeLists.txt b/imgui/CMakeLists.txt index 3221e9319..eea75d5c2 100644 --- a/imgui/CMakeLists.txt +++ b/imgui/CMakeLists.txt @@ -19,6 +19,14 @@ if (CMAKE_COMPILER_IS_GNUCXX) endif() target_link_libraries(imgui PRIVATE boo hecl-light RetroDataSpec aurora) +# Optional, replaces stb_freetype if available +find_package(Freetype) +if (FREETYPE_FOUND) + target_sources(imgui PRIVATE ../extern/imgui/misc/freetype/imgui_freetype.cpp) + target_compile_definitions(imgui PUBLIC IMGUI_ENABLE_FREETYPE) + target_link_libraries(imgui PRIVATE Freetype::Freetype) +endif () + bintoc_compress(NotoMono.cpp NotoMono-Regular.ttf NOTO_MONO_FONT) bintoc(MetaforceIcon.cpp ../Runtime/platforms/freedesktop/256x256/apps/metaforce.png METAFORCE_ICON) diff --git a/imgui/ImGuiEngine.cpp b/imgui/ImGuiEngine.cpp index c89cd1571..d11ca7027 100644 --- a/imgui/ImGuiEngine.cpp +++ b/imgui/ImGuiEngine.cpp @@ -10,6 +10,10 @@ #define STBI_ONLY_PNG #include "stb_image.h" +#ifdef IMGUI_ENABLE_FREETYPE +#include "misc/freetype/imgui_freetype.h" +#endif + extern "C" const uint8_t NOTO_MONO_FONT[]; extern "C" const size_t NOTO_MONO_FONT_SZ; extern "C" const size_t NOTO_MONO_FONT_DECOMPRESSED_SZ; @@ -33,13 +37,22 @@ void ImGuiEngine_Initialize(float scale) { fontConfig.FontData = fontData; fontConfig.FontDataSize = int(NOTO_MONO_FONT_DECOMPRESSED_SZ); fontConfig.SizePixels = std::floor(14.f * scale); +#ifdef IMGUI_ENABLE_FREETYPE + fontConfig.FontBuilderFlags = ImGuiFreeTypeBuilderFlags_LightHinting; +#endif snprintf(static_cast(fontConfig.Name), sizeof(fontConfig.Name), "Noto Mono Regular, %dpx", static_cast(fontConfig.SizePixels)); ImGuiEngine::fontNormal = io.Fonts->AddFont(&fontConfig); fontConfig.FontDataOwnedByAtlas = false; // first one took ownership fontConfig.SizePixels = std::floor(24.f * scale); +#ifdef IMGUI_ENABLE_FREETYPE + fontConfig.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Bold; + snprintf(static_cast(fontConfig.Name), sizeof(fontConfig.Name), "Noto Mono Bold, %dpx", + static_cast(fontConfig.SizePixels)); +#else snprintf(static_cast(fontConfig.Name), sizeof(fontConfig.Name), "Noto Mono Regular, %dpx", static_cast(fontConfig.SizePixels)); +#endif ImGuiEngine::fontLarge = io.Fonts->AddFont(&fontConfig); ImGui::GetStyle().ScaleAllSizes(scale); diff --git a/imgui/ImGuiEngine.hpp b/imgui/ImGuiEngine.hpp index 05301398c..eea82f242 100644 --- a/imgui/ImGuiEngine.hpp +++ b/imgui/ImGuiEngine.hpp @@ -8,6 +8,8 @@ //#include namespace metaforce { +constexpr inline int TranslateBooSpecialKey(boo::ESpecialKey key) { return 256 + static_cast(key); } + class ImGuiEngine { public: static ImFont* fontNormal;