Tk Source Code

View Ticket
Login
2026-10-22
17:22 • Ticket [d08538fd] Regression in 9.1: wrapped text counts spaces at end of line, splits words, breaks after leading spaces (X11 with bidi, Windows) status still Closed with 3 other changes artifact: 6186b255 user: serhiy.storchaka
2026-10-06
11:45 • Closed ticket [d08538fd]. artifact: d421aa6d user: serhiy.storchaka
11:44 • Ticket [d08538fd]: 3 changes artifact: 747fe903 user: serhiy.storchaka
11:36
Fix [d08538fd78]: Regression in 9.1: wrapped text counts spaces at end of line, splits words, breaks after leading spaces (X11 with bidi, Windows) check-in: 123cc66f user: serhiy.storchaka tags: trunk, main
2026-10-01
09:45 • New ticket [d08538fd] Regression in 9.1: wrapped text counts spaces at end of line, splits words, breaks after leading spaces (X11 with bidi, Windows). artifact: 4bc34832 user: serhiy.storchaka
09:42
Fix [d08538fd78]: regression in 9.1 in word wrapping with the text shaping font backends (X11 with bidi, Windows). With TK_WHOLE_WORDS, Tk_MeasureChars() counted the spaces at the end of a line in its width, split a word which did not fit after a tab, and treated leading spaces as a word boundary (bug 1006286 again). Restore the 9.0 constraints of the tests which were disabled because of this. closed check-in: 0ef89066 user: serhiy.storchaka tags: shaping-whole-words

Ticket UUID: d08538fd78a8f39bc0a7a5c860fd4b5f771617da
Title: Regression in 9.1: wrapped text counts spaces at end of line, splits words, breaks after leading spaces (X11 with bidi, Windows)
Type: Bug Version: 9.1.0
Submitter: serhiy.storchaka Created on: 2026-10-01 09:45:59
Subsystem: 44. Generic Fonts Assigned To:
Priority: Severity:
Status: Closed Last Modified: 2026-10-22 17:22:38
Resolution: Fixed Closed By: serhiy.storchaka
    Closed on: 2026-10-06 11:45:56
Description:

This is a regression in 9.1. The text shaping font backends (X11 built with bidi, which is the default, and Windows) implement Tk_MeasureChars() with TK_WHOLE_WORDS differently from the other backends and from 9.0, so wrapped text in labels, canvas text items, etc. is laid out differently:

  • The spaces at the end of a line are counted in its width.
  • A word which does not fit after a tab is split instead of moved to the next line.
  • Leading spaces are treated as a word boundary, so text starting with spaces breaks after them (bug [1006286] again).
pack [label .l -font TkFixedFont -padx 0 -pady 0 -bd 0 -highlightthickness 0 \
	-text "000            000" -wraplength [font measure TkFixedFont 00000]]
update
puts [expr {[winfo reqwidth .l] / [font measure TkFixedFont 0]}]

This prints 3 with 9.0 and 5 with 9.1.

The failing tests were restricted to macOS (font-24.5, 24.11, 24.12, 30.6, 31.6, canvText-19.1) or excluded on other platforms (canvText-10.1, textDisp-9.7 and textDisp-21.1 on Windows, unixfont-5.6, 5.7 and 5.8 with Xft). 9.0 runs all of them on all platforms.

Proposed fix in branch shaping-whole-words: use the same word-boundary rules as the other backends, and restore the 9.0 constraints of these tests. Tested on X11 (with bidi, without bidi, without Xft) and Windows.

User Comments: serhiy.storchaka added on 2026-10-06 11:44:41:

Merged into main [123cc66f98]. Tested on X11 with bidi and on Windows. Tk 9.0 is not affected: it has neither text shaping on X11 nor Uniscribe on Windows.