Add option for setting dim font weight

Allows users to set this to a value lower than default font weight.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
Mohammad AlSaleh 2024-01-12 01:58:57 +03:00 • committed by Jeremy Soller
parent f34116f3f7
commit e56e582f90
4 changed files with 45 additions and 0 deletions

View file

@ -138,6 +138,7 @@ pub struct Terminal {
size: Size,
pub term: Arc<FairMutex<Term<EventProxy>>>,
colors: Colors,
dim_font_weight: Weight,
bold_font_weight: Weight,
use_bright_bold: bool,
notifier: Notifier,
@ -158,6 +159,7 @@ impl Terminal {
) -> Self {
let font_stretch = app_config.typed_font_stretch();
let font_weight = app_config.font_weight;
let dim_font_weight = app_config.dim_font_weight;
let bold_font_weight = app_config.bold_font_weight;
let use_bright_bold = app_config.use_bright_bold;
@ -206,6 +208,7 @@ impl Terminal {
Self {
colors,
dim_font_weight: Weight(dim_font_weight),
bold_font_weight: Weight(bold_font_weight),
use_bright_bold,
default_attrs,
@ -455,6 +458,11 @@ impl Terminal {
update_cell_size = true;
}
if self.dim_font_weight.0 != config.dim_font_weight {
self.dim_font_weight = Weight(config.dim_font_weight);
update_cell_size = true;
}
if self.bold_font_weight.0 != config.font_weight {
self.bold_font_weight = Weight(config.bold_font_weight);
update_cell_size = true;
@ -639,6 +647,9 @@ impl Terminal {
//TODO: more flags
if indexed.cell.flags.contains(Flags::BOLD) {
attrs = attrs.weight(self.bold_font_weight);
} else if indexed.cell.flags.contains(Flags::DIM) {
// if DIM and !BOLD
attrs = attrs.weight(self.dim_font_weight);
}
if indexed.cell.flags.contains(Flags::ITALIC) {
//TODO: automatically use fake italic