fix(decor): unwrap if max width fits 0 chars

The `title_pixmap` function assumed if `title` was not empty, the returned
`glyphs` from `layout_title_glyphs` would also not be empty.
`layout_title_glyphs`, however, could break before a single insertion if
`max_width` was too small. Emacs, when using `emacsclient
--create-frame`, could call `title_pixmap` with a `max_width` of 1,
causing a panic. Closes #311.
This commit is contained in:
En-En 2025-12-12 01:21:42 +00:00 committed by Supreeeme
parent f0ad674b70
commit 0337421299

View file

@ -382,8 +382,7 @@ fn title_pixmap(title: &str, max_width: u32, height: u32, scale: f32) -> Option<
let width = glyphs let width = glyphs
.last() .last()
.map(|g| g.position.x + font.h_advance(g.id)) .map(|g| g.position.x + font.h_advance(g.id))?
.unwrap()
.ceil() as u32; .ceil() as u32;
let mut pixmap = Pixmap::new(width, height).unwrap(); let mut pixmap = Pixmap::new(width, height).unwrap();