diff --git a/wezterm-font/src/rasterizer/freetype.rs b/wezterm-font/src/rasterizer/freetype.rs index fdeeef474..0c7bafb4e 100644 --- a/wezterm-font/src/rasterizer/freetype.rs +++ b/wezterm-font/src/rasterizer/freetype.rs @@ -230,9 +230,12 @@ impl FreeTypeRasterizer { // emoji glyphs don't always fill the bitmap size, so we compute // the non-transparent bounds - let cropped = crate::rasterizer::crop_to_non_transparent(&mut source_image).to_image(); + let mut cropped = crate::rasterizer::crop_to_non_transparent(&mut source_image).to_image(); + crate::rasterizer::swap_red_and_blue(&mut cropped); + let dest_width = cropped.width() as usize; let dest_height = cropped.height() as usize; + RasterizedGlyph { data: cropped.into_vec(), height: dest_height, diff --git a/wezterm-font/src/rasterizer/mod.rs b/wezterm-font/src/rasterizer/mod.rs index b1180df50..fa8d00806 100644 --- a/wezterm-font/src/rasterizer/mod.rs +++ b/wezterm-font/src/rasterizer/mod.rs @@ -1,6 +1,7 @@ use crate::parser::ParsedFont; use crate::units::*; use config::FontRasterizerSelection; +use image::{ImageBuffer, Rgba}; /// The amount, as a number in [0,1], to horizontally skew a glyph when rendering synthetic /// italics @@ -47,9 +48,19 @@ pub fn new_rasterizer( } } +pub(crate) fn swap_red_and_blue + std::ops::DerefMut>( + image: &mut ImageBuffer, Container>, +) { + for pixel in image.pixels_mut() { + let red = pixel[0]; + pixel[0] = pixel[2]; + pixel[2] = red; + } +} + pub(crate) fn crop_to_non_transparent<'a, Container>( - image: &'a mut image::ImageBuffer, Container>, -) -> image::SubImage<&'a mut image::ImageBuffer, Container>> + image: &'a mut image::ImageBuffer, Container>, +) -> image::SubImage<&'a mut ImageBuffer, Container>> where Container: std::ops::Deref, {