Respect leading spaces for rendering
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
**Is your feature request related to a problem? Please describe.**
I'm trying to align a cursor for menu entries.
```
let cursor = if some_condition {
RichText::new("> ").color(Color32::LIGHT_GRAY).text_style(TextStyle::Monospace)
} else {
RichText::new(" ").color(Color32::LIGHT_GRAY).text_style(TextStyle::Monospace)
};
ui.label(cursor);
ui.label("Some Text");
```
Currently, the `else` condition never renders. There has to be an actual symbol besides just regular spaces. I'd prefer not to mess with the fonts as I like the default ones.
**Describe the solution you'd like**
If there is a space character it was most likely put there deliberately and thus should be rendered by default.
**Describe alternatives you've considered**
Using a custom font with some space-equivalent-yet-renderable character.
**Additional context**
I've tried looking into the source code but unfortunately couldn't figure out where the `is_empty` call is made that is causing this.
Contributor guide
Research direction
Start by tracing the ui.label rendering path and locating the is_empty call mentioned in the issue. Reproduce the example with the leading-space labels, then verify that intentional leading spaces render and the cursor and menu text align without requiring a custom font.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100