Skip to content

expose complex-scripts feature (#24094)#24683

Open
unclepomedev wants to merge 3 commits into
bevyengine:mainfrom
unclepomedev:main
Open

expose complex-scripts feature (#24094)#24683
unclepomedev wants to merge 3 commits into
bevyengine:mainfrom
unclepomedev:main

Conversation

@unclepomedev

@unclepomedev unclepomedev commented Jun 20, 2026

Copy link
Copy Markdown

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:

ICU4X data error: No segmentation model for language: ja

parley added a complex-scripts Cargo feature that switches to dictionary-based segmentation, but it was not reachable from Bevy.

Solution

  • Add an opt-in complex_script_segmentation feature to bevy_text that forwards to parley/complex-scripts, propagated through bevy_internal and bevy. 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 parley confirms parley's complex-scripts feature is only enabled when complex_script_segmentation is requested (not pulled in by any default/collection feature).
  • Ran a Text2d example with a Japanese string in a width-bounded box (TextBounds, LineBreak::WordBoundary) under RUST_LOG=warn:
    • default: the No segmentation model for language: ja error 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).
  • Tested on macOS (Apple Silicon).

@github-actions

Copy link
Copy Markdown
Contributor

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 ✨

@mnmaita mnmaita added C-Dependencies A change to the crates that Bevy depends on A-Text Rendering and layout for characters D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 22, 2026
@unclepomedev

Copy link
Copy Markdown
Author

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.

Copilot AI review requested due to automatic review settings July 7, 2026 08:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an opt-in complex_script_segmentation Cargo feature to the bevy feature graph (via bevy_textbevy_internalbevy) and documents it, enabling dictionary-based segmentation for complex scripts when requested.

Changes:

  • Adds complex_script_segmentation to bevy_text and forwards it to parley/complex-scripts.
  • Propagates complex_script_segmentation through bevy_internal and the top-level bevy crate 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.

Comment thread docs/cargo_features.md Outdated
Comment thread crates/bevy_text/Cargo.toml
@unclepomedev unclepomedev changed the title Bump parley from 0.9.0 to 0.10.0 and expose complex-scripts feature (#24094) expose complex-scripts feature (#24094) Jul 7, 2026
@unclepomedev

unclepomedev commented Jul 7, 2026

Copy link
Copy Markdown
Author

Removed the parley version bump since it was already merged separately.
Re-verified after resolving the merge conflict against current main: the No segmentation model for language: ja error still reproduces by default, and --features complex_script_segmentation still resolves it.
The current CI failure seems unrelated to this PR (filed as #24902)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Text Rendering and layout for characters C-Dependencies A change to the crates that Bevy depends on D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICU4X data error: No segmentation model for language: ja when updating CJK characters

3 participants