bevyengine / bevyengine/bevy

Line Break doesn't clear trailing whitespace

Open
#12,319 8 comments 0 reactions 0 assignees View on GitHub
A-Text A-UI C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

0.13.0

## \[Optional\] Relevant system information

```
AdapterInfo { name: "NVIDIA GeForce GTX 1050 Ti", vendor: 4318, device: 7298, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "545.29.06", backend: Vulkan }
SystemInfo { os: "Linux 23.1.3 Manjaro Linux", kernel: "5.15.148-2-MANJARO", cpu: "Intel(R) Core(TM) i5-4690K CPU @ 3.50GHz", core_count: "4", memory: "31.3 GiB" }
```

## What you did

Create a `TextBundle` node within a parent `NodeBundle` of a fixed size. The parent node centers the child node using `align_items`, `align_content`, `justify_items`, and `justify_content`. The text should contain several words and be set to line break on word boundry. The text is set to justify center.

## What went wrong

When the line break occurs, the white space char is kept in the same position. This causes the renderer to include this char in the bounding box and thus shifting the center alignment of the text.

## Additional information

This will cause the text to be off-center. The effect can clearly be seen with background colors enabled.

![Screenshot_20240305_053132](https://github.com/bevyengine/bevy/assets/3118172/c0598efb-b598-4a5f-9dc2-389b40358034)

As you can see in the image above, the space between "Streamline" and "UI" is kept in place, causing the text to be shifted by half a char width to the left.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.