Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

fix(render): dim faint text by colour only

RoversXf097a5face4b
diff --git a/config/src/config.rs b/config/src/config.rs
index 41dd0200..86a8dbd7 100644
--- a/config/src/config.rs
+++ b/config/src/config.rs
@@ -1578,20 +1578,17 @@ impl Config {
let bold = reduced.make_bold();
let bold_italic = bold.make_italic();
- let half_bright = reduced.make_half_bright();
- let half_bright_italic = half_bright.make_italic();
-
+ // Faint (SGR 2) keeps the regular face. The renderer draws it in a
+ // dimmer colour, as other terminals do; a lighter weight on top would
+ // make it thin as well as grey, and where the font has no lighter
+ // face the synthesized one would halve its brightness again. Only
+ // faint italic needs a rule, because the italic rule below is for
+ // normal intensity; plain faint falls through to `font` like normal
+ // text.
cfg.font_rules.push(StyleRule {
italic: Some(true),
intensity: Some(wezterm_term::Intensity::Half),
- font: half_bright_italic,
- ..Default::default()
- });
-
- cfg.font_rules.push(StyleRule {
- italic: Some(false),
- intensity: Some(wezterm_term::Intensity::Half),
- font: half_bright,
+ font: italic.clone(),
..Default::default()
});
@@ -2889,4 +2886,23 @@ return config
assert!(!to.exists());
}
}
+
+ /// The renderer dims faint text by colour, so the default rules must not
+ /// also ask for a lighter face: that would make it thin as well as grey,
+ /// or dim it twice where the font has no lighter weight.
+ #[test]
+ fn faint_text_keeps_the_regular_weight() {
+ let config = Config::default_config();
+ let faint_rules: Vec<_> = config
+ .font_rules
+ .iter()
+ .filter(|rule| rule.intensity == Some(wezterm_term::Intensity::Half))
+ .collect();
+ assert!(!faint_rules.is_empty(), "faint italic still needs its rule");
+ for rule in faint_rules {
+ for attr in &rule.font.font {
+ assert!(attr.weight >= crate::FontWeight::REGULAR, "{:?}", attr);
+ }
+ }
+ }
}
diff --git a/wezterm-gui/src/termwindow/render/mod.rs b/wezterm-gui/src/termwindow/render/mod.rs
index 08a6e8a3..9e7da818 100644
--- a/wezterm-gui/src/termwindow/render/mod.rs
+++ b/wezterm-gui/src/termwindow/render/mod.rs
@@ -1458,15 +1458,11 @@ fn resolve_fg_color_attr(
resolve_fg_color_attr_srgb(attrs, fg, palette, config, style).to_linear()
}
-/// A cell's colours as the line renderer draws them, before blinking: its
-/// foreground resolved as text is -- bold brightening, a font rule's colour
-/// -- and the two swapped where the cell's reverse attribute and the
-/// screen's reverse video disagree. The flag says the background is the
-/// pane's own ground.
/// The colour SGR 2 (faint) is drawn in: half way from the foreground to
/// the cell's own background, which is what a 50% overlay looks like on an
/// opaque cell. Faint carries no alpha of its own, so mixing is the only way
-/// to honour it without changing the glyph pipeline.
+/// to honour it without changing the glyph pipeline. The default font rules
+/// keep faint text in the regular face, so this is all the dimming it gets.
pub(crate) fn faint_color(
fg: wezterm_term::color::SrgbaTuple,
bg: wezterm_term::color::SrgbaTuple,
@@ -1474,6 +1470,11 @@ pub(crate) fn faint_color(
fg.interpolate(bg, 0.5)
}
+/// A cell's colours as the line renderer draws them, before blinking: its
+/// foreground resolved as text is -- bold brightening, a font rule's colour
+/// -- and the two swapped where the cell's reverse attribute and the
+/// screen's reverse video disagree, then dimmed if the cell is faint. The
+/// flag says the background is the pane's own ground.
pub(crate) fn cell_fg_bg(
attrs: &CellAttributes,
palette: &ColorPalette,
diff --git a/wezterm-gui/src/termwindow/render/screen_line.rs b/wezterm-gui/src/termwindow/render/screen_line.rs
index 0804428b..417661fe 100644
--- a/wezterm-gui/src/termwindow/render/screen_line.rs
+++ b/wezterm-gui/src/termwindow/render/screen_line.rs
@@ -358,8 +358,8 @@ impl crate::TermWindow {
} else {
(params.foreground, params.default_bg, false)
};
- // A bar or underline cursor still shows the cell's glyph, so
- // faint text has to stay faint under it too.
+ // A reverse-video cursor is drawn in the cell's foreground, so a
+ // faint cell's cursor takes the faint colour too.
let fg_color = if faint {
faint_color(fg_color.to_srgb(), bg_color.to_srgb()).to_linear()
} else {