bevy/crates/bevy_text/src
Nicola Papale afcb1fee90
Cleanup some bevy_text pipeline.rs (#9111)
## Objective

- `bevy_text/src/pipeline.rs` had some crufty code.

## Solution

Remove the cruft.

- `&mut self` argument was unused by
`TextPipeline::create_text_measure`, so we replace it with a constructor
`TextMeasureInfo::from_text`.
- We also pass a `&Text` to `from_text` since there is no reason to
split the struct before passing it as argument.
- from_text also checks beforehand that every Font exist in the
Assets<Font>. This allows rust to skip the drop code on the Vecs we
create in the method, since there is no early exit.
- We also remove the scaled_fonts field on `TextMeasureInfo`. This
avoids an additional allocation. We can re-use the font on `fonts`
instead in `compute_size`. Building a `ScaledFont` seems fairly cheap,
when looking at the ab_glyph internals.
- We also implement ToSectionText on TextMeasureSection, this let us
skip creating a whole new Vec each time we call compute_size.
- This let us remove compute_size_from_section_text, since its only
purpose was to not have to allocate the Vec we just made redundant.
- Make some immutabe `Vec<T>` into `Box<[T]>` and `String` into
`Box<str>`
- `{min,max}_width_content_size` fields of `TextMeasureInfo` have name
`width` in them, yet the contain information on both width and height.
- `TextMeasureInfo::linebreak_behaviour`  -> `linebreak_behavior`

## Migration Guide

- The `ResMut<TextPipeline>` argument to `measure_text_system` doesn't
exist anymore. If you were calling this system manually, you should
remove the argument.
- The `{min,max}_width_content_size` fields of `TextMeasureInfo` are
renamed to `min` and `max` respectively
- Other changes to `TextMeasureInfo` may also break your code if you
were manually building it. Please consider using the new
`TextMeasureInfo::from_text` to build one instead.
- `TextPipeline::create_text_measure` has been removed in favor of
`TextMeasureInfo::from_text`
2023-08-28 16:46:16 +00:00
..
error.rs Remove TextError::ExceedMaxTextAtlases(usize) variant (#6796) 2022-12-05 23:23:16 +00:00
FiraMono-subset.ttf add a default font (#8445) 2023-04-21 22:30:18 +00:00
font_atlas_set.rs reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
font_atlas.rs Replace old renderer with new renderer (#3312) 2021-12-14 03:58:23 +00:00
font_loader.rs Add support for OTF fonts (#1200) 2021-01-03 12:10:23 -08:00
font.rs reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
glyph_brush.rs Cleanup some bevy_text pipeline.rs (#9111) 2023-08-28 16:46:16 +00:00
lib.rs Improve font size related docs (#9320) 2023-08-03 07:48:11 +00:00
pipeline.rs Cleanup some bevy_text pipeline.rs (#9111) 2023-08-28 16:46:16 +00:00
text2d.rs Reorder render sets, refactor bevy_sprite to take advantage (#9236) 2023-08-27 14:33:49 +00:00
text.rs Cleanup some bevy_text pipeline.rs (#9111) 2023-08-28 16:46:16 +00:00