[PR #4894] [CLOSED] Arabic shaping: the extended letters join like the base ones #5924

Closed
opened 2026-11-03 05:15:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4894
Author: @sirrayi
Created: 10/31/2026
Status: ❌ Closed

Base: main ← Head: fix/bidi-extended-letters


📝 Commits (2)

  • 04306df Arabic shaping: the extended letters join like the base ones
  • 4307b19 Merge main

📊 Changes

1 file changed (+102 additions, -2 deletions)

View changed files

📝 crates/horizon-client-render/src/bidi.rs (+102 -2)

📄 Description

🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi themselves.

What and why

Fixes #2796. Persian letters that do not exist in Arabic (پ چ ژ ک گ ی) were drawn isolated — "پ گ چ ژ"
where Persian renders "پگچژ" — although their neighbours joined them.

crates/horizon-client-render/src/bidi.rs hand-rolls ICU's ArabicShaping. JOINS classifies those
letters correctly; FORMS, the table that turns a letter into its joined presentation form, only listed
U+0622 to U+064A plus the lam-alef ligatures, and shape's Right | Dual arm ends in
FORMS.binary_search_by_key(…).ok().and_then(…).unwrap_or(c). So an extended letter fell through to its
isolated code point and never joined, even though its neighbours treated it as a joining letter.

FORMS now carries the presentation forms the Arabic Presentation Forms-B block gives those letters, in the
same isolated/final/initial/medial order the table already assumed (پ U+067E → U+FB56–FB59, چ U+0686 →
U+FB7A–FB7D, ژ U+0698 → U+FB8A–FB8B and no initial/medial because it is right-joining, ک U+06A9 →
U+FB8E–FB91, گ U+06AF → U+FB92–FB95, ی U+06CC → U+FBFC–FBFF, plus the other letters of U+0679–U+06D3 that
have a form). The extended letters the block has no presentation form for are left out and stay unchanged,
as before — a wrong row would draw a wrong glyph, which is worse than today. The table stays sorted, which
binary_search_by_key requires.

bidi.rs had no test module at all; it has six now.

This reverses a deliberate commit — please read before merging

8a5d7bb78 (2026-10-26, "Leave the extended Arabic letters unshaped, as ICU does") removed these exact
rows
from FORMS and wrote the comment I am deleting. So this change is a partial revert of a decision
someone made on purpose two days before the report, and it deserves a maintainer's check rather than my
judgement.

What I can and cannot support:

  • For the change: the report's screenshot, and Unicode's Arabic Presentation Forms-A/-B, which gives
    these letters initial/medial/final forms. Vanilla's renderer shapes right-to-left text through ICU4J, and
    ICU's shaping rules apply to every letter that has a presentation form, not only the Arabic-language ones.
  • Against it: 8a5d7bb78's message asserts the opposite about ICU, and I have no vanilla data on this
    machine
    — no jar, no decompiled sources, so tools/rea_vanilla.py cannot run here and I could not settle
    it. python3 tools/rea_vanilla.py class com.ibm.icu.text.ArabicShaping, or a one-line Java check of
    ArabicShaping.shape("پگچژ") against the pinned jar, decides it in a minute.
  • If the earlier claim was right, this belongs as a Horizon extra (better than vanilla for Persian) or not at
    all — not as a parity fix, and the Kind tick above is wrong for it.

One more thing a reviewer should know: 8a5d7bb78 changed two things, not one — besides the rows it narrowed
letter_of's presentation-forms range from 0xFB50..=0xFDFF | 0xFE70..=0xFEFC to 0xFE70..=0xFEFC. I
restore only the rows, because with the rows back the narrower letter_of still leaves already-shaped
extended forms alone, which is the idempotent behaviour. If the maintainer decides the full revert is right,
that range belongs in the same change and I can add it.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

The renderer's shaping mirrors ICU's ArabicShaping (u_shapeArabic, U_SHAPE_LETTERS_SHAPE), which the
file's own comment already names as its source. The presentation forms are the Unicode Arabic Presentation Forms-B block, which is a published table rather than a project's code.

The one point I could not check here, and which a reviewer should confirm: the file claimed ICU leaves the
extended letters unchanged, which is why they were missing. If that claim was right for the shaper vanilla
uses, this change is a deliberate divergence and belongs to Horizon's own font rather than to parity. The
report says the opposite of what that comment predicts, and the six tests pin the behaviour either way:
persian_letters_take_their_joined_forms (the reported word), right_joining_letters_take_no_initial_or_medial_form
(ژ), base_arabic_keeps_the_forms_it_had (control), lam_followed_by_an_alef_is_one_ligature,
the_forms_table_is_sorted_and_every_row_joins and left_to_right_text_keeps_its_order.

cargo test -p horizon-client-render --lib bidi → 6 passed.

Self-check

cargo fmt --all -- --check                                    ✅
cargo test -p horizon-client --bins <new test>                 1 passed; 0 failed
cargo clippy -p horizon-client --bins --tests -- -D warnings   ✅

python3 tools/pr_ready.py was not finished here: this machine has no prepared vanilla data
(.local/), so its harness half only lists what CI must run, and its workspace-wide passes compete for the
build cache with other work on the machine. CI's verify runs the workspace fmt/clippy/tests.

Screenshots

Players see it: a Persian chat line or sign joins instead of drawing isolated letters. I have no prepared
vanilla data on this machine, so I could not capture a before/after; the shaped code points are asserted
by the tests instead.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4894 **Author:** [@sirrayi](https://github.com/sirrayi) **Created:** 10/31/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/bidi-extended-letters` --- ### 📝 Commits (2) - [`04306df`](https://github.com/horizon-rust/horizon/commit/04306df2663e29a48af7ffa11077dcacabd8784b) Arabic shaping: the extended letters join like the base ones - [`4307b19`](https://github.com/horizon-rust/horizon/commit/4307b195ba21710872dd9d52eacabf0ae6c3459e) Merge main ### 📊 Changes **1 file changed** (+102 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/bidi.rs` (+102 -2) </details> ### 📄 Description > 🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi themselves. ## What and why Fixes #2796. Persian letters that do not exist in Arabic (پ چ ژ ک گ ی) were drawn isolated — "پ گ چ ژ" where Persian renders "پگچژ" — although their neighbours joined them. `crates/horizon-client-render/src/bidi.rs` hand-rolls ICU's `ArabicShaping`. `JOINS` classifies those letters correctly; `FORMS`, the table that turns a letter into its joined presentation form, only listed U+0622 to U+064A plus the lam-alef ligatures, and `shape`'s `Right | Dual` arm ends in `FORMS.binary_search_by_key(…).ok().and_then(…).unwrap_or(c)`. So an extended letter fell through to its isolated code point and never joined, even though its neighbours treated it as a joining letter. `FORMS` now carries the presentation forms the Arabic Presentation Forms-B block gives those letters, in the same isolated/final/initial/medial order the table already assumed (پ U+067E → U+FB56–FB59, چ U+0686 → U+FB7A–FB7D, ژ U+0698 → U+FB8A–FB8B and no initial/medial because it is right-joining, ک U+06A9 → U+FB8E–FB91, گ U+06AF → U+FB92–FB95, ی U+06CC → U+FBFC–FBFF, plus the other letters of U+0679–U+06D3 that have a form). The extended letters the block has no presentation form for are left out and stay unchanged, as before — a wrong row would draw a wrong glyph, which is worse than today. The table stays sorted, which `binary_search_by_key` requires. `bidi.rs` had no test module at all; it has six now. ## This reverses a deliberate commit — please read before merging `8a5d7bb78` (2026-10-26, "Leave the extended Arabic letters unshaped, as ICU does") removed **these exact rows** from `FORMS` and wrote the comment I am deleting. So this change is a partial revert of a decision someone made on purpose two days before the report, and it deserves a maintainer's check rather than my judgement. What I can and cannot support: - **For the change:** the report's screenshot, and Unicode's `Arabic Presentation Forms-A`/`-B`, which gives these letters initial/medial/final forms. Vanilla's renderer shapes right-to-left text through ICU4J, and ICU's shaping rules apply to every letter that has a presentation form, not only the Arabic-language ones. - **Against it:** `8a5d7bb78`'s message asserts the opposite about ICU, and I have **no vanilla data on this machine** — no jar, no decompiled sources, so `tools/rea_vanilla.py` cannot run here and I could not settle it. `python3 tools/rea_vanilla.py class com.ibm.icu.text.ArabicShaping`, or a one-line Java check of `ArabicShaping.shape("پگچژ")` against the pinned jar, decides it in a minute. - **If the earlier claim was right**, this belongs as a Horizon extra (better than vanilla for Persian) or not at all — not as a parity fix, and the `Kind` tick above is wrong for it. One more thing a reviewer should know: `8a5d7bb78` changed two things, not one — besides the rows it narrowed `letter_of`'s presentation-forms range from `0xFB50..=0xFDFF | 0xFE70..=0xFEFC` to `0xFE70..=0xFEFC`. I restore only the rows, because with the rows back the narrower `letter_of` still leaves already-shaped extended forms alone, which is the idempotent behaviour. If the maintainer decides the full revert is right, that range belongs in the same change and I can add it. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference The renderer's shaping mirrors ICU's `ArabicShaping` (`u_shapeArabic`, `U_SHAPE_LETTERS_SHAPE`), which the file's own comment already names as its source. The presentation forms are the Unicode `Arabic Presentation Forms-B` block, which is a published table rather than a project's code. The one point I could not check here, and which a reviewer should confirm: the file claimed ICU leaves the extended letters unchanged, which is why they were missing. If that claim was right for the shaper vanilla uses, this change is a deliberate divergence and belongs to Horizon's own font rather than to parity. The report says the opposite of what that comment predicts, and the six tests pin the behaviour either way: `persian_letters_take_their_joined_forms` (the reported word), `right_joining_letters_take_no_initial_or_medial_form` (ژ), `base_arabic_keeps_the_forms_it_had` (control), `lam_followed_by_an_alef_is_one_ligature`, `the_forms_table_is_sorted_and_every_row_joins` and `left_to_right_text_keeps_its_order`. `cargo test -p horizon-client-render --lib bidi` → 6 passed. ## Self-check ``` cargo fmt --all -- --check ✅ cargo test -p horizon-client --bins <new test> 1 passed; 0 failed cargo clippy -p horizon-client --bins --tests -- -D warnings ✅ ``` `python3 tools/pr_ready.py` was not finished here: this machine has no prepared vanilla data (`.local/`), so its harness half only lists what CI must run, and its workspace-wide passes compete for the build cache with other work on the machine. CI's `verify` runs the workspace fmt/clippy/tests. ## Screenshots Players see it: a Persian chat line or sign joins instead of drawing isolated letters. I have no prepared vanilla data on this machine, so I could not capture a before/after; the shaped code points are asserted by the tests instead. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:56 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5924
No description provided.