Fix Windows OCR word order for RTL languages#20537
Open
islambenmebarekdz-collab wants to merge 1 commit into
Open
Fix Windows OCR word order for RTL languages#20537islambenmebarekdz-collab wants to merge 1 commit into
islambenmebarekdz-collab wants to merge 1 commit into
Conversation
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.
Link to issue number:
Fixes #20475
Summary of the issue:
Windows OCR returns words in left-to-right coordinate order even when the recognizer language is right-to-left. As a result, NVDA speaks and navigates Arabic and Hebrew OCR results with the word order reversed.
Description of user facing changes:
Windows OCR results for right-to-left languages are now spoken and navigated in reading order. Embedded left-to-right runs, such as an English phrase within an Arabic sentence, retain their internal order.
Description of developer facing changes:
The Windows OCR bridge now determines the layout direction from
OcrEngine.RecognizerLanguage. It sorts recognized words from right to left for RTL languages and restores the logical order of contiguous LTR word runs. A Universal API contract check preserves compatibility with Windows versions predatingLanguage.LayoutDirection, falling back to the Arabic and Hebrew script identifiers.Description of development approach:
Each OCR line is copied to a vector before serialization. For an RTL recognizer language, the vector is stably sorted by descending horizontal coordinate. Windows character-type information is then used to identify and reverse contiguous LTR runs within the reordered line.
Testing strategy:
ar-SA:مرحبا بكم في عالم البرمجةwas returned asالبرمجة عالم في بكم مرحبا.sourcetarget successfully with warnings treated as errors, including x64, ARM64, and ARM64EC OCR helpers.مرحبا بكم في عالم البرمجةretained the expected reading order.Welcome to the world of programmingremained unchanged.مرحبا good morning جميعاretained both the RTL sentence order and the internal order of the English phrase.contentRecogunit tests successfully.runlint.batandruncheckpot.batsuccessfully.Known issues with pull request:
None known. An automated test was not added because the ordering is implemented in the native WinRT OCR bridge and depends on real OCR output; it was covered with manual end-to-end tests against the built DLL.
Code Review Checklist:
contentRecogsuite)