1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Fix crash with very low font sizes

Fixes #6432.
This commit is contained in:
Kirill Chibisov 2022-10-21 22:40:42 +03:00 committed by GitHub
parent 5b1dd38806
commit 62e9d3ab39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -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 - `--help` output for `--class` does not match man pages
- Cursor and underlines always being black on very old hardware - Cursor and underlines always being black on very old hardware
- Crash when using very low negative `font.offset`
## 0.11.0 ## 0.11.0

View file

@ -37,8 +37,9 @@ pub fn builtin_glyph(
} }
fn box_drawing(character: char, metrics: &Metrics, offset: &Delta<i8>) -> RasterizedGlyph { fn box_drawing(character: char, metrics: &Metrics, offset: &Delta<i8>) -> RasterizedGlyph {
let height = (metrics.line_height as i32 + offset.y as i32) as usize; // Ensure that width and height is at least one.
let width = (metrics.average_advance as i32 + offset.x as i32) as usize; 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. // 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 stroke_size = cmp::max((width as f32 / 8.).round() as usize, 1);
let heavy_stroke_size = stroke_size * 2; let heavy_stroke_size = stroke_size * 2;