Tk Source Code

View Ticket
Login
Ticket UUID: 6a78781cc3bc9e84bc56b2af77d4ce8a406383fd
Title: Revised [text]: (textDisp-27.10) numeric adjust text needs calculation fixes
Type: Bug Version: revised_text, 8.6.7
Submitter: bll Created on: 2017-08-12 14:29:08
Subsystem: 18. [text] Assigned To: gcramer
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2021-07-14 15:45:05
Resolution: Fixed Closed By: nobody
    Closed on:
Description:
This is test textDisp-27.10.

When doing numeric alignment, the text is wrapped when there is clearly enough room.

The expected result is probably wrong, all numeric alignment tests will need to be fixed after the tab width calculations are fixed.

package require Tk
set fixedFont {"Courier New" -12}
set fixedWidth [font measure $fixedFont m]
set fixedHeight [font metrics $fixedFont -linespace]
frame .f -width 100 -height 20
pack .f -side left
text .t -font $fixedFont -width 40 -height 10
pack .t -expand 1 -fill both
update
set bw [.t cget -borderwidth]
set px [.t cget -padx]
set py [.t cget -pady]
set hlth [.t cget -highlightthickness]
set padx [expr {$bw+$px+$hlth}]
set pady [expr {$bw+$py+$hlth}]

    .t delete 1.0 end
    .t insert 1.0 a\t123.4
    .t tag delete x
    # make room for 3 characters
    set wid [expr {[winfo width .t]-2*$padx-3*$fixedWidth}]
    .t tag configure x -tabs [list $wid numeric]
    .t tag add x 1.0 end
    set res [.t bbox 1.5]
    set exp [list $wid $pady $fixedWidth $fixedHeight]
    set _trc 0
    if { $res eq $exp } {
      set _trc 1
    } else {
      puts "result: $res"
      puts "expected: $exp"
    }
    set _trc
User Comments: jan.nijtmans added on 2021-04-27 14:06:29:

Testcase textDisp-27.10 in revised_text is now marked as "knownBug". Someone wants to take this ticket?


fvogel added on 2018-10-07 09:54:35:

Indeed rendering with "-wrap char" (the case of textDisp-27.10 and of the submitted test script) is now OK for me on Windows (see attachment "Rendering OK on Win - 2018 10 07.png").

However, test textDisp-27.10, that the test script from Brad mimics, is still failing for me in the revised_text branch (only - it does not fail with the legacy widget). For this reason I think this ticket should be kept open. Probably this is just about fixing the expected result, but still it needs to be done before closing this ticket.

Log of the test failure:

==== textDisp-27.10 SizeOfTab procedure, numeric alignment FAILED
==== Contents of test case:

    .t delete 1.0 end
    .t insert 1.0 a\t123.4
    .t tag delete x
    .t tag configure x -tabs {120 numeric}
    .t tag add x 1.0 end
    list [.t bbox 1.3] [.t bbox 1.4]

---- Result was:
{110 5 7 15} {117 5 7 15}
---- Result should have been (exact matching):
{117 5 27 15} {4 20 7 15}
==== textDisp-27.10 FAILED


gcramer added on 2017-08-15 14:14:28:
The whole tab handling has been overworked, because the legacy widget did not implement line wrapping when tabs are involved. With [e1566eb2e] line wrapping is working so far if wrap=char (or "none", like in your test script), but wrap=word is not yet implemented. And the whole thing needs more testing, the implementation is quite complex.

One correction in your script:

    incr wid $padx ;# CORRECTION
    set exp [list $wid $pady $fixedWidth $fixedHeight]

Attachments: