aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-08-31 17:56:59 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-08-31 17:56:59 +0000
commitbb948d03e199870da6b35ba6f88ea88be12cfe21 (patch)
tree5ff108903b3091fa458bed336fbb2d26170293a5
parentMerge branch 'csi-cleanup' (diff)
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.
-rw-r--r--terminal.c11
1 files 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