Conversation
f68213f to
6822fc1
Compare
There was a problem hiding this comment.
Code Review
This pull request implements text hyphenation support by integrating the hyphenation crate and adding a hyphenate toggle to the TypesettingConfig. The implementation includes a new utility to insert soft hyphens into English text when a maximum width is specified. Feedback suggests improving the robustness of dictionary initialization to prevent potential panics and making the OverflowWrap::BreakWord setting conditional on the hyphenation toggle to avoid unintended layout changes for standard text.
| static EN_US_DICT: OnceLock<Standard> = OnceLock::new(); | ||
|
|
||
| fn get_dict_for_language(lang: Language) -> Option<&'static Standard> { | ||
| match lang { | ||
| Language::EnglishUS | Language::EnglishGB => EN_US_DICT | ||
| .get_or_init(|| Standard::from_embedded(Language::EnglishUS).expect("embed_all feature must be enabled")) | ||
| .into(), | ||
| _ => None, | ||
| } | ||
| } |
There was a problem hiding this comment.
Using expect during dictionary initialization will cause the application to panic if the hyphenation data fails to load (e.g., if the embed_all feature is missing or the binary data is corrupted). It is safer to use OnceLock<Option<Standard>> and handle the failure gracefully by logging an error and returning None. This allows the text to render without hyphenation instead of crashing the entire application.
static EN_US_DICT: OnceLock<Option<Standard>> = OnceLock::new();
fn get_dict_for_language(lang: Language) -> Option<&'static Standard> {
match lang {
Language::EnglishUS | Language::EnglishGB => EN_US_DICT
.get_or_init(|| {
Standard::from_embedded(Language::EnglishUS).map_err(|err| {
log::error!("Failed to load hyphenation dictionary: {err}");
err
}).ok()
})
.as_ref(),
_ => None,
}
}|
I have also tried manually inserting "-" at breaking, but it would be better to extend parley's support rather than mix implementaton. Screen.Recording.2026-04-09.at.2.12.42.AM.movScreen.Recording.2026-04-09.at.2.10.47.AM.mov |
|
Ideally we should break URLs or emails in a specific way but currently parley doesn't support it. |
|
@Annonnymmousss I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 11 files
Confidence score: 3/5
- There is a concrete backward-compatibility risk: inserting the new
hyphenateinput shifts positional indices, so existing saved graphs may misinterpret inputs when deserialized. - Severity is mid-range and user-impacting (graphs could load with incorrect input mapping), which keeps this at a moderate risk rather than a safe-to-merge 4/5.
- Pay close attention to
node-graph/nodes/gstd/src/text.rs- positionalVec<NodeInput>index shift affecting saved graphs.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="node-graph/nodes/gstd/src/text.rs">
<violation number="1" location="node-graph/nodes/gstd/src/text.rs:62">
P2: Inserting the new `hyphenate` input between existing parameters shifts positional input indices. Because node inputs are serialized in a positional `Vec<NodeInput>`, existing saved graphs may interpret the previous `separate_glyph_elements` input as `hyphenate` unless a migration handles the reindexing.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
2d7d6b9 to
c1cf558
Compare
Partially closes #2351
The hyphenation should ideally be merged only after parley implement hyphenation support (insertion of "-" on breaking points). Currently with Hyphenate crate we can break the words according to dictionary.
Screen.Recording.2026-04-09.at.3.34.58.AM.mov
Screen.Recording.2026-04-09.at.3.36.17.AM.mov