proof: Indic pack patterns reach words with joiners

With joiners now inside an Indic word, the Gujarati pack guard (the
Gujarati block only) turned a word with a ZWJ or ZWNJ away from its
pack, so a pack exception for it was skipped. Gujarati and Hindi now
check the script's letters, marks and joiners (indic::Script::is_letter),
as their rules do, and still need the pack to know the word.

CodeRabbit on #3905.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ruchirguitarandClaude Opus 5.5 committed 2026-11-27 22:27:05 +05:30
1 parent 8aff71b9f8
commit 7dff06d72b
2 files changed
+19 -4

No files matched your search

+7 -4
View File
@@ -242,9 +242,10 @@ fn composed_chars(core: &[char]) -> (Vec<char>, Vec<Option<usize>>) {
(nfc, starts)
}
/// Does a pack's `pats` hyphenate `core` in `lang`? Russian, Bulgarian, Turkish and Gujarati: a
/// word in their script (the guard their rules use) whose letters the patterns know, so a word with a
/// letter the pack never mentions goes on to the fallback rules. Polish, Portuguese, Italian
/// Does a pack's `pats` hyphenate `core` in `lang`? Russian, Bulgarian, Turkish, Gujarati and
/// Hindi: a word in their script (the guard their rules use; for Gujarati and Hindi, the script's
/// letters and marks and the joiners inside a conjunct, [`crate::indic`]) whose letters the
/// patterns know, so a word with a letter the pack never mentions goes on to the fallback rules. Polish, Portuguese, Italian
/// and German: every word, as their embedded patterns do. Any other language: a word whose letters
/// the patterns know.
fn pack_patterns_fit(lang: ProofLang, pats: &Patterns, core: &[char]) -> bool {
@@ -253,7 +254,9 @@ fn pack_patterns_fit(lang: ProofLang, pats: &Patterns, core: &[char]) -> bool {
ProofLang::Bg => core.iter().all(|&c| crate::bg::is_letter(c)) && pack_knows(pats, core),
ProofLang::Tr => core.iter().all(|&c| crate::tr::hyphen::is_letter(c)) && pack_knows(pats, core),
ProofLang::Pl | ProofLang::Pt | ProofLang::It | ProofLang::De => true,
ProofLang::Gu => core.iter().all(|&c| crate::gu::is_gujarati_char(c)) && pack_knows(pats, core),
ProofLang::Gu | ProofLang::Hi => {
crate::indic::Script::of(lang).is_some_and(|s| core.iter().all(|&c| s.is_letter(c))) && pack_knows(pats, core)
}
_ => pats.values(core).is_some(),
}
}
+12
View File
@@ -195,6 +195,18 @@ fn gujarati_pack_patterns_fit_checks_script_and_exceptions() {
assert!(!pack_patterns_fit(ProofLang::Gu, &pats, &en_word));
}
/// CodeRabbit on craft-libs#3905: a word with a joiner in a conjunct still reaches its pack's
/// exception word (here: no break at all), in Gujarati and Hindi.
#[test]
fn indic_pack_exceptions_reach_words_with_joiners() {
for (lang, word) in [(ProofLang::Gu, "પુસ્\u{200D}તક"), (ProofLang::Hi, "पुस्\u{200D}तक")] {
let pats = Patterns::parse(&format!("1ક 1क \\hyphenation{{{word}}}"));
let core: Vec<char> = word.chars().collect();
assert!(pack_patterns_fit(lang, &pats, &core), "{lang:?}");
assert_eq!(core_breaks_patterns(&pats, &core), (vec![], Source::Dictionary), "{lang:?}");
}
}
/// storytold/vectorcraft#4947: Gujarati text breaks between aksharas, within the paragraph's
/// limits, where it used to fall to the English rules and get no break at all; a Latin word in
/// a Gujarati run is still hyphenated as English.