Skip to content

Fix RTL text rendering for Arabic, Hebrew, and other right-to-left scripts - #63

Merged
f merged 2 commits into
f:masterfrom
MHegazy89:fix/rtl-arabic-text-rendering
Aug 8, 2026
Merged

Fix RTL text rendering for Arabic, Hebrew, and other right-to-left scripts#63
f merged 2 commits into
f:masterfrom
MHegazy89:fix/rtl-arabic-text-rendering

Conversation

@MHegazy89

Copy link
Copy Markdown
Contributor

Summary

Fixes garbled and incorrect text rendering when using Arabic, Hebrew, Persian, Urdu, and other right-to-left (RTL) scripts in Textream.

Changes

MarqueeTextView.swift:

  • Added isRTLUnicodeScalar() helper to detect RTL script Unicode scalars (Hebrew, Arabic, Syriac, Thaana, NKo, etc.)
  • Added computed isRTL property that checks if any word contains RTL characters
  • Flips VStack alignment to .trailing for RTL content
  • Sets .environment(\.layoutDirection, .rightToLeft) on each line's HStack so word flow renders correctly right-to-left

HighlightingTextEditor.swift:

  • Added isRTLUnicodeScalar() function covering Hebrew, Arabic, Syriac, Thaana, NKo, Samaritan, Mandaic, Arabic Extended forms, and presentation forms
  • Added containsRTLText() convenience helper
  • Added updateWritingDirection() that sets textView.baseWritingDirection = .rightToLeft when RTL content is detected
  • Called updateWritingDirection() on initial setup and on text changes (e.g., paste)

Test Plan

  • Open Textream with Arabic text - verify words flow right-to-left in marquee view
  • Open Textream with Hebrew text - verify correct rendering
  • Type/paste Arabic in the editor - verify caret and alignment are RTL
  • Verify LTR text continues to work as before
  • Verify mixed LTR/RTL content handles correctly

Rafa-Ross and others added 2 commits June 25, 2026 10:34
…cripts

- MarqueeTextView: Detect RTL content via isRTLUnicodeScalar(), flip VStack
  alignment to .trailing for RTL, and set .environment(\.layoutDirection) so
  word flow lines render right-to-left.
- HighlightingTextEditor: Add isRTLUnicodeScalar() and containsRTLText()
  helpers, plus updateWritingDirection() that sets textView.baseWritingDirection
  to .rightToLeft when RTL content is detected, ensuring proper caret and text
  alignment in the editor.

Fixes garbled/truncated display when dictating or editing Arabic, Hebrew,
Persian, Urdu, and other RTL text.
Preserve cue styling and annotation matching while adding first-strong text direction detection for editor and native teleprompter surfaces.
@f
f changed the base branch from main to master August 8, 2026 21:56
@f
f merged commit ce11831 into f:master Aug 8, 2026
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.

3 participants