From 2ccf2378fda79d7cd0a97a1c855cdd018ebe4e0a Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 6 Feb 2022 06:19:49 -0700 Subject: [PATCH] fix vertical positioning for custom block glyphs refs: https://github.com/wez/wezterm/issues/1621 --- wezterm-gui/src/termwindow/render.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/wezterm-gui/src/termwindow/render.rs b/wezterm-gui/src/termwindow/render.rs index f53c1a521..e760519f6 100644 --- a/wezterm-gui/src/termwindow/render.rs +++ b/wezterm-gui/src/termwindow/render.rs @@ -2035,11 +2035,6 @@ impl super::TermWindow { break; } - let top = cell_height - + (params.render_metrics.descender.get() as f32 - - (glyph.y_offset + glyph.bearing_y).get() as f32) - * height_scale; - for glyph_idx in 0..info.pos.num_cells as usize { for img in &images { if img.z_index() < 0 { @@ -2059,6 +2054,10 @@ impl super::TermWindow { { // First, resolve this glyph to a texture let mut texture = glyph.texture.as_ref().cloned(); + let mut top = cell_height + + (params.render_metrics.descender.get() as f32 + - (glyph.y_offset + glyph.bearing_y).get() as f32) + * height_scale; if self.config.custom_block_glyphs { if let Some(cell) = params.line.cells().get(visual_cell_idx) { @@ -2069,6 +2068,10 @@ impl super::TermWindow { .borrow_mut() .cached_block(block, ¶ms.render_metrics)?, ); + // Custom glyphs don't have the same offsets as computed + // by the shaper, and are rendered relative to the cell + // top left, rather than the baseline. + top = 0.; } } }