bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Text renamings

Open ickshonpe opened this issue 6 months ago • 1 comments

Objective

The names of some of the components in bevy_text are confusing and inconsistent:

  • TextLayoutInfo Contains the final computed text layout. The -Info suffix is redundant and potentially confusing.

  • TextLayout Holds the settings for text justification and line breaking. Not the layout.

  • ComputedTextBlock This holds the cosmic-text buffer. The name suggests that it contains the final result of a text relayout, but the buffer can be out-of-date until it is updated during the text schedule.

Solution

  • Rename
    • TextLayoutInfo -> ComputedTextLayout
    • ComputedTextBlock -> TextBuffer
  • Remove TextLayout.
  • Make JustifyText and LineBreak into components.
  • Require JustifyText and LineBreak on Text and Text2d.

Fixes #19467

ickshonpe avatar May 30 '25 19:05 ickshonpe

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-19444

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

github-actions[bot] avatar Jun 02 '25 12:06 github-actions[bot]

Just noting that this seems to be going in the opposite direction of a sentiment expressed here: https://github.com/bevyengine/bevy/discussions/15014#discussioncomment-10574459 with regard to the new LineBreak and JustifyText components.

I think this might merit more discussion to reduce potential churn. The main issue I am seeing with TextLayout at the moment is that I think LineHeight should be in there instead of in TextFont.

rparrett avatar Jun 12 '25 13:06 rparrett

Just noting that this seems to be going in the opposite direction of a sentiment expressed here: #15014 (comment) with regard to the new LineBreak and JustifyText components.

I think this might merit more discussion to reduce potential churn. The main issue I am seeing with TextLayout at the moment is that I think LineHeight should be in there instead of in TextFont.

Ah yeah this was heavily discussed there and also in https://github.com/bevyengine/bevy/pull/15591 and https://github.com/bevyengine/bevy/pull/15797, I wasn't aware of that. I think this needs review from the people involved in those discussions.

kristoff3r avatar Jun 12 '25 13:06 kristoff3r

I agree with ComputedTextLayout for consistency, but don't agree about changing ComputedTextBlock -> TextBuffer. The Computed prefix is a good pattern for marking components driven by bevy systems (like ComputedNode). ComputedTextBlock cannot be mutated outside bevy, so it should remain Computed.

Also, the fact ComputedTextBlock contains a buffer is an implementation detail that users almost never need to care about. So calling it a Buffer is less appropriate than TextBlock.

UkoeHB avatar Jul 01 '25 18:07 UkoeHB