Skip to content

Commit 07c9a99

Browse files
authored
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
1 parent 064d9af commit 07c9a99

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

src/buffer/out/TextAttribute.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ void TextAttribute::SetRightVerticalDisplayed(const bool isDisplayed) noexcept
232232
WI_UpdateFlag(_attrs, CharacterAttributes::RightGridline, isDisplayed);
233233
}
234234

235+
bool TextAttribute::IsBold(const bool intenseIsBold) const noexcept
236+
{
237+
return IsIntense() && (intenseIsBold || !_foreground.CanBeBrightened());
238+
}
239+
235240
bool TextAttribute::IsIntense() const noexcept
236241
{
237242
return WI_IsFlagSet(_attrs, CharacterAttributes::Intense);

src/buffer/out/TextAttribute.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class TextAttribute final
115115
return memcmp(this, &other, sizeof(TextAttribute)) != 0;
116116
}
117117

118+
bool IsBold(const bool intenseIsBold) const noexcept;
118119
bool IsLegacy() const noexcept;
119120
bool IsIntense() const noexcept;
120121
bool IsFaint() const noexcept;

src/buffer/out/textBuffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,7 @@ std::string TextBuffer::GenHTML(const CopyRequest& req,
22782278
fmt::format_to(std::back_inserter(htmlBuilder), FMT_COMPILE("color:{};"), fgHex);
22792279
fmt::format_to(std::back_inserter(htmlBuilder), FMT_COMPILE("background-color:{};"), bgHex);
22802280

2281-
if (isIntenseBold && attr.IsIntense())
2281+
if (attr.IsBold(isIntenseBold))
22822282
{
22832283
htmlBuilder += "font-weight:bold;";
22842284
}
@@ -2528,7 +2528,7 @@ std::string TextBuffer::GenRTF(const CopyRequest& req,
25282528
fmt::format_to(std::back_inserter(contentBuilder), FMT_COMPILE("\\cf{}"), fgIdx);
25292529
fmt::format_to(std::back_inserter(contentBuilder), FMT_COMPILE("\\chshdng0\\chcbpat{}"), bgIdx);
25302530

2531-
if (isIntenseBold && attr.IsIntense())
2531+
if (attr.IsBold(isIntenseBold))
25322532
{
25332533
contentBuilder += "\\b";
25342534
}

src/renderer/atlas/AtlasEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ try
651651
if (!isSettingDefaultBrushes)
652652
{
653653
auto attributes = FontRelevantAttributes::None;
654-
WI_SetFlagIf(attributes, FontRelevantAttributes::Bold, textAttributes.IsIntense() && renderSettings.GetRenderMode(RenderSettings::Mode::IntenseIsBold));
654+
WI_SetFlagIf(attributes, FontRelevantAttributes::Bold, textAttributes.IsBold(renderSettings.GetRenderMode(RenderSettings::Mode::IntenseIsBold)));
655655
WI_SetFlagIf(attributes, FontRelevantAttributes::Italic, textAttributes.IsItalic());
656656

657657
if (_api.attributes != attributes)

0 commit comments

Comments
 (0)