Skip to content

Add a setting for disabling rendering "intense" text as bold #10648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@
"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": {
"default": "false",
"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"
Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/IControlAppearance.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/Appearances.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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;
Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/TerminalSettingsEditor/Appearances.idl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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
Expand Down
10 changes: 10 additions & 0 deletions src/cascadia/TerminalSettingsEditor/Appearances.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
<local:PaddingConverter x:Key="PaddingConverter" />
<local:StringIsNotDesktopConverter x:Key="StringIsNotDesktopConverter" />
<local:DesktopWallpaperToEmptyStringConverter x:Key="DesktopWallpaperToEmptyStringConverter" />
<local:InvertedBooleanConverter x:Key="InvertedBooleanConverter" />

</ResourceDictionary>
</UserControl.Resources>

Expand Down Expand Up @@ -160,6 +162,14 @@
SettingOverrideSource="{x:Bind Appearance.RetroTerminalEffectOverrideSource, Mode=OneWay}">
<ToggleSwitch IsOn="{x:Bind Appearance.RetroTerminalEffect, Mode=TwoWay}" />
</local:SettingContainer>
<!-- Intense is bold -->
<local:SettingContainer x:Uid="Profile_DisableIntenseIsBold"
ClearSettingValue="{x:Bind Appearance.ClearDisableIntenseIsBold}"
HasSettingValue="{x:Bind Appearance.HasDisableIntenseIsBold, Mode=OneWay}"
SettingOverrideSource="{x:Bind Appearance.DisableIntenseIsBoldOverrideSource, Mode=OneWay}">
<ToggleSwitch IsOn="{x:Bind Appearance.DisableIntenseIsBold, Mode=TwoWay, Converter={StaticResource InvertedBooleanConverter}}" />
</local:SettingContainer>

</StackPanel>

<!-- Grouping: Cursor -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,10 @@
<value>Flash window</value>
<comment>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.</comment>
</data>
<data name="Profile_DisableIntenseIsBold.Header" xml:space="preserve">
<value>Render "intense" text as bold</value>
<comment>Header for a control to toggle if text formatted as "intense" should be rendered with a bold font weight or not.</comment>
</data>
<data name="ColorScheme_AddNewButton.Text" xml:space="preserve">
<value>Add new</value>
<comment>Button label that creates a new color scheme.</comment>
Expand Down Expand Up @@ -1170,4 +1174,4 @@
<value>Add new</value>
<comment>Button label that creates a new action on the actions page.</comment>
</data>
</root>
</root>
4 changes: 4 additions & 0 deletions src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Profile> sourceProfile) :
_sourceProfile(sourceProfile)
Expand All @@ -48,6 +49,7 @@ winrt::com_ptr<AppearanceConfig> AppearanceConfig::CopyAppearance(const winrt::c
appearance->_BackgroundImageAlignment = sourceAppearance->_BackgroundImageAlignment;
appearance->_RetroTerminalEffect = sourceAppearance->_RetroTerminalEffect;
appearance->_PixelShaderPath = sourceAppearance->_PixelShaderPath;
appearance->_DisableIntenseIsBold = sourceAppearance->_DisableIntenseIsBold;
return appearance;
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsModel/AppearanceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Profile> _sourceProfile;
};
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::Duplicate
DUPLICATE_SETTING_MACRO_SUB(appearance, target, SelectionBackground);
DUPLICATE_SETTING_MACRO_SUB(appearance, target, CursorColor);
DUPLICATE_SETTING_MACRO_SUB(appearance, target, PixelShaderPath);
DUPLICATE_SETTING_MACRO_SUB(appearance, target, DisableIntenseIsBold);
DUPLICATE_SETTING_MACRO_SUB(appearance, target, BackgroundImagePath);
DUPLICATE_SETTING_MACRO_SUB(appearance, target, BackgroundImageOpacity);
DUPLICATE_SETTING_MACRO_SUB(appearance, target, BackgroundImageStretchMode);
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsModel/IAppearanceConfig.idl
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ namespace Microsoft.Terminal.Settings.Model

INHERITABLE_APPEARANCE_SETTING(Boolean, RetroTerminalEffect);
INHERITABLE_APPEARANCE_SETTING(String, PixelShaderPath);

INHERITABLE_APPEARANCE_SETTING(Boolean, DisableIntenseIsBold);
};
}
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsModel/TerminalSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation

_RetroTerminalEffect = appearance.RetroTerminalEffect();
_PixelShaderPath = winrt::hstring{ wil::ExpandEnvironmentStringsW<std::wstring>(appearance.PixelShaderPath().c_str()) };

_DisableIntenseIsBold = appearance.DisableIntenseIsBold();
}

// Method Description:
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsModel/TerminalSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::array<Microsoft::Terminal::Core::Color, COLOR_TABLE_SIZE>> _ColorTable;
gsl::span<Microsoft::Terminal::Core::Color> _getColorTableImpl();
Expand Down
14 changes: 13 additions & 1 deletion src/renderer/dx/DxRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CustomTextRenderer>() },
Expand Down Expand Up @@ -1035,6 +1036,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)
Expand Down Expand Up @@ -1961,7 +1973,7 @@ CATCH_RETURN()
if (_drawingContext)
{
_drawingContext->forceGrayscaleAA = _ShouldForceGrayscaleAA();
_drawingContext->useBoldFont = textAttributes.IsBold();
_drawingContext->useBoldFont = _intenseIsBold && textAttributes.IsBold();
_drawingContext->useItalicFont = textAttributes.IsItalic();
}

Expand Down
3 changes: 3 additions & 0 deletions src/renderer/dx/DxRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace Microsoft::Console::Render

void SetSoftwareRendering(bool enable) noexcept;

void SetIntenseIsBold(bool enable) noexcept;

HANDLE GetSwapChainHandle();

// IRenderEngine Members
Expand Down Expand Up @@ -252,6 +254,7 @@ namespace Microsoft::Console::Render
// Preferences and overrides
bool _softwareRendering;
bool _forceFullRepaintRendering;
bool _intenseIsBold;

D2D1_TEXT_ANTIALIAS_MODE _antialiasingMode;

Expand Down