Tk Source Code

View Ticket
Login
2026-10-01
14:50 • Closed ticket [b7ded574]: Tk text line breaks Thai words plus 6 other changes artifact: ab61bd2e user: kevin_walzer
14:47
Implements line breaks (UAX #14) and word/sentence breaks (UAX #29) for Unicode extended grapheme clusters utilizing the mojibake Unicode library, and implements a forward maximum-matching word segmenter using ICU-derived dictionaries for specific scripts without space (Khmer, Lao, Thai) - fix for [b7ded5749c] check-in: e3ef73ae user: kevin_walzer tags: trunk, main
2026-08-15
02:38 • Add attachment Screenshot 2026-08-14 at 10.32.46 PM.png to ticket [b7ded574] artifact: 07a2f931 user: kevin_walzer
02:38 • Ticket [b7ded574] Tk text line breaks Thai words status still Open with 3 other changes artifact: f34411ea user: kevin_walzer
2026-08-09
19:21 • Ticket [b7ded574]: 5 changes artifact: 8911da2b user: kevin_walzer
2026-08-05
19:42 • Ticket [b7ded574]: 3 changes artifact: a87a6aa8 user: kevin_walzer
2026-08-01
05:58 • Ticket [b7ded574]: 3 changes artifact: 3b715f53 user: anonymous
2026-03-30
02:15 • Ticket [b7ded574]: 3 changes artifact: a128ec71 user: kevin_walzer
2024-04-05
16:12 • Ticket [b7ded574]: 4 changes artifact: d0f8929a user: oehhar
2024-03-28
02:24 • New ticket [b7ded574]. artifact: adaec463 user: veer66

Ticket UUID: b7ded5749cb003cdaf2c873baea25ff6ebc8274b
Title: Tk text line breaks Thai words
Type: Bug Version: 39e505e32599e4cdb59d8a8f9949615cb2480d4e
Submitter: veer66 Created on: 2024-03-28 02:24:44
Subsystem: 18. [text] Assigned To: kevin_walzer
Priority: 5 Medium Severity: Severe
Status: Closed Last Modified: 2026-10-01 14:50:15
Resolution: Fixed Closed By: kevin_walzer
    Closed on: 2026-10-01 14:50:15
Description:

By running:

grid [text .myText -font {"Noto Sans Thai" -50 bold} -width 6 -height 5]
.myText insert 1.0 "การบ้านการบ้านการบ้านการบ้านการบ้านการบ้าน"

the result look like this. It splits THAI_CHARACTER_KO_KAI and THAI_CHARACTER_SARA_AA into different lines, which must not happen.

User Comments: kevin_walzer added on 2026-10-01 14:50:15:
Addressed through commit [e3ef73ae] to trunk.

kevin_walzer added on 2026-08-15 02:38:03:
Please review the attachment for a potential fix. We are adding the mojibake Unicode library to support UAX #14 and 29 for word and line breaking, as well as dictionary-based datasets for Thai, Lao, Khmer and Burmese (based on the ICU dictionaries).

kevin_walzer added on 2026-08-09 19:21:03:
It appears that the recent improvements to Tk on all platforms for shaping and bidirectional text support that will be part of Tk 9.1 do not address the issues this bug report raises - decisions about where to break glyph runs are at a different layer of the text rendering process. Implementing this is not a simple project but is definitely something that should be looked at. Leaving this open for future work.

kevin_walzer added on 2026-08-05 19:42:07:
What version of Tk are you testing?  Please test against the tip of trunk - it uses Harfbuzz and Sheenbidi for correct shaping and alignment on X11.

anonymous added on 2026-08-01 05:58:13:
Here the link to the requested example:

https://mstdn.io/@veer66/117018706874241432

kevin_walzer added on 2026-03-30 02:15:30:
We have just added support for text shaping and bidi, which may help.

oehhar added on 2024-04-05 16:12:21:

Dear vsatayamas, thanks for the ticket. Greast that you care!

I fear, Tk just knows nothing about Thai word break. As there are no spaces&friends in the text, it just breaks after each 6th character.

It might be that the usage of the ICU library will manage this. But AFAIK, ICU is so far only used for Shift-Tab navigation to find the next word. And only in Tk 9.0.

So, this is clearly a feature request which may take some time.

It would be great, if you could visually for us do the right word break with not more than 6 glyphs per line.

Thank you and take care, Harald


Attachments: