diff --git a/src/Menu.cpp b/src/Menu.cpp index e53f1fcb59..6c322d28ab 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -169,6 +169,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( AutoHideFeatureList, SkipConstraintWarning, RequireShiftToDock, + UseResolutionFont, Theme, SelectedThemePreset) diff --git a/src/Menu.h b/src/Menu.h index 37f4c3d5e0..3aedbd2bbc 100644 --- a/src/Menu.h +++ b/src/Menu.h @@ -411,11 +411,13 @@ class Menu bool AutoHideFeatureList = false; // Auto-hide left feature list panel, show on hover bool SkipConstraintWarning = false; // Skip popup when a setting change creates new constraints bool RequireShiftToDock = true; // Require holding Shift to dock windows + bool UseResolutionFont = true; // When true, runtime font size scales with screen resolution; when persisted to theme files, FontSize is zeroed for backward compatibility ThemeSettings Theme; std::string SelectedThemePreset = ""; // Currently selected theme preset (empty = custom/user theme) }; - const ThemeSettings& GetTheme() const { return settings.Theme; } // Provide read-only access to the Theme. - Settings& GetSettings() { return settings; } // Provide access to settings for other components + const ThemeSettings& GetTheme() const { return settings.Theme; } // Provide read-only access to the Theme. + Settings& GetSettings() { return settings; } // Provide access to settings for other components + const Settings& GetSettings() const { return settings; } winrt::com_ptr GetDXGIAdapter3() const { return dxgiAdapter3; } // Provide access to dxgiAdapter3 ThemeSettings::FontRoleSettings& GetFontRoleSettings(FontRole role) { return settings.Theme.FontRoles[static_cast(role)]; } const ThemeSettings::FontRoleSettings& GetFontRoleSettings(FontRole role) const { return settings.Theme.FontRoles[static_cast(role)]; } diff --git a/src/Menu/SettingsTabRenderer.cpp b/src/Menu/SettingsTabRenderer.cpp index a52993e4b8..a63b6e2417 100644 --- a/src/Menu/SettingsTabRenderer.cpp +++ b/src/Menu/SettingsTabRenderer.cpp @@ -856,11 +856,10 @@ void SettingsTabRenderer::RenderFontsTab() SeparatorTextWithFont("Font", Menu::FontRole::Subheading); - bool useAutoFont = (themeSettings.FontSize <= 0.0f); + bool& useAutoFont = menuInstance->GetSettings().UseResolutionFont; if (ImGui::Checkbox("Use resolution-based font size", &useAutoFont)) { - if (useAutoFont) { - themeSettings.FontSize = 0.0f; - } else { + if (!useAutoFont) { + // Seed the fixed-size slider with the current effective size so it doesn't jump float effective = ThemeManager::ResolveFontSize(*menuInstance); themeSettings.FontSize = std::clamp(effective, ThemeManager::Constants::MIN_FONT_SIZE, ThemeManager::Constants::MAX_FONT_SIZE); } diff --git a/src/Menu/ThemeManager.cpp b/src/Menu/ThemeManager.cpp index a1d8466013..31da7155e5 100644 --- a/src/Menu/ThemeManager.cpp +++ b/src/Menu/ThemeManager.cpp @@ -791,15 +791,16 @@ bool ThemeManager::ValidateThemeData(const json& themeData) const float ThemeManager::ResolveFontSize(const Menu& menu) { - const auto& themeSettings = menu.GetTheme(); - float configured = themeSettings.FontSize; + const auto& settings = menu.GetSettings(); - // If user configured a positive size, use it (clamped) - if (std::round(configured) > 0) { - return std::clamp(configured, Constants::MIN_FONT_SIZE, Constants::MAX_FONT_SIZE); + // When resolution-based font is disabled, use the theme's fixed size directly + if (!settings.UseResolutionFont) { + float configured = settings.Theme.FontSize; + if (std::round(configured) > 0) + return std::clamp(configured, Constants::MIN_FONT_SIZE, Constants::MAX_FONT_SIZE); } - // Otherwise, compute dynamic default based on current screen resolution + // Compute dynamic size from screen resolution float dynamicSize; if (globals::game::isVR) { // VR: use overlay height