From bb948d03e199870da6b35ba6f88ea88be12cfe21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Aug 2021 19:56:59 +0200 Subject: [PATCH] =?UTF-8?q?terminal:=20prefer=20the=20advance=20width=20of?= =?UTF-8?q?=20=E2=80=98M=E2=80=99=20over=20that=20of=20a=20space?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes some non-monospaced fonts more readable, allowing users to read errors and warnings printed in the window. Furthermore, fcft-3.0 will remove the space_advance member, so once we upgrade, we’ll have to rasterize a glyph ourselves anyway. --- terminal.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/terminal.c b/terminal.c index cb1641f2..a95a5c61 100644 --- a/terminal.c +++ b/terminal.c @@ -657,10 +657,15 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4]) const struct config *conf = term->conf; + const struct fcft_glyph *M = fcft_glyph_rasterize( + term->fonts[0], L'M', term->font_subpixel); + term->cell_width = - (term->fonts[0]->space_advance.x > 0 - ? term->fonts[0]->space_advance.x - : term->fonts[0]->max_advance.x) + (M != NULL + ? M->advance.x + : (term->fonts[0]->space_advance.x > 0 + ? term->fonts[0]->space_advance.x + : term->fonts[0]->max_advance.x)) + term_pt_or_px_as_pixels(term, &conf->letter_spacing); term->cell_height = term->font_line_height.px >= 0