Fix RTL text rendering for Arabic, Hebrew, and other right-to-left scripts - #63
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
isRTLUnicodeScalar()helper to detect RTL script Unicode scalars (Hebrew, Arabic, Syriac, Thaana, NKo, etc.)isRTLproperty that checks if any word contains RTL charactersVStackalignment to.trailingfor RTL content.environment(\.layoutDirection, .rightToLeft)on each line'sHStackso word flow renders correctly right-to-leftHighlightingTextEditor.swift:
isRTLUnicodeScalar()function covering Hebrew, Arabic, Syriac, Thaana, NKo, Samaritan, Mandaic, Arabic Extended forms, and presentation formscontainsRTLText()convenience helperupdateWritingDirection()that setstextView.baseWritingDirection = .rightToLeftwhen RTL content is detectedupdateWritingDirection()on initial setup and on text changes (e.g., paste)Test Plan