Skip to content

Commit 1092adc

Browse files
committed
doc fixes; system ambiguity fixes
1 parent cf90e1c commit 1092adc

File tree

11 files changed

+29
-24
lines changed

11 files changed

+29
-24
lines changed

crates/bevy_text/src/font_atlas_set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ pub struct FontAtlasKey(pub u32, pub FontSmoothing);
6060
/// A `FontAtlasSet` is an [`Asset`].
6161
///
6262
/// There is one `FontAtlasSet` for each font:
63-
/// - When a [`Font`] is loaded as an asset and then used in [`Text`](crate::Text),
63+
/// - When a [`Font`] is loaded as an asset and then used in [`TextStyle`](crate::TextStyle),
6464
/// a `FontAtlasSet` asset is created from a weak handle to the `Font`.
65-
/// - ~When a font is loaded as a system font, and then used in [`Text`](crate::Text),
65+
/// - ~When a font is loaded as a system font, and then used in [`TextStyle`](crate::TextStyle),
6666
/// a `FontAtlasSet` asset is created and stored with a strong handle to the `FontAtlasSet`.~
6767
/// (*Note that system fonts are not currently supported by the `TextPipeline`.*)
6868
///

crates/bevy_text/src/glyph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use bevy_sprite::TextureAtlasLayout;
1313
/// Used in [`TextPipeline::queue_text`](crate::TextPipeline::queue_text) and [`crate::TextLayoutInfo`] for rendering glyphs.
1414
#[derive(Debug, Clone, Reflect)]
1515
pub struct PositionedGlyph {
16-
/// The position of the glyph in the [`Text`](crate::Text)'s bounding box.
16+
/// The position of the glyph in the text block's bounding box.
1717
pub position: Vec2,
1818
/// The width and height of the glyph in logical pixels.
1919
pub size: Vec2,

crates/bevy_text/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//!
1515
//! The [`TextPipeline`] resource does all of the heavy lifting for rendering text.
1616
//!
17-
//! [`Text`] is first measured by creating a [`TextMeasureInfo`] in [`TextPipeline::create_text_measure`],
17+
//! UI `Text` is first measured by creating a [`TextMeasureInfo`] in [`TextPipeline::create_text_measure`],
1818
//! which is called by the `measure_text_system` system of `bevy_ui`.
1919
//!
2020
//! Note that text measurement is only relevant in a UI context.
@@ -23,7 +23,7 @@
2323
//! or [`text2d::update_text2d_layout`] system (in a 2d world space context)
2424
//! passes it into [`TextPipeline::queue_text`], which:
2525
//!
26-
//! 1. creates a [`Buffer`](cosmic_text::Buffer) from the [`TextSection`]s, generating new [`FontAtlasSet`]s if necessary.
26+
//! 1. updates a [`Buffer`](cosmic_text::Buffer) from the [`TextSpan`]s, generating new [`FontAtlasSet`]s if necessary.
2727
//! 2. iterates over each glyph in the [`Buffer`](cosmic_text::Buffer) to create a [`PositionedGlyph`],
2828
//! retrieving glyphs from the cache, or rasterizing to a [`FontAtlas`] if necessary.
2929
//! 3. [`PositionedGlyph`]s are stored in a [`TextLayoutInfo`],
@@ -92,7 +92,7 @@ pub const DEFAULT_FONT_DATA: &[u8] = include_bytes!("FiraMono-subset.ttf");
9292
pub struct TextPlugin;
9393

9494
/// Text is rendered for two different view projections;
95-
/// 2-dimensional text ([`Text2dBundle`]) is rendered in "world space" with a `BottomToTop` Y-axis,
95+
/// 2-dimensional text ([`Text2d`]) is rendered in "world space" with a `BottomToTop` Y-axis,
9696
/// while UI is rendered with a `TopToBottom` Y-axis.
9797
/// This matters for text because the glyph positioning is different in either layout.
9898
/// For `TopToBottom`, 0 is the top of the text, while for `BottomToTop` 0 is the bottom.

crates/bevy_text/src/pipeline.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct FontFaceInfo {
6060
family_name: Arc<str>,
6161
}
6262

63-
/// The `TextPipeline` is used to layout and render [`Text`](crate::Text).
63+
/// The `TextPipeline` is used to layout and render text blocks (see `Text`/[`Text2d`](crate::Text2d)).
6464
///
6565
/// See the [crate-level documentation](crate) for more information.
6666
#[derive(Default, Resource)]
@@ -383,9 +383,10 @@ impl TextPipeline {
383383
}
384384
}
385385

386-
/// Render information for a corresponding [`Text`](crate::Text) component.
386+
/// Render information for a corresponding text block.
387387
///
388-
/// Contains scaled glyphs and their size. Generated via [`TextPipeline::queue_text`].
388+
/// Contains scaled glyphs and their size. Generated via [`TextPipeline::queue_text`] when an entity has
389+
/// [`TextBlock`] and [`ComputedTextBlock`] components.
389390
#[derive(Component, Clone, Default, Debug, Reflect)]
390391
#[reflect(Component, Default, Debug)]
391392
pub struct TextLayoutInfo {
@@ -395,7 +396,7 @@ pub struct TextLayoutInfo {
395396
pub size: Vec2,
396397
}
397398

398-
/// Size information for a corresponding [`Text`](crate::Text) component.
399+
/// Size information for a corresponding [`ComputedTextBlock`] component.
399400
///
400401
/// Generated via [`TextPipeline::create_text_measure`].
401402
#[derive(Debug)]

crates/bevy_text/src/text.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ impl ComputedTextBlock {
7676

7777
/// Indicates if the text needs to be refreshed in [`TextLayoutInfo`].
7878
///
79-
/// Updated automatically by [`detect_text_needs_rerender`](crate::detect_text_needs_rerender) and cleared
80-
/// by [`TextPipeline`] methods.
79+
/// Updated automatically by [`detect_text_needs_rerender`] and cleared
80+
/// by [`TextPipeline`](crate::TextPipeline) methods.
8181
pub fn needs_rerender(&self) -> bool {
8282
self.needs_rerender
8383
}
@@ -99,7 +99,7 @@ impl Default for ComputedTextBlock {
9999
/// spans associated with a text block are collected into [`ComputedTextBlock`] for layout, and then inserted
100100
/// to [`TextLayoutInfo`] for rendering.
101101
///
102-
/// See [`Text2d`] for the core component of 2d text, and `Text` in `bevy_ui` for UI text.
102+
/// See [`Text2d`](crate::Text2d) for the core component of 2d text, and `Text` in `bevy_ui` for UI text.
103103
#[derive(Component, Debug, Copy, Clone, Default, Reflect)]
104104
#[reflect(Component, Default, Debug)]
105105
#[require(ComputedTextBlock, TextLayoutInfo)]
@@ -349,8 +349,8 @@ pub enum FontSmoothing {
349349

350350
/// System that detects changes to text blocks and sets `ComputedTextBlock::should_rerender`.
351351
///
352-
/// Generic over the root text component and text span component. For example, [`Text2d`]/[`TextSpan`] for 2d or
353-
/// `Text`/[`TextSpan`] for UI.
352+
/// Generic over the root text component and text span component. For example, [`Text2d`](crate::Text2d)/[`TextSpan`] for
353+
/// 2d or `Text`/[`TextSpan`] for UI.
354354
pub fn detect_text_needs_rerender<Root: Component>(
355355
changed_roots: Query<
356356
Entity,

crates/bevy_text/src/text2d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use bevy_window::{PrimaryWindow, Window, WindowScaleFactorChanged};
3838
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/2d/text2d.rs)
3939
///
4040
/// The string in this component is the first 'text span' in a hierarchy of text spans that are collected into
41-
/// a [`TextBlock`]. See [`TextSpan2d`] for the component used by children of entities with [`Text2d`].
41+
/// a [`TextBlock`]. See [`TextSpan`](crate::TextSpan) for the component used by children of entities with [`Text2d`].
4242
///
4343
/// With `Text2d` the `justify` field of [`TextBlock`] only affects the internal alignment of a block of text and not its
4444
/// relative position, which is controlled by the [`Anchor`] component.

crates/bevy_text/src/text_access.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ impl TextIterScratch {
4242
}
4343
}
4444

45-
/// System parameter for reading text spans in a [`TextBlock`].
45+
/// System parameter for reading text spans in a [`TextBlock`](crate::TextBlock).
4646
///
4747
/// `R` is the root text component, and `S` is the text span component on children.
4848
#[derive(SystemParam)]
4949
pub struct TextReader<'w, 's, R: TextRoot> {
50-
scratch: ResMut<'w, TextIterScratch>,
50+
// This is a local to avoid system ambiguities when TextReaders run in parallel.
51+
scratch: Local<'s, TextIterScratch>,
5152
roots: Query<'w, 's, (&'static R, &'static TextStyle, Option<&'static Children>)>,
5253
spans: Query<
5354
'w,
@@ -108,7 +109,7 @@ impl<'w, 's, R: TextRoot> TextReader<'w, 's, R> {
108109
}
109110
}
110111

111-
/// Iterator returned by [`TextReader::iter`] and [`TextWriter::iter`].
112+
/// Iterator returned by [`TextReader::iter`].
112113
///
113114
/// Iterates all spans in a text block according to hierarchy traversal order.
114115
/// Does *not* flatten interspersed ghost nodes. Only contiguous spans are traversed.
@@ -183,11 +184,12 @@ impl<'a, R: TextRoot> Drop for TextSpanIter<'a, R> {
183184
}
184185
}
185186

186-
/// System parameter for reading and writing text spans in a [`TextBlock`].
187+
/// System parameter for reading and writing text spans in a [`TextBlock`](crate::TextBlock).
187188
///
188189
/// `R` is the root text component, and `S` is the text span component on children.
189190
#[derive(SystemParam)]
190191
pub struct TextWriter<'w, 's, R: TextRoot> {
192+
// This is a resource because two TextWriters can't run in parallel.
191193
scratch: ResMut<'w, TextIterScratch>,
192194
roots: Query<'w, 's, (&'static mut R, &'static mut TextStyle), Without<TextSpan>>,
193195
spans: Query<'w, 's, (&'static mut TextSpan, &'static mut TextStyle), Without<R>>,

crates/bevy_ui/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
//! This crate contains Bevy's UI system, which can be used to create UI for both 2D and 3D games
1010
//! # Basic usage
11-
//! Spawn UI elements with [`node_bundles::ButtonBundle`], [`node_bundles::ImageBundle`], [`node_bundles::TextBundle`] and [`node_bundles::NodeBundle`]
11+
//! Spawn UI elements with [`node_bundles::ButtonBundle`], [`node_bundles::ImageBundle`], [`Text`](prelude::Text) and [`node_bundles::NodeBundle`]
1212
//! This UI is laid out with the Flexbox and CSS Grid layout models (see <https://cssreference.io/flexbox/>)
1313
1414
pub mod measurement;
@@ -238,6 +238,8 @@ fn build_text_interop(app: &mut App) {
238238
)
239239
.chain()
240240
.in_set(UiSystem::Prepare)
241+
// Text and Text2d are independent.
242+
.ambiguous_with(bevy_text::detect_text_needs_rerender::<bevy_text::Text2d>)
241243
// Potential conflict: `Assets<Image>`
242244
// Since both systems will only ever insert new [`Image`] assets,
243245
// they will never observe each other's effects.

crates/bevy_ui/src/node_bundles.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use bevy_transform::prelude::{GlobalTransform, Transform};
1313
///
1414
/// Contains the [`Node`] component and other components required to make a container.
1515
///
16-
/// See [`node_bundles`](crate::node_bundles) for more specialized bundles like [`TextBundle`].
16+
/// See [`node_bundles`](crate::node_bundles) for more specialized bundles like [`ImageBundle`].
1717
#[derive(Bundle, Clone, Debug, Default)]
1818
pub struct NodeBundle {
1919
/// Describes the logical size of the node

crates/bevy_ui/src/ui_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2520,7 +2520,7 @@ impl<'w, 's> DefaultUiCamera<'w, 's> {
25202520
/// Marker for controlling whether Ui is rendered with or without anti-aliasing
25212521
/// in a camera. By default, Ui is always anti-aliased.
25222522
///
2523-
/// **Note:** This does not affect text anti-aliasing. For that, use the `font_smoothing` property of the [`bevy_text::Text`] component.
2523+
/// **Note:** This does not affect text anti-aliasing. For that, use the `font_smoothing` property of the [`TextStyle`](bevy_text::TextStyle) component.
25242524
///
25252525
/// ```
25262526
/// use bevy_core_pipeline::prelude::*;

crates/bevy_ui/src/widget/text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl Default for TextNodeFlags {
5252
/// Adding [`Text`] to an entity will pull in required components for setting up a UI text node.
5353
///
5454
/// The string in this component is the first 'text span' in a hierarchy of text spans that are collected into
55-
/// a [`TextBlock`]. See [`TextSpan`] for the component used by children of entities with [`Text`].
55+
/// a [`TextBlock`]. See [`TextSpan`](bevy_text::TextSpan) for the component used by children of entities with [`Text`].
5656
///
5757
/// Note that [`Transform`] on this entity is managed automatically by the UI layout system.
5858
///

0 commit comments

Comments
 (0)