diff --git a/src/shape.rs b/src/shape.rs index ff654b1..9216592 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -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; }