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:
parent
f0ad674b70
commit
0337421299
1 changed files with 1 additions and 2 deletions
|
|
@ -382,8 +382,7 @@ fn title_pixmap(title: &str, max_width: u32, height: u32, scale: f32) -> Option<
|
|||
|
||||
let width = glyphs
|
||||
.last()
|
||||
.map(|g| g.position.x + font.h_advance(g.id))
|
||||
.unwrap()
|
||||
.map(|g| g.position.x + font.h_advance(g.id))?
|
||||
.ceil() as u32;
|
||||
|
||||
let mut pixmap = Pixmap::new(width, height).unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue