bevyengine / bevyengine/bevy

`\t` tab escape sequence support in text

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

Description

## What problem does this solve or what need does it fill?

from the `display_and_visibility` example:

```rust
let bottom_frame = commands.spawn(NodeBundle {
style: Style {
flex_direction: FlexDirection::Row,
align_items: AlignItems::Start,
justify_content: JustifyContent::Start,
column_gap: Val::Px(10.),
..Default::default()
},
..default() })
.with_children(|builder| {
let text_style = TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 20.0,
color: Color::WHITE,
};
builder.spawn(TextBundle {
text: Text::from_section(
"Display::None\nVisibility::Hidden\nVisibility::Inherited",
TextStyle { color: HIDDEN_COLOR, ..text_style.clone() }
).with_alignment(TextAlignment::Center),
..Default::default()
});
builder.spawn(TextBundle {
text: Text::from_section(
"-\n-\n-",
TextStyle { color: Color::DARK_GRAY, ..text_style.clone() }
).with_alignment(TextAlignment::Center),
..Default::default()
});
builder.spawn(TextBundle::from_section(
"The UI Node and its descendants will not be visible and will not be allotted any space in the UI layout.\nThe UI Node will not be visible but will still occupy space in the UI layout.\nThe UI node will inherit the visibility property of its parent. If it has no parent it will be visible.",
text_style
));
}).id();
```

In order to format the text it is displayed in three vertical columns. It's extremely unclear what this code is meant to do without running the example to see the displayed output.

A more natural way to write this would be to use tab escape sequences:

```rust
commands.spawn(
TextBundle::from_section(
"Display::None\t-\tThe UI Node and its descendants will not be visible and will not be allotted any space in the UI layout.\n\
Visibility::Hidden\t-\tThe UI Node will not be visible but will still occupy space in the UI layout.\n\
Visibility::Inherited\t-\tThe UI node will inherit the visibility property of its parent. If it has no parent it will be visible.",
TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 20.0,
color: Color::WHITE,
}).with_alignment(TextAlignment::Center),
);
```

## What solution would you like?

It seems tricky to add tabs from within `bevy_text` itself and `glyph_brush_layout` ignores `\t`.
Maybe the cosmic text implementation will support tabs, I'm not sure.

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.