renderer: hook up font thickening setting

This commit is contained in:
Mitchell Hashimoto
2023-07-01 10:01:40 -07:00
parent 3795cd6c2d
commit 0bb2d22052
2 changed files with 27 additions and 1 deletions

View File

@ -129,6 +129,7 @@ const GPUCellMode = enum(u8) {
/// configuration. This must be exported so that we don't need to
/// pass around Config pointers which makes memory management a pain.
pub const DerivedConfig = struct {
font_thicken: bool,
cursor_color: ?terminal.color.RGB,
background: terminal.color.RGB,
foreground: terminal.color.RGB,
@ -142,6 +143,8 @@ pub const DerivedConfig = struct {
_ = alloc_gpa;
return .{
.font_thicken = config.@"font-thicken",
.cursor_color = if (config.@"cursor-color") |col|
col.toTerminalRGB()
else
@ -738,6 +741,14 @@ fn drawCells(
/// Update the configuration.
pub fn changeConfig(self: *Metal, config: *DerivedConfig) !void {
// If font thickening settings change, we need to reset our
// font texture completely because we need to re-render the glyphs.
if (self.config.font_thicken != config.font_thicken) {
self.font_group.reset();
self.font_group.atlas_greyscale.clear();
self.font_group.atlas_color.clear();
}
self.config = config.*;
}
@ -998,6 +1009,7 @@ pub fn updateCell(
shaper_cell.glyph_index,
.{
.max_height = @intFromFloat(@ceil(self.cell_size.height)),
.thicken = self.config.font_thicken,
},
);

View File

@ -226,6 +226,7 @@ const GPUCellMode = enum(u8) {
/// configuration. This must be exported so that we don't need to
/// pass around Config pointers which makes memory management a pain.
pub const DerivedConfig = struct {
font_thicken: bool,
cursor_color: ?terminal.color.RGB,
background: terminal.color.RGB,
foreground: terminal.color.RGB,
@ -239,6 +240,8 @@ pub const DerivedConfig = struct {
_ = alloc_gpa;
return .{
.font_thicken = config.@"font-thicken",
.cursor_color = if (config.@"cursor-color") |col|
col.toTerminalRGB()
else
@ -1144,7 +1147,10 @@ pub fn updateCell(
self.alloc,
shaper_run.font_index,
shaper_cell.glyph_index,
.{ .max_height = @intFromFloat(@ceil(self.cell_size.height)) },
.{
.max_height = @intFromFloat(@ceil(self.cell_size.height)),
.thicken = self.config.font_thicken,
},
);
// If we're rendering a color font, we use the color atlas
@ -1254,6 +1260,14 @@ fn gridSize(self: *const OpenGL, screen_size: renderer.ScreenSize) renderer.Grid
/// Update the configuration.
pub fn changeConfig(self: *OpenGL, config: *DerivedConfig) !void {
// If font thickening settings change, we need to reset our
// font texture completely because we need to re-render the glyphs.
if (self.config.font_thicken != config.font_thicken) {
self.font_group.reset();
self.font_group.atlas_greyscale.clear();
self.font_group.atlas_color.clear();
}
self.config = config.*;
}