Bevy: TextComponents - Position changes with length of text

Created on 31 Aug 2020  路  7Comments  路  Source: bevyengine/bevy

On macOS, just altering this string slice causes the vertical position of the text to change!

rising-text

bug ui

Most helpful comment

This happens due to how the flexbox engine interacts with fixed size elements:

This then results in the behavior we see now: A smaller height divided by two makes for an 'upwards' growing text, when in actuality it should be shrinking to fit the available width.

I am not sure what the ideal solution is here. Either the text overflows, or it gets smaller and smaller. Another option is to have it break into a new line (if there is space?)

All 7 comments

The first shot is the normal "Text Example". The second alters it to be "Text Example -- notice anything?". The third is "Text Example -- notice anything? Even more text 1234567890"

Suggested labels: bug | ui

I agree with you this is definitely a bug thanks for letting us know :) If anyone is reading this can you confirm the bug repros on other platforms too 馃槉

I'm on Archlinux , here's the same texts:

"Text Example"
image

"Text Example -- notice anything?"
image

"Text Example -- notice anything? Even more text 1234567890"
image

Same issue here

This happens due to how the flexbox engine interacts with fixed size elements:

This then results in the behavior we see now: A smaller height divided by two makes for an 'upwards' growing text, when in actuality it should be shrinking to fit the available width.

I am not sure what the ideal solution is here. Either the text overflows, or it gets smaller and smaller. Another option is to have it break into a new line (if there is space?)

In my use-case I would like to wrap. From my naive standpoint of never having had to implement a text layout system, it seems like wrap vs. shrink vs. overflow should all be supported via some configurable option. I don't know how hard that is to do.

I have this issue, my "fix" to have the expected placement is to set the Style component of the TextComponents, with the height equal to the font size:

TextComponents {
    style: Style {
        size: Size {
            height: Val::Px(40.),
            ..Default::default()
        },
        ..Default::default()
    },
    text: Text {
        value: "Text example",
        font,
        style: TextStyle {
            color: Color::WHITE,
            font_size: 40.,
        },
    },
    ..Default::default()
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

hollg picture hollg  路  13Comments

coolit picture coolit  路  22Comments

andreasterrius picture andreasterrius  路  27Comments

cart picture cart  路  80Comments

qarmin picture qarmin  路  28Comments