From 845a66ceff3eb2993b23c2b802a7329fb9b094c1 Mon Sep 17 00:00:00 2001 From: Mohammad AlSaleh Date: Fri, 19 Jan 2024 18:58:48 +0300 Subject: [PATCH] Multiply by a glyph-to-default rounded factor when resizing fonts When matching to a default monospace width, big fonts like those containing symbols and emojis got too small from font resizing. Adding a glyph-to-default rounded factor to the calculation should fix that issue without losing monospatiality. Fixes pop-os/cosmic-term#69. Signed-off-by: Mohammad AlSaleh --- src/shape.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shape.rs b/src/shape.rs index 1d9551218a..581bf6d057 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -1254,8 +1254,10 @@ impl ShapeLine { (Some(match_em_width), Some(glyph_em_width)) if glyph_em_width != match_em_width => { - let glyph_font_size = - font_size * (match_em_width / glyph_em_width); + let glyph_to_match_factor = glyph_em_width / match_em_width; + let glyph_font_size = glyph_to_match_factor.round().max(1.0) + / glyph_to_match_factor + * font_size; log::trace!("Adjusted glyph font size ({font_size} => {glyph_font_size})"); glyph_font_size }