From f5cf7e00403225b2e25df61e244397b8356d1c35 Mon Sep 17 00:00:00 2001 From: Mohammad AlSaleh Date: Wed, 17 Jan 2024 23:51:40 +0300 Subject: [PATCH] Set monospace width on text buffers Make use of the addition to cosmic-text that allows matching the widths of fallback Monospace fonts to the default one. Signed-off-by: Mohammad AlSaleh --- src/terminal.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/terminal.rs b/src/terminal.rs index d35603c..bfc04d5 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -203,7 +203,9 @@ impl Terminal { // Use size of space to determine cell size buffer.set_text(&mut font_system, " ", default_attrs, Shaping::Advanced); let layout = buffer.line_layout(&mut font_system, 0).unwrap(); - (layout[0].w, metrics.line_height) + let w = layout[0].w; + buffer.set_monospace_width(font_system, Some(w)); + (w, metrics.line_height) }; let size = Size { @@ -546,7 +548,9 @@ impl Terminal { // Use size of space to determine cell size buffer.set_text(font_system.raw(), " ", default_attrs, Shaping::Advanced); let layout = buffer.line_layout(font_system.raw(), 0).unwrap(); - (layout[0].w, buffer.metrics().line_height) + let w = layout[0].w; + buffer.set_monospace_width(font_system.raw(), Some(w)); + (w, buffer.metrics().line_height) }) };