terminal: prefer the advance width of ‘M’ over that of a space

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.
This commit is contained in:
Daniel Eklöf 2021-08-31 19:56:59 +02:00
parent f26251d3bd
commit bb948d03e1
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -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