Round x_advance to nearest monospace width when requested, fixes #237

This commit is contained in:
Jeremy Soller 2025-11-03 15:09:58 -07:00
parent 40fee41332
commit 8a7bc790e5
No known key found for this signature in database
GPG key ID: 670FDFB5428E05CA

View file

@ -1616,7 +1616,7 @@ impl ShapeLine {
_ => font_size,
};
let x_advance = glyph_font_size.mul_add(
let mut x_advance = glyph_font_size.mul_add(
glyph.x_advance,
if word.blank {
justification_expansion
@ -1624,6 +1624,10 @@ impl ShapeLine {
0.0
},
);
if let Some(match_em_width) = match_mono_em_width {
// Round to nearest monospace width
x_advance = ((x_advance / match_em_width).round()) * match_em_width;
}
if self.rtl {
x -= x_advance;
}