From 65dd64d9673e86b8ee7525fa4d60ef25c41b4797 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 13 Jul 2021 10:25:14 -0500 Subject: [PATCH 1/3] This does the whole thing --- src/cascadia/TerminalControl/ControlCore.cpp | 3 +++ src/cascadia/TerminalControl/IControlAppearance.idl | 1 + src/cascadia/TerminalSettingsEditor/Appearances.h | 1 + src/cascadia/TerminalSettingsEditor/Appearances.idl | 3 +++ .../TerminalSettingsEditor/Appearances.xaml | 10 ++++++++++ src/cascadia/TerminalSettingsEditor/Profiles.xaml | 1 + .../Resources/en-US/Resources.resw | 6 +++++- .../TerminalSettingsModel/AppearanceConfig.cpp | 4 ++++ .../TerminalSettingsModel/AppearanceConfig.h | 2 ++ .../TerminalSettingsModel/CascadiaSettings.cpp | 1 + .../TerminalSettingsModel/IAppearanceConfig.idl | 2 ++ .../TerminalSettingsModel/TerminalSettings.cpp | 2 ++ .../TerminalSettingsModel/TerminalSettings.h | 2 ++ src/renderer/dx/DxRenderer.cpp | 13 ++++++++++++- src/renderer/dx/DxRenderer.hpp | 3 +++ 15 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index 932042a8b1f..174e91aa6cb 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -198,6 +198,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation dxEngine->SetPixelShaderPath(_settings.PixelShaderPath()); dxEngine->SetForceFullRepaintRendering(_settings.ForceFullRepaintRendering()); dxEngine->SetSoftwareRendering(_settings.SoftwareRendering()); + dxEngine->SetIntenseIsBold(!_settings.DisableIntenseIsBold()); _updateAntiAliasingMode(dxEngine.get()); @@ -526,6 +527,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation _renderEngine->SetForceFullRepaintRendering(_settings.ForceFullRepaintRendering()); _renderEngine->SetSoftwareRendering(_settings.SoftwareRendering()); + _renderEngine->SetIntenseIsBold(!_settings.DisableIntenseIsBold()); + _updateAntiAliasingMode(_renderEngine.get()); // Refresh our font with the renderer diff --git a/src/cascadia/TerminalControl/IControlAppearance.idl b/src/cascadia/TerminalControl/IControlAppearance.idl index 88de9e4b609..cdec7d9fa83 100644 --- a/src/cascadia/TerminalControl/IControlAppearance.idl +++ b/src/cascadia/TerminalControl/IControlAppearance.idl @@ -12,6 +12,7 @@ namespace Microsoft.Terminal.Control Windows.UI.Xaml.HorizontalAlignment BackgroundImageHorizontalAlignment; Windows.UI.Xaml.VerticalAlignment BackgroundImageVerticalAlignment; + Boolean DisableIntenseIsBold; // Experimental settings Boolean RetroTerminalEffect; String PixelShaderPath; diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.h b/src/cascadia/TerminalSettingsEditor/Appearances.h index 8884b4b74fa..20578451307 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.h +++ b/src/cascadia/TerminalSettingsEditor/Appearances.h @@ -78,6 +78,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation OBSERVABLE_PROJECTED_SETTING(_appearance, BackgroundImageOpacity); OBSERVABLE_PROJECTED_SETTING(_appearance, BackgroundImageStretchMode); OBSERVABLE_PROJECTED_SETTING(_appearance, BackgroundImageAlignment); + OBSERVABLE_PROJECTED_SETTING(_appearance, DisableIntenseIsBold); private: Model::AppearanceConfig _appearance; diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.idl b/src/cascadia/TerminalSettingsEditor/Appearances.idl index dc337f9b091..92a6cfd808c 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.idl +++ b/src/cascadia/TerminalSettingsEditor/Appearances.idl @@ -39,6 +39,9 @@ namespace Microsoft.Terminal.Settings.Editor OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Double, BackgroundImageOpacity); OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.UI.Xaml.Media.Stretch, BackgroundImageStretchMode); OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Microsoft.Terminal.Settings.Model.ConvergedAlignment, BackgroundImageAlignment); + + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Boolean, DisableIntenseIsBold); + } [default_interface] runtimeclass Appearances : Windows.UI.Xaml.Controls.UserControl, Windows.UI.Xaml.Data.INotifyPropertyChanged diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.xaml b/src/cascadia/TerminalSettingsEditor/Appearances.xaml index e070acaca66..1183d4a875d 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.xaml +++ b/src/cascadia/TerminalSettingsEditor/Appearances.xaml @@ -44,6 +44,8 @@ + + @@ -157,6 +159,14 @@ SettingOverrideSource="{x:Bind Appearance.RetroTerminalEffectOverrideSource, Mode=OneWay}"> + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.xaml b/src/cascadia/TerminalSettingsEditor/Profiles.xaml index 7ae5fd6452a..e9d88841d8b 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles.xaml @@ -402,6 +402,7 @@ IsChecked="{x:Bind IsBellStyleFlagSet(4), BindBack=SetBellStyleTaskbar, Mode=TwoWay}" /> + diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index 5c4f305e4f1..a02038d54c4 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -926,6 +926,10 @@ Flash window An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the window is flashed. + + Render "intense" text as bold + Header for a control to toggle if text formatted as "intense" should be rendered with a bold font weight or not. + Add new Button label that creates a new color scheme. @@ -1158,4 +1162,4 @@ Add new Button label that creates a new action on the actions page. - \ No newline at end of file + diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp index a7343a51ba1..24b472bdfe6 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp @@ -25,6 +25,7 @@ static constexpr std::string_view BackgroundImageStretchModeKey{ "backgroundImag static constexpr std::string_view BackgroundImageAlignmentKey{ "backgroundImageAlignment" }; static constexpr std::string_view RetroTerminalEffectKey{ "experimental.retroTerminalEffect" }; static constexpr std::string_view PixelShaderPathKey{ "experimental.pixelShaderPath" }; +static constexpr std::string_view DisableIntenseIsBoldKey{ "disableIntenseIsBold" }; winrt::Microsoft::Terminal::Settings::Model::implementation::AppearanceConfig::AppearanceConfig(const winrt::weak_ref sourceProfile) : _sourceProfile(sourceProfile) @@ -48,6 +49,7 @@ winrt::com_ptr AppearanceConfig::CopyAppearance(const winrt::c appearance->_BackgroundImageAlignment = sourceAppearance->_BackgroundImageAlignment; appearance->_RetroTerminalEffect = sourceAppearance->_RetroTerminalEffect; appearance->_PixelShaderPath = sourceAppearance->_PixelShaderPath; + appearance->_DisableIntenseIsBold = sourceAppearance->_DisableIntenseIsBold; return appearance; } @@ -68,6 +70,7 @@ Json::Value AppearanceConfig::ToJson() const JsonUtils::SetValueForKey(json, BackgroundImageAlignmentKey, _BackgroundImageAlignment); JsonUtils::SetValueForKey(json, RetroTerminalEffectKey, _RetroTerminalEffect); JsonUtils::SetValueForKey(json, PixelShaderPathKey, _PixelShaderPath); + JsonUtils::SetValueForKey(json, DisableIntenseIsBoldKey, _DisableIntenseIsBold); return json; } @@ -98,6 +101,7 @@ void AppearanceConfig::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, BackgroundImageAlignmentKey, _BackgroundImageAlignment); JsonUtils::GetValueForKey(json, RetroTerminalEffectKey, _RetroTerminalEffect); JsonUtils::GetValueForKey(json, PixelShaderPathKey, _PixelShaderPath); + JsonUtils::GetValueForKey(json, DisableIntenseIsBoldKey, _DisableIntenseIsBold); } winrt::Microsoft::Terminal::Settings::Model::Profile AppearanceConfig::SourceProfile() diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h index cdcdc9613ea..14a43fea760 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h @@ -53,6 +53,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::IAppearanceConfig, bool, RetroTerminalEffect, false); INHERITABLE_SETTING(Model::IAppearanceConfig, hstring, PixelShaderPath, L""); + INHERITABLE_SETTING(Model::IAppearanceConfig, bool, DisableIntenseIsBold, false); + private: winrt::weak_ref _sourceProfile; }; diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp index 0323d381757..076a03b8b08 100644 --- a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp @@ -340,6 +340,7 @@ winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::Duplicate DUPLICATE_APPEARANCE_SETTING_MACRO(SelectionBackground); DUPLICATE_APPEARANCE_SETTING_MACRO(CursorColor); DUPLICATE_APPEARANCE_SETTING_MACRO(PixelShaderPath); + DUPLICATE_APPEARANCE_SETTING_MACRO(DisableIntenseIsBold); DUPLICATE_APPEARANCE_SETTING_MACRO(BackgroundImagePath); DUPLICATE_APPEARANCE_SETTING_MACRO(BackgroundImageOpacity); DUPLICATE_APPEARANCE_SETTING_MACRO(BackgroundImageStretchMode); diff --git a/src/cascadia/TerminalSettingsModel/IAppearanceConfig.idl b/src/cascadia/TerminalSettingsModel/IAppearanceConfig.idl index 2b5cbbd5244..23ae6cc6de7 100644 --- a/src/cascadia/TerminalSettingsModel/IAppearanceConfig.idl +++ b/src/cascadia/TerminalSettingsModel/IAppearanceConfig.idl @@ -42,5 +42,7 @@ namespace Microsoft.Terminal.Settings.Model INHERITABLE_APPEARANCE_SETTING(Boolean, RetroTerminalEffect); INHERITABLE_APPEARANCE_SETTING(String, PixelShaderPath); + + INHERITABLE_APPEARANCE_SETTING(Boolean, DisableIntenseIsBold); }; } diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp index a0ec41a43ad..978c1f5df7a 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp @@ -202,6 +202,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation _RetroTerminalEffect = appearance.RetroTerminalEffect(); _PixelShaderPath = winrt::hstring{ wil::ExpandEnvironmentStringsW(appearance.PixelShaderPath().c_str()) }; + + _DisableIntenseIsBold = appearance.DisableIntenseIsBold(); } // Method Description: diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.h b/src/cascadia/TerminalSettingsModel/TerminalSettings.h index 5e87d415143..88df89fa1b9 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.h @@ -150,6 +150,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::TerminalSettings, hstring, PixelShaderPath); + INHERITABLE_SETTING(Model::TerminalSettings, bool, DisableIntenseIsBold, false); + private: std::optional> _ColorTable; gsl::span _getColorTableImpl(); diff --git a/src/renderer/dx/DxRenderer.cpp b/src/renderer/dx/DxRenderer.cpp index 03904814e2b..de35032429c 100644 --- a/src/renderer/dx/DxRenderer.cpp +++ b/src/renderer/dx/DxRenderer.cpp @@ -1035,6 +1035,17 @@ try } CATCH_LOG() +void DxEngine::SetIntenseIsBold(bool enable) noexcept +try +{ + if (_intenseIsBold != enable) + { + _intenseIsBold = enable; + LOG_IF_FAILED(InvalidateAll()); + } +} +CATCH_LOG() + HANDLE DxEngine::GetSwapChainHandle() { if (!_swapChainHandle) @@ -1961,7 +1972,7 @@ CATCH_RETURN() if (_drawingContext) { _drawingContext->forceGrayscaleAA = _ShouldForceGrayscaleAA(); - _drawingContext->useBoldFont = textAttributes.IsBold(); + _drawingContext->useBoldFont = _intenseIsBold && textAttributes.IsBold(); _drawingContext->useItalicFont = textAttributes.IsItalic(); } diff --git a/src/renderer/dx/DxRenderer.hpp b/src/renderer/dx/DxRenderer.hpp index cbd34ea3b78..28f95bb44c2 100644 --- a/src/renderer/dx/DxRenderer.hpp +++ b/src/renderer/dx/DxRenderer.hpp @@ -70,6 +70,8 @@ namespace Microsoft::Console::Render void SetSoftwareRendering(bool enable) noexcept; + void SetIntenseIsBold(bool enable) noexcept; + HANDLE GetSwapChainHandle(); // IRenderEngine Members @@ -252,6 +254,7 @@ namespace Microsoft::Console::Render // Preferences and overrides bool _softwareRendering; bool _forceFullRepaintRendering; + bool _intenseIsBold{ true }; D2D1_TEXT_ANTIALIAS_MODE _antialiasingMode; From 92ec348ac305b0b64c309aaf7bcf5775f5b1fca5 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 15 Jul 2021 09:58:00 -0500 Subject: [PATCH 2/3] add to schema too --- doc/cascadia/profiles.schema.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 0294330e9d2..8389b6fe1d0 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -154,6 +154,10 @@ "description": "Sets how the background image aligns to the boundaries of the window when unfocused. Possible values: \"center\", \"left\", \"top\", \"right\", \"bottom\", \"topLeft\", \"topRight\", \"bottomLeft\", \"bottomRight\"", "type": "string" }, + "disableIntenseIsBold": { + "description": "When set to true, text formatted as 'intense' will not be rendered as 'bold'.", + "type": "boolean" + }, "experimental.retroTerminalEffect": { "description": "When set to true, enable retro terminal effects when unfocused. This is an experimental feature, and its continued existence is not guaranteed.", "type": "boolean" From 493b382c58fd42440eebeefe1b76ab1d4df5b48e Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 15 Jul 2021 10:01:00 -0500 Subject: [PATCH 3/3] nits --- doc/cascadia/profiles.schema.json | 1 + src/cascadia/TerminalSettingsEditor/Profiles.xaml | 1 - src/renderer/dx/DxRenderer.cpp | 1 + src/renderer/dx/DxRenderer.hpp | 2 +- 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 8389b6fe1d0..c79f5727efe 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -155,6 +155,7 @@ "type": "string" }, "disableIntenseIsBold": { + "default": "false", "description": "When set to true, text formatted as 'intense' will not be rendered as 'bold'.", "type": "boolean" }, diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.xaml b/src/cascadia/TerminalSettingsEditor/Profiles.xaml index 27f191a090e..e2fb389877b 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles.xaml @@ -481,7 +481,6 @@ IsChecked="{x:Bind IsBellStyleFlagSet(4), BindBack=SetBellStyleTaskbar, Mode=TwoWay}" /> - diff --git a/src/renderer/dx/DxRenderer.cpp b/src/renderer/dx/DxRenderer.cpp index de35032429c..a2e467b01b2 100644 --- a/src/renderer/dx/DxRenderer.cpp +++ b/src/renderer/dx/DxRenderer.cpp @@ -95,6 +95,7 @@ DxEngine::DxEngine() : _dpi{ USER_DEFAULT_SCREEN_DPI }, _scale{ 1.0f }, _prevScale{ 1.0f }, + _intenseIsBold{ true }, _chainMode{ SwapChainMode::ForComposition }, _customLayout{}, _customRenderer{ ::Microsoft::WRL::Make() }, diff --git a/src/renderer/dx/DxRenderer.hpp b/src/renderer/dx/DxRenderer.hpp index 28f95bb44c2..eafe0ded1b0 100644 --- a/src/renderer/dx/DxRenderer.hpp +++ b/src/renderer/dx/DxRenderer.hpp @@ -254,7 +254,7 @@ namespace Microsoft::Console::Render // Preferences and overrides bool _softwareRendering; bool _forceFullRepaintRendering; - bool _intenseIsBold{ true }; + bool _intenseIsBold; D2D1_TEXT_ANTIALIAS_MODE _antialiasingMode;