Skip to content

Commit 396aff9

Browse files
authored
Remove bevy_ui's "bevy_text" feature (#15951)
# Objective Remove `bevy-ui`'s non-functional "bevy_text" feature. Fixes #15900 ## Solution Remove all the "bevy_text" cfg gates. I tried to fix it at first but couldn't figure it out. I'll happily withdraw this in favour of another PR that gets the feature gate working.
1 parent ab79763 commit 396aff9

File tree

8 files changed

+21
-78
lines changed

8 files changed

+21
-78
lines changed

crates/bevy_dev_tools/Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev" }
3232
bevy_render = { path = "../bevy_render", version = "0.15.0-dev" }
3333
bevy_time = { path = "../bevy_time", version = "0.15.0-dev" }
3434
bevy_transform = { path = "../bevy_transform", version = "0.15.0-dev" }
35-
bevy_ui = { path = "../bevy_ui", version = "0.15.0-dev", features = [
36-
"bevy_text",
37-
] }
35+
bevy_text = { path = "../bevy_text", version = "0.15.0-dev" }
36+
bevy_ui = { path = "../bevy_ui", version = "0.15.0-dev" }
3837
bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" }
3938
bevy_window = { path = "../bevy_window", version = "0.15.0-dev" }
40-
bevy_text = { path = "../bevy_text", version = "0.15.0-dev" }
4139
bevy_state = { path = "../bevy_state", version = "0.15.0-dev" }
4240

4341
# other

crates/bevy_ui/src/layout/mod.rs

+12-25
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ use bevy_window::{PrimaryWindow, Window, WindowScaleFactorChanged};
2121
use derive_more::derive::{Display, Error, From};
2222
use ui_surface::UiSurface;
2323

24-
#[cfg(feature = "bevy_text")]
2524
use bevy_text::ComputedTextBlock;
26-
#[cfg(feature = "bevy_text")]
25+
2726
use bevy_text::CosmicFontSystem;
2827

2928
mod convert;
@@ -135,8 +134,8 @@ pub fn ui_layout_system(
135134
Option<&Outline>,
136135
Option<&ScrollPosition>,
137136
)>,
138-
#[cfg(feature = "bevy_text")] mut buffer_query: Query<&mut ComputedTextBlock>,
139-
#[cfg(feature = "bevy_text")] mut font_system: ResMut<CosmicFontSystem>,
137+
mut buffer_query: Query<&mut ComputedTextBlock>,
138+
mut font_system: ResMut<CosmicFontSystem>,
140139
) {
141140
let UiLayoutSystemBuffers {
142141
interned_root_nodes,
@@ -277,7 +276,6 @@ with UI components as a child of an entity without UI components, your UI layout
277276
}
278277
});
279278

