Skip to content

feat(ui): Hebrew and Arabic read right to left in cells, editors and fields - #1479

Open
H0ruu1 wants to merge 1 commit into
storytold:mainfrom
H0ruu1:feat/hebrew-rtl
Open

H0ruu1 wants to merge 1 commit into
storytold:mainfrom
H0ruu1:feat/hebrew-rtl

Conversation

@H0ruu1

@H0ruu1 H0ruu1 commented Oct 15, 2026

Copy link
Copy Markdown

What this changes

Hebrew and Arabic in GridCraft read right to left, as in Excel. Before, a Hebrew cell drawn by one font came out reversed as a whole ("קובץ 2026" showed as "6202 ץבוק"), mixed cells showed their words in the wrong order, and the caret in the cell editor sat as if the text ran left to right.

  • crates/ui-egui/src/bidi.rs (new): lays right-to-left text out in Unicode bidirectional display order (UAX Fix: list and render installed system fonts (#4) #9). Each stretch of one font and one direction becomes its own section, already in the order egui's shaper needs. Glyphs are then put back into reading order at their screen positions, so the caret, clicks and Backspace follow the text.
  • Cells: Hebrew cells, wrapped cells (broken between words in reading order, the first words on the first row), text boxes, sheet tabs, chart labels, headers and footers read correctly. General-aligned Hebrew text sits at the right, as in Excel. A right-to-left sheet keeps its mirroring.
  • Editing: the cell editor, the formula bar and the main text fields (find and replace, sheet rename, comments, dialog text, filter search) follow the text. In Edit mode Left/Right move the way they point; in Enter mode they still move between cells. Multi-line fields wrap a right-to-left line between words in reading order.
  • File names: recent workbooks and the title bar show Hebrew names as a file manager does: words from the right, the extension at the end.
  • Fonts: workbook fonts bound by name now end with the script fallback faces, as the built-in roles do. Hebrew in Calibri showed boxes.
  • CSV: a non-UTF-8 CSV whose high bytes read as Hebrew is decoded as Windows-1255 (Excel's CSV on Hebrew Windows) instead of Windows-1252.
  • vendor/epaint 0.36.2 with two patches, listed in vendor/README.md and marked GridCraft patch:: (1) a right-to-left run got zero-width continuation glyphs, so glyph count ≠ character count and Backspace hit the wrong character; (2) Glyph::rtl plus bidi-aware Row::x_offset/char_at. PdfCraft, DeckCraft, PhotoCraft and WordCraft carry the same patch. Both should go upstream to egui.

How it was verified

On Windows, GNU toolchain, after rebasing on today's main: cargo fmt --check, clippy -D warnings on gridcraft-ui-egui and gridcraft-xlsx, cargo xtask assets and layers. Tests: the UI crate's lib tests plus every UI integration test binary except native_print (it waits on the real print spooler here), and the CSV tests.

New tests: real-egui layout tests (Hebrew in reading order, caret placement, wrapped paragraphs, file names), tests/hebrew_text.rs (Edit-mode arrows, Enter-mode arrows unchanged; it fails with the arrow fix reverted), the bound-font fallback, and the Windows-1255 detection (French, German and Russian 8-bit text are not mistaken for Hebrew).

Checked by hand in the release build with a Hebrew sample workbook and a Windows-1255 CSV.

Known limits

  • A long line wrapped inside the cell editor or the expanded formula bar keeps drawing order on its rows.
  • The Insert Function and command search boxes and the header/footer editor are plain fields.
  • Excel's per-cell Reading order setting isn't read; the direction comes from the text.

docs/localization-parity.md and the ROADMAP progress log are updated.

🤖 Generated with Claude Code

…fields

- crates/ui-egui/src/bidi.rs: right-to-left text in Unicode bidi display order (UAX storytold#9).
- Cells, wrapped cells (broken between words in reading order), text boxes, sheet tabs, chart
  labels, headers and footers, recent workbooks and the title bar show Hebrew in display order;
  General-aligned Hebrew text sits at the right.
- The cell editor, formula bar and the main text fields: the caret, clicks and Backspace follow
  the text, and Edit-mode Left/Right move the way they point; multi-line fields wrap a
  right-to-left line between words in reading order.
- Workbook fonts bound by name fall back to the script faces (Hebrew in Calibri showed boxes).
- CSV import detects Hebrew in Windows-1255.
- vendor/epaint 0.36.2 with two patches (right-to-left runs got extra continuation glyphs;
  Glyph::rtl and bidi-aware caret placement).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ReviewerA — source-read COMMENT (not an approval)

I read the head of the diff: Hebrew and Arabic read right to left in cells, editors and fields. The lock gains unicode-bidi 0.3.18 and drops a registry source and checksum from a package, which means a package is now supplied by a patch or a path (the same author's deckcraft#792 mentions a patched copy of egui's epaint in vendor/). A vendored patch of a third-party crate is a supply-chain item that needs a numbered row in vendor/README.md. Right-to-left cell display, Excel's Right-to-left sheet direction and per-cell reading order are the oracle. Editing bidirectional text needs correct cursor movement and selection, which visual reordering does not give. It is the suite's shaping and bidi decision (harfrust, unicode-bidi) again. I read the lock hunks. 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.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants