expose complex-scripts feature (#24094)#24683
Conversation
|
Welcome, new contributor! Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨ |
…ne#24094) Update generated cargo features doc
|
The previous commit is a squash of all commits. It was also intended to re-trigger the CI that had failed due to a network error. |
There was a problem hiding this comment.
Pull request overview
This PR adds an opt-in complex_script_segmentation Cargo feature to the bevy feature graph (via bevy_text → bevy_internal → bevy) and documents it, enabling dictionary-based segmentation for complex scripts when requested.
Changes:
- Adds
complex_script_segmentationtobevy_textand forwards it toparley/complex-scripts. - Propagates
complex_script_segmentationthroughbevy_internaland the top-levelbevycrate features. - Documents the new feature in
docs/cargo_features.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/cargo_features.md | Documents the new complex_script_segmentation feature (but currently has a duplicated row that should be fixed). |
| crates/bevy_text/Cargo.toml | Adds a complex_script_segmentation feature that forwards to parley/complex-scripts. |
| crates/bevy_internal/Cargo.toml | Plumbs complex_script_segmentation through bevy_internal to bevy_text. |
| Cargo.toml | Exposes complex_script_segmentation as a top-level bevy feature via bevy_internal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Removed the parley version bump since it was already merged separately. |
Objective
Fixes #24094
Text containing complex scripts that lack explicit word boundaries (CJK, Thai, Khmer, Lao, Myanmar) is segmented by parley's lightweight segmenter, which emits a data error per layout:
parley added a
complex-scriptsCargo feature that switches to dictionary-based segmentation, but it was not reachable from Bevy.Solution
complex_script_segmentationfeature tobevy_textthat forwards toparley/complex-scripts, propagated throughbevy_internalandbevy. It is off by default because the bundled segmentation dictionary increases binary size.This supplies the segmentation data and enables dictionary-based word segmentation; it does not change CJK line-break positions, which ICU keeps permissive by design.
Testing
cargo build -p bevy_text -p bevy_ui -p bevy_ui_widgets, with default features and with--features complex_script_segmentation.cargo tree -e features -i parleyconfirms parley'scomplex-scriptsfeature is only enabled whencomplex_script_segmentationis requested (not pulled in by any default/collection feature).Text2dexample with a Japanese string in a width-bounded box (TextBounds,LineBreak::WordBoundary) underRUST_LOG=warn:No segmentation model for language: jaerror is logged.--features complex_script_segmentation: the error is gone.cargo run -p ci(lints + compile + tests). One unrelated local failure:bevy_ecs ... filtered_backtrace_test, which also fails on main on my machine (an environment-dependent backtrace-symbolization test, unrelated to this PR).