diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2022-10-21 22:40:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-21 22:40:42 +0300 |
commit | 62e9d3ab394f3ad104642e964e9034a352d76d9a (patch) | |
tree | fd9cc5a53dfe02ff7b058df9eaab6e4a3647e47a | |
parent | 5b1dd38806eeb625f45303ab8981f3975f1b7b24 (diff) | |
download | alacritty-62e9d3ab394f3ad104642e964e9034a352d76d9a.tar.gz alacritty-62e9d3ab394f3ad104642e964e9034a352d76d9a.zip |
Fix crash with very low font sizes
Fixes #6432.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | alacritty/src/renderer/text/builtin_font.rs | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 56045e29..3608f2f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `--help` output for `--class` does not match man pages - Cursor and underlines always being black on very old hardware +- Crash when using very low negative `font.offset` ## 0.11.0 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<i8>) -> 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; |