From fd512da9832ccedb5bbbb3a317bb9a6e671e81c0 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 8 Jun 2020 18:02:51 -0700 Subject: [PATCH] term: improve iterm2 image pixel->cell calculation If the image is smaller than the cell size we could end up rounding that dimension to zero and ultimately not render the texture to the cell. This commit adjusts the math to round up, which yields better results for the test in refs: https://github.com/wez/wezterm/issues/211 --- term/src/terminalstate.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index d1595c41d..3885fc200 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -958,8 +958,8 @@ impl TerminalState { (Some(w), Some(h)) => (w, h), }; - let width_in_cells = width / cell_pixel_width; - let height_in_cells = height / cell_pixel_height; + let width_in_cells = (width as f32 / cell_pixel_width as f32).ceil() as usize; + let height_in_cells = (height as f32 / cell_pixel_height as f32).ceil() as usize; // TODO: defer this to the actual renderer /*