Skip to content

Commit ff626f2

Browse files
tigregaliscart
andauthored
fix wavy text (#725)
fix wavy text Co-authored-by: Carter Anderson <mcanders1@gmail.com>
1 parent b6004e4 commit ff626f2

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

crates/bevy_text/src/draw.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,10 @@ impl<'a> Drawable for DrawableText<'a> {
119119
)?;
120120

121121
let bounds = outlined.px_bounds();
122-
let offset = scaled_font.descent() + glyph_height;
123-
let transform = Mat4::from_translation(
124-
caret
125-
+ Vec3::new(
126-
0.0 + glyph_width / 2.0 + bounds.min.x,
127-
glyph_height / 2.0 - bounds.min.y - offset,
128-
0.0,
129-
),
130-
);
122+
let x = bounds.min.x + glyph_width / 2.0;
123+
// the 0.5 accounts for odd-numbered heights (bump up by 1 pixel)
124+
let y = -bounds.max.y + glyph_height / 2.0 - scaled_font.descent() + 0.5;
125+
let transform = Mat4::from_translation(caret + Vec3::new(x, y, 0.0));
131126
let sprite = TextureAtlasSprite {
132127
index: glyph_atlas_info.char_index,
133128
color: self.style.color,

0 commit comments

Comments
 (0)