Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: Add dynamic padding to prevent glyph clipping in text rendering on macOS (#45957)
Jony Lab83ca31055cf3
diff --git a/crates/gpui/src/platform/mac/text_system.rs b/crates/gpui/src/platform/mac/text_system.rsindex c72271f24fe..df0e1433e0e 100644--- a/crates/gpui/src/platform/mac/text_system.rs+++ b/crates/gpui/src/platform/mac/text_system.rs@@ -356,16 +356,22 @@ impl MacTextSystemState {fn raster_bounds(&self, params: &RenderGlyphParams) -> Result<Bounds<DevicePixels>> {let font = &self.fonts[params.font_id.0];- let scale = Transform2F::from_scale(params.scale_factor);- Ok(font+ let mut bounds: Bounds<DevicePixels> = font.raster_bounds(params.glyph_id.0,params.font_size.into(),- scale,+ Transform2F::from_scale(params.scale_factor),HintingOptions::None,font_kit::canvas::RasterizationOptions::GrayscaleAa,)?- .into())+ .into();++ // Adjust the x position to account for the scale factor to avoid glyph clipped.+ let x_offset = DevicePixels(bounds.origin.x.0 / params.scale_factor as i32);+ bounds.origin.x -= x_offset;+ bounds.size.width += x_offset;++ Ok(bounds)}fn rasterize_glyph(