Render SGR 1 as bold when used with ITU colors (#18903)

The `SGR 1` VT attribute can either be interpreted as a brighter color,
or as a bolder font, depending on the _Intense text style_ setting.
However, the concept of brightness only applies to the eight standard
ANSI colors, so when `SGR 1` is configured as _bright_, it has no effect
on the ITU T.416 colors (RGB and the 256 index colors).

To address that, we now interpret `SGR 1` as a bolder font when applied
to ITU colors, regardless of whether the _Intense text style_ option is
set to bold or not.

Note that this only applies to the Atlas render engine, since the GDI
engine doesn't support bold fonts.

## Validation Steps Performed

I've manually tested `SGR 1` applied to different color formats with the
_Intense text style_ option set to _None_, and confirmed that the text
is now rendered with a bold font for ITU colors, but not for ANSI/AIX
colors.

Closes #18284
This commit is contained in:
James Holderness 2025-05-13 18:53:13 +01:00 committed by GitHub
parent 064d9af46e
commit 07c9a99273
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 3 deletions

View File

@ -232,6 +232,11 @@ void TextAttribute::SetRightVerticalDisplayed(const bool isDisplayed) noexcept
WI_UpdateFlag(_attrs, CharacterAttributes::RightGridline, isDisplayed);
}
bool TextAttribute::IsBold(const bool intenseIsBold) const noexcept
{
return IsIntense() && (intenseIsBold || !_foreground.CanBeBrightened());
}
bool TextAttribute::IsIntense() const noexcept
{
return WI_IsFlagSet(_attrs, CharacterAttributes::Intense);

View File

@ -115,6 +115,7 @@ public:
return memcmp(this, &other, sizeof(TextAttribute)) != 0;
}
bool IsBold(const bool intenseIsBold) const noexcept;
bool IsLegacy() const noexcept;
bool IsIntense() const noexcept;
bool IsFaint() const noexcept;

View File

@ -2278,7 +2278,7 @@ std::string TextBuffer::GenHTML(const CopyRequest& req,
fmt::format_to(std::back_inserter(htmlBuilder), FMT_COMPILE("color:{};"), fgHex);
fmt::format_to(std::back_inserter(htmlBuilder), FMT_COMPILE("background-color:{};"), bgHex);
if (isIntenseBold && attr.IsIntense())
if (attr.IsBold(isIntenseBold))
{
htmlBuilder += "font-weight:bold;";
}
@ -2528,7 +2528,7 @@ std::string TextBuffer::GenRTF(const CopyRequest& req,
fmt::format_to(std::back_inserter(contentBuilder), FMT_COMPILE("\\cf{}"), fgIdx);
fmt::format_to(std::back_inserter(contentBuilder), FMT_COMPILE("\\chshdng0\\chcbpat{}"), bgIdx);
if (isIntenseBold && attr.IsIntense())
if (attr.IsBold(isIntenseBold))
{
contentBuilder += "\\b";
}

View File

@ -651,7 +651,7 @@ try
if (!isSettingDefaultBrushes)
{
auto attributes = FontRelevantAttributes::None;
WI_SetFlagIf(attributes, FontRelevantAttributes::Bold, textAttributes.IsIntense() && renderSettings.GetRenderMode(RenderSettings::Mode::IntenseIsBold));
WI_SetFlagIf(attributes, FontRelevantAttributes::Bold, textAttributes.IsBold(renderSettings.GetRenderMode(RenderSettings::Mode::IntenseIsBold)));
WI_SetFlagIf(attributes, FontRelevantAttributes::Italic, textAttributes.IsItalic());
if (_api.attributes != attributes)