Skip to content

Commit

Permalink
Implement faint attr (\e[2m) in default renderer
Browse files Browse the repository at this point in the history
Fixes #66
  • Loading branch information
ku1ik committed Oct 23, 2024
1 parent 4ea9e66 commit 530bda9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct TextAttrs {
foreground: Option<avt::Color>,
background: Option<avt::Color>,
bold: bool,
faint: bool,
italic: bool,
underline: bool,
}
Expand Down Expand Up @@ -74,6 +75,7 @@ fn text_attrs(
foreground,
background,
bold: pen.is_bold(),
faint: pen.is_faint(),
italic: pen.is_italic(),
underline: pen.is_underline(),
}
Expand Down
9 changes: 7 additions & 2 deletions src/renderer/fontdue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,16 @@ impl Renderer for FontdueRenderer {
continue;
}

let v = bitmap[bmap_y * metrics.width + bmap_x];
let mut ratio = bitmap[bmap_y * metrics.width + bmap_x];

if attrs.faint {
ratio = (ratio as f32 * 0.5) as u8;
}

let idx = (y as usize) * self.pixel_width + (x as usize);
let bg = buf[idx];

buf[idx] = mix_colors(fg, bg, v);
buf[idx] = mix_colors(fg, bg, ratio);
}
}

Expand Down

0 comments on commit 530bda9

Please sign in to comment.