Repository navigation
fix(fonts): paragraph direction skips bidi isolates; harakat no longer block the Lam-Alef ligature - #1034
Conversation
…r block the Lam-Alef ligature (storytold#1033) base_rtl now ignores strong characters between an isolate initiator and its PDI (or the end, when unmatched), per UBA P2. presentation_forms looks past combining marks for the Alef after a Lam and emits the marks after the ligature. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the diff: the paragraph direction skips bidi isolates, and harakat no longer block the Lam-Alef ligature. The function that finds the first strong character used find_map over the characters and now, "as rule P2 requires", skips the characters between an isolate initiator and its matching PDI (or the end of the paragraph when there is no match). UAX #9 rule P2 does say that characters between an isolate initiator and its matching PDI are ignored when finding the first strong character, so this is the specified behaviour, and it matters for text like an isolated English name inside Arabic. Isolate nesting needs a depth counter and the unmatched-PDI case needs care (a PDI with no initiator is not an end of anything); I saw the doc comment and the start of the loop, not the counter. The second half of the title, harakat (Arabic diacritics) between Lam and Alef blocking the ligature, is in a part I did not read; a test with the Arabic string for "no" with a fatha between them would pin it. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
austin62jake
left a comment
There was a problem hiding this comment.
Approving. I merged it onto current main with seven other PRs (#1460, #1452, #1038, #1020, #1034, #1588, #1673, #1292). fmt, clippy and the web build pass, and 3188 of 3189 tests pass. The one failure is #1452's missing Chinese label.
Skipping characters inside an isolate (LRI/RLI/FSI…PDI, or to the end when unmatched) when finding the paragraph direction is rule P2. Letting harakat between lam and alef keep the ligature, staying after it in logical order, is how Arabic joins. It doesn't conflict with my #2618, which sets single-line TEXT's base direction explicitly.
FredApps
left a comment
There was a problem hiding this comment.
Reviewed c32c0f5e30eecdfe6dce20c5a0948eed4e4293fb. No findings in the complete one-file source review. The isolate-depth counter saturates at both ends, so nested/unmatched isolates and stray PDI controls are handled without underflow. The Lam–Alef lookahead skips combining marks and preserves their source indices and logical order. The new tests already cover nested/unmatched isolates, stray PDI, intervening harakat, word-medial joining and non-Alef boundaries. This supersedes my earlier partial review, which had not inspected those paths.
This is a review comment, not an approval: GitHub reports no checks for this head, and no local Rust tests were run because the available workspace is out of disk space. Please refresh the branch onto the current CI-enabled base and obtain a passing gate, or provide reproducible validation for this exact head. The missing validation is the remaining gap; I am not asking for duplicate tests that are already in the diff.
|
Same as #1273, CI never ran here, so I merged it onto current main ( |
Fixes #1033
Two fixes in
crates/fonts/src/bidi.rsonly.Causes and fixes
base_rtltook the first L/R/AL character anywhere, so"\u{2067}שלום\u{2069} abc"gaveSome(true). UBA P2 skips everything between an isolate initiator (LRI/RLI/FSI) and its matching PDI, or to the end of the paragraph when unmatched. It now tracks isolate depth (saturating, so a stray PDI is harmless) and only considers strong characters at depth 0. The example givesSome(false).presentation_formsrequired the Alef to be the next code point. Marks are transparent for joining (joining_formsalready skips them), so Lam + fatha + Alef kept two separate glyphs. After a Lam it now looks past combining marks for the Alef, emits the ligature, then the skipped marks (logical order, each with its own source index), then continues after the Alef. A non-mark between Lam and Alef still blocks the ligature. The scan only runs for a Lam.Tests (in
bidi.rs)paragraph_direction_skips_isolate_contents: the example, LRI/FSI variants, nested isolates, unmatched initiator, stray PDIs, no strong character outside the isolates, unchanged plain case.harakat_between_lam_and_alef_keep_the_ligature: Lam+fatha+Alef, medial with fatha+shadda, plain Lam+Alef unchanged, mark after the Alef, Lam+mark+non-Alef, Lam+mark at the end, non-mark between Lam and Alef.cargo test -p cadcraft-fonts --lib bidi, saw both tests fail, then restored the fixes.Commands that ran
All with a separate
CARGO_TARGET_DIR:cargo fmt -p cadcraft-fonts(a--checkfirst reported one wrapping diff in my code, now formatted)cargo clippy -p cadcraft-fonts --all-targets -- -D warnings: cleancargo test -p cadcraft-fonts: 55 unit + 9 integration tests passcargo test -p cadcraft-render: all passcargo xtask layers: OKcargo check --target wasm32-unknown-unknown -p cadcraft-fonts: OKNot run: the full
cargo xtask ciand workspace-wide builds/tests (shared machine; only the touched crate and its direct consumer were checked).Left out
shape_linesignature change inlib.rs, which collides with open PR In-window menu bar redesign: layout table, menu icons and keyboard access #961.mtext*: separate findings, another change is working inmtext.rs/mtext/para.rs; kept this PR to two small, independent fixes.🤖 Generated with Claude Code