From 06c72fc8c335e569584f64754e9965af7d14ec5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 Dec 2021 18:41:36 +0100 Subject: [PATCH] term: ensure cell dimensions are non-zero Closes #830 --- CHANGELOG.md | 5 +++++ terminal.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23f10509..2ad375d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,11 @@ ### Deprecated ### Removed ### Fixed + +* Crash when bitmap fonts are scaled down to very small font sizes + (https://codeberg.org/dnkl/foot/issues/830). + + ### Security ### Contributors diff --git a/terminal.c b/terminal.c index 1d27693a..d5728a53 100644 --- a/terminal.c +++ b/terminal.c @@ -688,6 +688,11 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4]) : max(term->fonts[0]->height, term->fonts[0]->ascent + term->fonts[0]->descent); + if (term->cell_width <= 0) + term->cell_width = 1; + if (term->cell_height <= 0) + term->cell_height = 1; + term->font_x_ofs = term_pt_or_px_as_pixels(term, &conf->horizontal_letter_offset); term->font_y_ofs = term_pt_or_px_as_pixels(term, &conf->vertical_letter_offset);