Tk Source Code

View Ticket
Login
Ticket UUID: 219bd168b2fb4ddb9879c6c247f620118e70af4a
Title: Windows: tk::startOfCluster/endOfCluster return byte offsets since [2e58f8e6aa]
Type: Bug Version: trunk
Submitter: Created on: 2026-11-02 19:22:02
Subsystem: 47. Win Fonts Assigned To: kevin_walzer
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2026-11-03 01:40:48
Resolution: Fixed Closed By: kevin_walzer
    Closed on: 2026-11-03 01:40:48
Description:
Fixed in [498ae6d6]. Thank you, Serhiy.
User Comments: jan.nijtmans added on 2026-11-02 20:57:19:

Thanks for this, and for the testcases!

It turns out that on macOS the ::tk::startOfCluster/endOfCluster functions the answer is not correct either in some cases .....

Having a look (not high prio)

Anyway, I 'stole' your testcases for "trunk" already.


serhiy.storchaka added on 2026-11-02 19:22:02:

Since [2e58f8e6aa], ::tk::startOfCluster and ::tk::endOfCluster on Windows always come from the Uniscribe implementation in win/tkWinFont.c. It returns UTF-8 byte offsets instead of character indices (tk::startOfCluster שלום 2 gives 4), and for end it reads past the end of the break attributes, so the result varies. A click at the start of a line sets the cursor after the first character: text-38.2 and textDisp-32.4 fail, as do 14 tests in cluster.test.

Fixed on branch win-uniscribe-cluster, [0d86873f65]: the indices and the results for indices out of range are the same as with ICU.