From b18e983499e55637e1e5afaf62ad2583b313d928 Mon Sep 17 00:00:00 2001 From: "C. J. Howard" Date: Fri, 22 Mar 2019 06:00:20 +0800 Subject: [PATCH] Fix DPI scaling on Windows --- CMakeLists.txt | 5 +++++ src/game.cpp | 5 ++++- src/game.hpp | 4 +--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5452e1..b28aaa2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,11 @@ configure_file(${PROJECT_SOURCE_DIR}/src/configuration.hpp.in file(GLOB_RECURSE SOURCE_FILES ${PROJECT_SOURCE_DIR}/src/*.cpp) +# Make DPI-aware on Windows +if(MSVC) + list(APPEND SOURCE_FILES "${PROJECT_SOURCE_DIR}/src/dpi-aware.manifest") +endif() + # Add executable target set(EXECUTABLE_TARGET ${PROJECT_NAME}-executable) add_executable(${EXECUTABLE_TARGET} ${SOURCE_FILES}) diff --git a/src/game.cpp b/src/game.cpp index 55dac6f..6d815eb 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1094,7 +1094,10 @@ void Game::setupUI() // Get DPI and convert font size to pixels const Display* display = deviceManager->getDisplays()->front(); dpi = display->getDPI(); - fontSizePX = fontSizePT * (1.0f / 72.0f) * dpi; + fontSizePX = fontSizePT * (1.0f / 96.0f) * dpi; + + logger->log("Detected display DPI as " + std::to_string(dpi) + "."); + logger->log("Fonts size = " + std::to_string(fontSizePT) + " PT = " + std::to_string(fontSizePX) + " PX."); // Load fonts loadFonts(); diff --git a/src/game.hpp b/src/game.hpp index 250a491..9d172f8 100644 --- a/src/game.hpp +++ b/src/game.hpp @@ -162,9 +162,7 @@ private: virtual void handleEvent(const GamepadDisconnectedEvent& event); virtual void handleEvent(const ScheduledFunctionEvent& event); - #if defined(DEBUG) - void setupDebugging(); - #endif + void setupDebugging(); void setupLocalization(); void setupWindow(); void setupGraphics();