Skip to content

Commit

Permalink
Fix blurry text
Browse files Browse the repository at this point in the history
  • Loading branch information
rparrett committed Mar 11, 2024
1 parent 8a08825 commit 86f6c07
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,15 @@ pub fn extract_uinode_text(
// * Multiply by the rounded physical position by the inverse scale factor to return to logical coordinates

let logical_top_left = -0.5 * uinode.size();
let physical_nearest_pixel = (logical_top_left * scale_factor).round();
let logical_top_left_nearest_pixel = physical_nearest_pixel * inverse_scale_factor;
let transform = Mat4::from(global_transform.affine())
* Mat4::from_translation(logical_top_left_nearest_pixel.extend(0.));

let mut transform = Mat4::from(global_transform.affine())
* Mat4::from_translation(logical_top_left.extend(0.))
* Mat4::from_scale(Vec3::splat(scale_factor));

transform.w_axis[0] = transform.w_axis[0].round();
transform.w_axis[1] = transform.w_axis[1].round();

transform = transform * Mat4::from_scale(Vec3::splat(inverse_scale_factor));

let mut color = LinearRgba::WHITE;
let mut current_section = usize::MAX;
Expand Down

0 comments on commit 86f6c07

Please sign in to comment.