From cbe6faa83be8d73e760d643656c7a90e39dda282 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 23 Mar 2021 20:06:52 +0100 Subject: [PATCH] Render tab character (\t) as four spaces --- epaint/src/text/font.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/epaint/src/text/font.rs b/epaint/src/text/font.rs index 2ec97543..60ce8544 100644 --- a/epaint/src/text/font.rs +++ b/epaint/src/text/font.rs @@ -107,13 +107,20 @@ impl FontImpl { if glyph.id().0 == 0 { None } else { - let glyph_info = allocate_glyph( + let mut glyph_info = allocate_glyph( &mut self.atlas.lock(), glyph, self.scale_in_pixels, self.y_offset, self.pixels_per_point, ); + + if c == '\t' { + if let Some(space) = self.glyph_info(' ') { + glyph_info.advance_width = 4.0 * space.advance_width; + } + } + self.glyph_info_cache.write().insert(c, glyph_info); Some(glyph_info) }