280-
#[cfg(feature = "bevy_text")]
281279
let text_buffers = &mut buffer_query;
282280
// clean up removed nodes after syncing children to avoid potential panic (invalid SlotMap key used)
283281
ui_surface.remove_entities(removed_components.removed_nodes.read());
@@ -292,14 +290,7 @@ with UI components as a child of an entity without UI components, your UI layout
292290
for (camera_id, mut camera) in camera_layout_info.drain() {
293291
let inverse_target_scale_factor = camera.scale_factor.recip();
294292

295-
ui_surface.compute_camera_layout(
296-
camera_id,
297-
camera.size,
298-
#[cfg(feature = "bevy_text")]
299-
text_buffers,
300-
#[cfg(feature = "bevy_text")]
301-
&mut font_system.0,
302-
);
293+
ui_surface.compute_camera_layout(camera_id, camera.size, text_buffers, &mut font_system.0);
303294

304295
for root in &camera.root_nodes {
305296
update_uinode_geometry_recursive(
@@ -549,11 +540,11 @@ mod tests {
549540
world.init_resource::<Events<AssetEvent<Image>>>();
550541
world.init_resource::<Assets<Image>>();
551542
world.init_resource::<ManualTextureViews>();
552-
#[cfg(feature = "bevy_text")]
543+
553544
world.init_resource::<bevy_text::TextPipeline>();
554-
#[cfg(feature = "bevy_text")]
545+
555546
world.init_resource::<bevy_text::CosmicFontSystem>();
556-
#[cfg(feature = "bevy_text")]
547+
557548
world.init_resource::<bevy_text::SwashCache>();
558549

559550
// spawn a dummy primary window and camera
@@ -1190,11 +1181,11 @@ mod tests {
11901181
world.init_resource::<Events<AssetEvent<Image>>>();
11911182
world.init_resource::<Assets<Image>>();
11921183
world.init_resource::<ManualTextureViews>();
1193-
#[cfg(feature = "bevy_text")]
1184+
11941185
world.init_resource::<bevy_text::TextPipeline>();
1195-
#[cfg(feature = "bevy_text")]
1186+
11961187
world.init_resource::<bevy_text::CosmicFontSystem>();
1197-
#[cfg(feature = "bevy_text")]
1188+
11981189
world.init_resource::<bevy_text::SwashCache>();
11991190

12001191
// spawn a dummy primary window and camera
@@ -1262,10 +1253,8 @@ mod tests {
12621253
fn test_system(
12631254
params: In<TestSystemParam>,
12641255
mut ui_surface: ResMut<UiSurface>,
1265-
#[cfg(feature = "bevy_text")] mut computed_text_block_query: Query<
1266-
&mut bevy_text::ComputedTextBlock,
1267-
>,
1268-
#[cfg(feature = "bevy_text")] mut font_system: ResMut<bevy_text::CosmicFontSystem>,
1256+
mut computed_text_block_query: Query<&mut bevy_text::ComputedTextBlock>,
1257+
mut font_system: ResMut<bevy_text::CosmicFontSystem>,
12691258
) {
12701259
ui_surface.upsert_node(
12711260
&LayoutContext::TEST_CONTEXT,
@@ -1277,9 +1266,7 @@ mod tests {
12771266
ui_surface.compute_camera_layout(
12781267
params.camera_entity,
12791268
UVec2::new(800, 600),
1280-
#[cfg(feature = "bevy_text")]
12811269
&mut computed_text_block_query,
1282-
#[cfg(feature = "bevy_text")]
12831270
&mut font_system.0,
12841271
);
12851272
}

crates/bevy_ui/src/layout/ui_surface.rs

+2-26
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,8 @@ impl UiSurface {
203203
&mut self,
204204
camera: Entity,
205205
render_target_resolution: UVec2,
206-
#[cfg(feature = "bevy_text")] buffer_query: &'a mut bevy_ecs::prelude::Query<
207-
&mut bevy_text::ComputedTextBlock,
208-
>,
209-
#[cfg(feature = "bevy_text")] font_system: &'a mut bevy_text::cosmic_text::FontSystem,
206+
buffer_query: &'a mut bevy_ecs::prelude::Query<&mut bevy_text::ComputedTextBlock>,
207+
font_system: &'a mut bevy_text::cosmic_text::FontSystem,
210208
) {
211209
let Some(camera_root_nodes) = self.camera_roots.get(&camera) else {
212210
return;
@@ -229,7 +227,6 @@ impl UiSurface {
229227
-> taffy::Size<f32> {
230228
context
231229
.map(|ctx| {
232-
#[cfg(feature = "bevy_text")]
233230
let buffer = get_text_buffer(
234231
crate::widget::TextMeasure::needs_buffer(
235232
known_dimensions.height,
@@ -244,12 +241,8 @@ impl UiSurface {
244241
height: known_dimensions.height,
245242
available_width: available_space.width,
246243
available_height: available_space.height,
247-
#[cfg(feature = "bevy_text")]
248244
font_system,
249-
#[cfg(feature = "bevy_text")]
250245
buffer,
251-
#[cfg(not(feature = "bevy_text"))]
252-
font_system: core::marker::PhantomData,
253246
},
254247
style,
255248
);
@@ -298,7 +291,6 @@ impl UiSurface {
298291
}
299292
}
300293

301-
#[cfg(feature = "bevy_text")]
302294
fn get_text_buffer<'a>(
303295
needs_buffer: bool,
304296
ctx: &mut NodeMeasure,
@@ -705,20 +697,4 @@ mod tests {
705697
"expected root node child count to be 1"
706698
);
707699
}
708-
709-
#[test]
710-
#[cfg(not(feature = "bevy_text"))]
711-
fn test_compute_camera_layout() {
712-
let mut ui_surface = UiSurface::default();
713-
let camera_entity = Entity::from_raw(0);
714-
let root_node_entity = Entity::from_raw(1);
715-
let style = Style::default();
716-
717-
ui_surface.upsert_node(&LayoutContext::TEST_CONTEXT, root_node_entity, &style, None);
718-
719-
ui_surface.compute_camera_layout(camera_entity, UVec2::new(800, 600));
720-
721-
let taffy_node = ui_surface.entity_to_taffy.get(&root_node_entity).unwrap();
722-
assert!(ui_surface.taffy.layout(*taffy_node).is_ok());
723-
}
724700
}

crates/bevy_ui/src/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub mod picking_backend;
2222

2323
use bevy_derive::{Deref, DerefMut};
2424
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
25-
#[cfg(feature = "bevy_text")]
2625
mod accessibility;
2726
mod focus;
2827
mod geometry;
@@ -46,11 +45,9 @@ use widget::UiImageSize;
4645
///
4746
/// This includes the most common types in this crate, re-exported for your convenience.
4847
pub mod prelude {
49-
#[cfg(feature = "bevy_text")]
5048
#[allow(deprecated)]
5149
#[doc(hidden)]
5250
pub use crate::widget::TextBundle;
53-
#[cfg(feature = "bevy_text")]
5451
#[doc(hidden)]
5552
pub use crate::widget::{Text, TextUiReader, TextUiWriter};
5653
#[doc(hidden)]
@@ -183,7 +180,6 @@ impl Plugin for UiPlugin {
183180
.in_set(UiSystem::Layout)
184181
.before(TransformSystem::TransformPropagate);
185182

186-
#[cfg(feature = "bevy_text")]
187183
let ui_layout_system_config = ui_layout_system_config
188184
// Text and Text2D operate on disjoint sets of entities
189185
.ambiguous_with(bevy_text::update_text2d_layout)
@@ -213,7 +209,6 @@ impl Plugin for UiPlugin {
213209
),
214210
);
215211

216-
#[cfg(feature = "bevy_text")]
217212
build_text_interop(app);
218213

219214
build_ui_render(app);
@@ -231,8 +226,6 @@ impl Plugin for UiPlugin {
231226
}
232227
}
233228

234-
/// A function that should be called from [`UiPlugin::build`] when [`bevy_text`] is enabled.
235-
#[cfg(feature = "bevy_text")]
236229
fn build_text_interop(app: &mut App) {
237230
use crate::widget::TextNodeFlags;
238231
use bevy_text::TextLayoutInfo;

crates/bevy_ui/src/measurement.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ pub use taffy::style::AvailableSpace;
66

77
use crate::widget::ImageMeasure;
88

9-
#[cfg(feature = "bevy_text")]
109
use crate::widget::TextMeasure;
1110

1211
impl core::fmt::Debug for ContentSize {
@@ -20,13 +19,8 @@ pub struct MeasureArgs<'a> {
2019
pub height: Option<f32>,
2120
pub available_width: AvailableSpace,
2221
pub available_height: AvailableSpace,
23-
#[cfg(feature = "bevy_text")]
2422
pub font_system: &'a mut bevy_text::cosmic_text::FontSystem,
25-
#[cfg(feature = "bevy_text")]
2623
pub buffer: Option<&'a mut bevy_text::ComputedTextBlock>,
27-
// When `bevy_text` is disabled, use `PhantomData` in order to keep lifetime in type signature.
28-
#[cfg(not(feature = "bevy_text"))]
29-
pub font_system: core::marker::PhantomData<&'a mut ()>,
3024
}
3125

3226
/// A `Measure` is used to compute the size of a ui node
@@ -42,7 +36,7 @@ pub trait Measure: Send + Sync + 'static {
4236
/// by wrapping them in a closure and a Custom variant that allows arbitrary measurement closures if required.
4337
pub enum NodeMeasure {
4438
Fixed(FixedMeasure),
45-
#[cfg(feature = "bevy_text")]
39+
4640
Text(TextMeasure),
4741
Image(ImageMeasure),
4842
Custom(Box<dyn Measure>),
@@ -52,7 +46,7 @@ impl Measure for NodeMeasure {
5246
fn measure(&mut self, measure_args: MeasureArgs, style: &taffy::Style) -> Vec2 {
5347
match self {
5448
NodeMeasure::Fixed(fixed) => fixed.measure(measure_args, style),
55-
#[cfg(feature = "bevy_text")]
49+
5650
NodeMeasure::Text(text) => text.measure(measure_args, style),
5751
NodeMeasure::Image(image) => image.measure(measure_args, style),
5852
NodeMeasure::Custom(custom) => custom.measure(measure_args, style),

crates/bevy_ui/src/render/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use bevy_render::{
4040
};
4141
use bevy_sprite::TextureAtlasLayout;
4242
use bevy_sprite::{BorderRect, ImageScaleMode, SpriteAssetEvents, TextureAtlas};
43-
#[cfg(feature = "bevy_text")]
43+
4444
use bevy_text::{ComputedTextBlock, PositionedGlyph, TextColor, TextLayoutInfo};
4545
use bevy_transform::components::GlobalTransform;
4646
use bevy_utils::HashMap;
@@ -112,7 +112,6 @@ pub fn build_ui_render(app: &mut App) {
112112
extract_uinode_background_colors.in_set(RenderUiSystem::ExtractBackgrounds),
113113
extract_uinode_images.in_set(RenderUiSystem::ExtractImages),
114114
extract_uinode_borders.in_set(RenderUiSystem::ExtractBorders),
115-
#[cfg(feature = "bevy_text")]
116115
extract_text_sections.in_set(RenderUiSystem::ExtractText),
117116
),
118117
)
@@ -584,7 +583,6 @@ pub fn extract_default_ui_camera_view(
584583
transparent_render_phases.retain(|entity, _| live_entities.contains(entity));
585584
}
586585

587-
#[cfg(feature = "bevy_text")]
588586
#[allow(clippy::too_many_arguments)]
589587
pub fn extract_text_sections(
590588
mut commands: Commands,

crates/bevy_ui/src/widget/image.rs

-3
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ impl Measure for ImageMeasure {
8787
}
8888
}
8989

90-
#[cfg(feature = "bevy_text")]
9190
type UpdateImageFilter = (With<Node>, Without<crate::prelude::Text>);
92-
#[cfg(not(feature = "bevy_text"))]
93-
type UpdateImageFilter = With<Node>;
9491

9592
/// Updates content size of the node based on the image provided
9693
pub fn update_image_content_size_system(

crates/bevy_ui/src/widget/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
mod button;
44
mod image;
55
mod label;
6-
#[cfg(feature = "bevy_text")]
6+
77
mod text;
88

99
pub use button::*;
1010
pub use image::*;
1111
pub use label::*;
12-
#[cfg(feature = "bevy_text")]
12+
1313
pub use text::*;

0 commit comments

Comments
 (0)