From ff626f2f6f47584d1c8d550f30af482c9bc26e0a Mon Sep 17 00:00:00 2001 From: tigregalis <38416468+tigregalis@users.noreply.github.com> Date: Sat, 31 Oct 2020 07:29:24 +0800 Subject: [PATCH] fix wavy text (#725) fix wavy text Co-authored-by: Carter Anderson --- crates/bevy_text/src/draw.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/crates/bevy_text/src/draw.rs b/crates/bevy_text/src/draw.rs index e09410b664..b88718952e 100644 --- a/crates/bevy_text/src/draw.rs +++ b/crates/bevy_text/src/draw.rs @@ -119,15 +119,10 @@ impl<'a> Drawable for DrawableText<'a> { )?; let bounds = outlined.px_bounds(); - let offset = scaled_font.descent() + glyph_height; - let transform = Mat4::from_translation( - caret - + Vec3::new( - 0.0 + glyph_width / 2.0 + bounds.min.x, - glyph_height / 2.0 - bounds.min.y - offset, - 0.0, - ), - ); + let x = bounds.min.x + glyph_width / 2.0; + // the 0.5 accounts for odd-numbered heights (bump up by 1 pixel) + let y = -bounds.max.y + glyph_height / 2.0 - scaled_font.descent() + 0.5; + let transform = Mat4::from_translation(caret + Vec3::new(x, y, 0.0)); let sprite = TextureAtlasSprite { index: glyph_atlas_info.char_index, color: self.style.color,