From 62e9d3ab394f3ad104642e964e9034a352d76d9a Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Fri, 21 Oct 2022 22:40:42 +0300 Subject: Fix crash with very low font sizes Fixes #6432. --- alacritty/src/renderer/text/builtin_font.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'alacritty/src') diff --git a/alacritty/src/renderer/text/builtin_font.rs b/alacritty/src/renderer/text/builtin_font.rs index aeee6d91..c0355be6 100644 --- a/alacritty/src/renderer/text/builtin_font.rs +++ b/alacritty/src/renderer/text/builtin_font.rs @@ -37,8 +37,9 @@ pub fn builtin_glyph( } fn box_drawing(character: char, metrics: &Metrics, offset: &Delta) -> RasterizedGlyph { - let height = (metrics.line_height as i32 + offset.y as i32) as usize; - let width = (metrics.average_advance as i32 + offset.x as i32) as usize; + // Ensure that width and height is at least one. + let height = (metrics.line_height as i32 + offset.y as i32).max(1) as usize; + let width = (metrics.average_advance as i32 + offset.x as i32).max(1) as usize; // Use one eight of the cell width, since this is used as a step size for block elemenets. let stroke_size = cmp::max((width as f32 / 8.).round() as usize, 1); let heavy_stroke_size = stroke_size * 2; -- cgit