diff --git a/wezterm-gui/src/glyphcache.rs b/wezterm-gui/src/glyphcache.rs index 8077ccfc3..626c13ba8 100644 --- a/wezterm-gui/src/glyphcache.rs +++ b/wezterm-gui/src/glyphcache.rs @@ -135,7 +135,7 @@ bitflags::bitflags! { } } -#[derive(Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub enum BlockAlpha { /// 100% Full, @@ -150,7 +150,7 @@ pub enum BlockAlpha { /// Represents a Block Element glyph, decoded from /// /// -#[derive(Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub enum BlockKey { /// Number of 1/8ths in the upper half Upper(u8), @@ -668,7 +668,7 @@ impl GlyphCache { BlockKey::Upper(num) => { for n in 0..usize::from(num) { for a in 0..scale(y_eighth) { - draw_horizontal(&mut buffer, scale(n as f32 * y_eighth) + a); + draw_horizontal(&mut buffer, (n as f32 * y_eighth).floor() as usize + a); } } } @@ -684,7 +684,7 @@ impl GlyphCache { BlockKey::Left(num) => { for n in 0..usize::from(num) { for a in 0..scale(x_eighth) { - draw_vertical(&mut buffer, scale(n as f32 * x_eighth) + a); + draw_vertical(&mut buffer, (n as f32 * x_eighth).floor() as usize + a); } } } @@ -728,6 +728,11 @@ impl GlyphCache { } } + /* + log::info!("{:?}", block); + buffer.log_bits(); + */ + let sprite = self.atlas.allocate(&buffer)?; self.block_glyphs.insert(block, sprite.clone()); Ok(sprite) diff --git a/window/src/bitmaps/mod.rs b/window/src/bitmaps/mod.rs index d63a5a325..926c0ab89 100644 --- a/window/src/bitmaps/mod.rs +++ b/window/src/bitmaps/mod.rs @@ -483,6 +483,19 @@ impl Image { let height = (self.height as f64 * scale) as usize; self.resize(width, height) } + + #[allow(dead_code)] + pub fn log_bits(&self) { + log::info!("Image pixels:"); + for y in 0..self.height { + let row = self.horizontal_pixel_range(0, self.width, y); + let mut line = String::new(); + for p in row { + line.push_str(&format!("{:08x} ", *p)); + } + log::info!("{}", line); + } + } } impl BitmapImage for Image {