Skip to content

Commit a507311

Browse files
authored
Render SGR 1 ("intensity") as bold in the DX engine (#10498)
This commit adds support for bold text in DxRenderer. For now, bold fonts are always rendered using DWRITE_FONT_WEIGHT_BOLD regardless of the base weight. As yet, this behavior is unconfigurable. References Previous refactoring PRs: #9096 (DxFontRenderData) #9201 (DxFontInfo) SGR support tracking issue: #6879 Closes #109
1 parent 305e3df commit a507311

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/renderer/dx/CustomTextLayout.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,16 @@ try
137137
{
138138
const auto drawingContext = static_cast<const DrawingContext*>(clientDrawingContext);
139139

140-
const DWRITE_FONT_WEIGHT weight = _fontRenderData->DefaultFontWeight();
140+
DWRITE_FONT_WEIGHT weight = _fontRenderData->DefaultFontWeight();
141141
DWRITE_FONT_STYLE style = _fontRenderData->DefaultFontStyle();
142142
const DWRITE_FONT_STRETCH stretch = _fontRenderData->DefaultFontStretch();
143143

144+
if (drawingContext->useBoldFont)
145+
{
146+
// TODO: "relative" bold?
147+
weight = DWRITE_FONT_WEIGHT_BOLD;
148+
}
149+
144150
if (drawingContext->useItalicFont)
145151
{
146152
style = DWRITE_FONT_STYLE_ITALIC;

src/renderer/dx/CustomTextRenderer.h

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace Microsoft::Console::Render
2424
renderTarget(renderTarget),
2525
foregroundBrush(foregroundBrush),
2626
backgroundBrush(backgroundBrush),
27+
useBoldFont(false),
2728
useItalicFont(false),
2829
forceGrayscaleAA(forceGrayscaleAA),
2930
dwriteFactory(dwriteFactory),
@@ -38,6 +39,7 @@ namespace Microsoft::Console::Render
3839
ID2D1RenderTarget* renderTarget;
3940
ID2D1SolidColorBrush* foregroundBrush;
4041
ID2D1SolidColorBrush* backgroundBrush;
42+
bool useBoldFont;
4143
bool useItalicFont;
4244
bool forceGrayscaleAA;
4345
IDWriteFactory* dwriteFactory;

src/renderer/dx/DxRenderer.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,7 @@ CATCH_RETURN()
19611961
if (_drawingContext)
19621962
{
19631963
_drawingContext->forceGrayscaleAA = _ShouldForceGrayscaleAA();
1964+
_drawingContext->useBoldFont = textAttributes.IsBold();
19641965
_drawingContext->useItalicFont = textAttributes.IsItalic();
19651966
}
19661967

0 commit comments

Comments
 (0)