Skip to content

G9: .ai right-to-left paragraphs keep their alignment - #2859

Merged
bflatastic merged 1 commit into
storytold:mainfrom
ham9zah:fix/ai-rtl-paragraph-alignment
Oct 18, 2026
Merged

bflatastic merged 1 commit into
storytold:mainfrom
ham9zah:fix/ai-rtl-paragraph-alignment

Conversation

@ham9zah

@ham9zah ham9zah commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Problem

Opening an Illustrator .ai file with Arabic layouts moved some point type sideways by its own width: a Latin title ran past the artboard edge, Arabic subtitles started where their right-aligned title ends instead of sitting under it, and a label landed on a QR code.

Cause

A right-to-left paragraph in the editing copy's text document (key 33 = 1 in its paragraph attributes) stores its alignment relative to its direction: "left" (0) puts the line ending at the anchor and "right" (1) puts it starting there. The importer read the alignment and ignored the direction.

Fix

crates/eps/src/import/ate.rs: Para gets an rtl flag (the paragraph's own key 33, else the document default); para_style swaps Left and Right for RTL paragraphs. Centre and the justified alignments are unchanged, and ParaStyle::direction is left as it was. New unit test: right_to_left_paragraphs_swap_left_and_right_alignment.

Evidence

Checked locally, the way the module's other keys were worked out, against ~1,440 single-line point-type stories in 60 of a user's own .ai files (used locally, never committed). For each story, the bounds of its glyphs were compared with its anchor:

alignment direction where the line sits count
left (0) LTR starts at anchor 317
left (0) RTL ends at anchor 332 of 337
right (1) LTR ends at anchor 12
right (1) RTL starts at anchor 51 of 51
centre (2) either centred 687 of 699

The justified alignments (3–6) are not changed, because there were too few RTL samples to verify them.

Verified in the app: the reported file now opens with the moved texts back in place (the title centred on its artboard, subtitles ending at their titles' right edges).

Tests

cargo xtask ci: all 10 steps pass (fmt, clippy, test, no-bundled-fonts, pdf-deps, assets, brands, cursors, layers, wasm); 7,945 tests, 0 failures.

A right-to-left paragraph in an Illustrator editing copy (key 33 of its
paragraph attributes) stores its alignment relative to its direction:
"left" lays the line out ending at the anchor and "right" starting there.
The importer read the alignment alone, so RTL point type opened shifted by
its own width (Arabic headings past the artboard edge, subtitles starting
where their title ends, a label over a QR code).

Checked locally against ~1,440 single-line point-type stories in a user's
own files (never committed): RTL + left ended at the anchor in 332 of 336,
RTL + right started there in 51 of 51; LTR and centred type unchanged.
Justified alignments keep their current mapping (too few samples).
@bflatastic
bflatastic force-pushed the fix/ai-rtl-paragraph-alignment branch from f7e4b1f to 4547439 Compare October 18, 2026 11:41
@bflatastic
bflatastic merged commit b58100c into storytold:main Oct 18, 2026
@coderabbitai

coderabbitai Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fb0a4b4a-c241-4023-afa9-4c2b0a4cf833
📥 Commits

Reviewing files that changed from the base of the PR and between 797e899 and 4547439.

📒 Files selected for processing: 1
  • crates/eps/src/import/ate.rs
+--------------------------------------------+
| This is what it sounds like when bugs cry. |
+--------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@bflatastic

Copy link
Copy Markdown
Member

Thanks @ham9zah, merged. Clear evidence table, and the swap matches how our model reads alignment (Left and Right are absolute, only Auto follows the paragraph's direction), so nothing swaps twice. It went through the full gate (fmt, clippy, tests, layers, wasm).

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