Add RTL shaping support for cmux - #88
Draft
essamgouda97 wants to merge 11 commits into
Draft
Conversation
CoreText emits glyphs in non-monotonic order for RTL runs containing combining marks (tashkeel). The shaper was anchoring cell offsets to run_offset.x (cumulative advances) instead of position.x (CoreText's absolute glyph position), causing adjacent base characters to visually overlap when tashkeel like shadda+kasra appeared at word endings. Use position.x for RTL anchor writes in both the reset and mark-fallback paths. Add a re-anchor path for the case where CoreText emits a combining mark before its base glyph within the same cluster, which caused overlap in multi-word phrases like "الحيِّ الذي". Extract isArabicCombiningMark into a shared bidi_helpers module used by both shapers. Add tashkeel overlap regression tests to both CoreText and HarfBuzz shapers. Also clean up the run iterator: cache row layout resolution across calls, extract fontStyleForStyle/presentationForCell helpers, and replace an unreachable with continue for neutral characters not found in the current run font.
Bump itijah dependency to v0.1.8 and add .lazy = true to match project convention. Extract duplicated font-resolution logic into resolveFontInfo helper.
The existing tashkeel tests checked cluster assignments but not the actual x_offset values that were broken. Add assertions that base glyphs outside the tashkeel cluster have x_offset == 0, which catches the position.x/run_offset.x divergence the previous commit fixed.
- Bump itijah to v0.2.1 (LTR fast path, hasStrongRtl, N0 IRS fix). - Rewrite bidi_helpers comment to drop "emission behavior" jargon and explain the Arabic mark fallback in plain terms. - Expand RTL path comments in coretext/harfbuzz and simplify the cluster_anchor_x init to a single appendNTimes call.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
Validation
zig build test -Dapp-runtime=none -Demit-macos-app=false -Demit-xcframework=false -Dtest-filter=arabiczig build test -Dapp-runtime=none -Demit-macos-app=false -Demit-xcframework=false -Dtest-filter=hebrewzig build test -Dapp-runtime=none -Demit-macos-app=false -Demit-xcframework=false -Dtest-filter=bidizig build test -Dapp-runtime=none -Demit-macos-app=false -Demit-xcframework=false -Dtest-filter=RTLzig build test -Dapp-runtime=none -Demit-macos-app=false -Demit-xcframework=false -Dtest-filter=mixedzig build test -Dapp-runtime=none -Demit-macos-app=false -Dtest-filter=Bengali7a51798436fa2cfcfcc9a2ed1e109ba69bdb68f9and validated the archiveNotes
This is based on the active upstream Ghostty RTL work in
ghostty-org/ghostty#11079, applied to the cmux Ghostty fork so cmux can get native terminal shaping instead of adding text reordering in cmux itself.The exact pinned branch used by the local cmux submodule is also published as
essamgouda97/ghostty:cmux-arabic-rtl-support-pinned-cmux.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Adds native RTL shaping to
cmuxusingitijah-based BiDi layout, bringing correct Arabic, Hebrew, and Bengali rendering in RTL and mixed-direction lines. Fixes combining-mark anchoring and overlap issues in both CoreText and HarfBuzz shapers.New Features
itijahto compute visual runs and split rows at RTL/LTR boundaries.Dependencies
itijahv0.2.1 (lazy) and integrate with shapers; reuseVisualLayoutScratchacross runs.uucodetables withbidi_class,bidi_paired_bracket,joining_type, andis_bidi_mirrored.Written for commit a7cfbb4. Summary will update on new commits.