Tk Source Code

View Ticket
Login
Ticket UUID: d40ec3d41bd21ab01f09de786a042e563ed9e876
Title: Windows: no bidi analysis, left-to-right paragraph for every string
Type: Bug Version: trunk
Submitter: nab Created on: 2026-10-13 16:28:47
Subsystem: 47. Win Fonts Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2026-10-13 17:32:06
Resolution: Fixed Closed By: nab
    Closed on: 2026-10-13 17:32:06
Description:

On Windows, TkWinShapeString calls ScriptItemize without a SCRIPT_CONTROL and SCRIPT_STATE. Uniscribe then does no bidi analysis: the paragraph is left to right whatever the text, and the neutrals and the digits keep level 0 whatever their context. A neutral or a number after an Arabic or Hebrew word is drawn on its right, and a neutral between two Arabic letters is left in logical order. X11 (SheenBidi) and macOS (CoreText) take the paragraph direction from the first strong character (UAX #9 P2 and P3) and resolve the neutrals by their context, so the same text is laid out differently on Windows.

Branch nab-win-bidi-paragraph, from trunk 36572376e3: the bidi state gets the paragraph direction from the first strong character (bidi class from mojibake), and Uniscribe runs its bidi algorithm (dfe7373bb0). Tests winfont-10.4 (an emoji between Arabic letters is drawn where the bidi algorithm puts it) and winfont-11.1 to 11.4 (an emoji after an Arabic or Hebrew word is drawn at the left end; a Latin first character keeps the line left to right; leading spaces and digits are not strong), red on trunk. The full Windows test suite gives the same results as trunk.

User Comments: nab added on 2026-10-13 17:32:06:

Merged into trunk, 5f33cd9ec1, with Kevin Walzer's go.


Attachments: