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 12, 2024
1 parent c729859 commit 048c6a1
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 @@ -611,6 +611,8 @@ pub fn extract_uinode_text(
)>,
>,
) {
use bevy_math::Affine3A;

for (uinode, global_transform, view_visibility, clip, camera, text, text_layout_info) in
&uinode_query
{
Expand Down Expand Up @@ -640,10 +642,13 @@ 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 =
global_transform.affine() * Affine3A::from_translation(logical_top_left.extend(0.));

transform.translation *= scale_factor;
transform.translation = transform.translation.round();
transform.translation *= inverse_scale_factor;

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

0 comments on commit 048c6a1

Please sign in to comment.