Skip to content

Commit

Permalink
Multiply by a glyph-to-default rounded factor when resizing fonts
Browse files Browse the repository at this point in the history
 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 <[email protected]>
  • Loading branch information
MoSal authored and jackpot51 committed Jan 19, 2024
1 parent 6aadfad commit 845a66c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 845a66c

Please sign in to comment.