Skip to content

Respect leading spaces for rendering #1272

Open
@Elinvynia

Description

@Elinvynia

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is brokentextProblems related to text

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions