Skip to content
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

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
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 @@ -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;
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 @@ -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
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 @@ -157,6 +159,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
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/Profiles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@
IsChecked="{x:Bind IsBellStyleFlagSet(4), BindBack=SetBellStyleTaskbar, Mode=TwoWay}" />
</StackPanel>
</local:SettingContainer>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see you thought you had to edit Profiles.xaml haha. You can definitely undo this one.

</StackPanel>
</ScrollViewer>
</PivotItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,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 @@ -1158,4 +1162,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 @@ -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);
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
13 changes: 12 additions & 1 deletion src/renderer/dx/DxRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1961,7 +1972,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{ true };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: looks like all of the other ones are initialized in the ctor. We should probably move this there for consistency

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should start moving these things into the header honestly.


D2D1_TEXT_ANTIALIAS_MODE _antialiasingMode;

Expand Down